Kilépes egyelőre csak Ctrl-C-vel.
#!/bin/bash
# simple script to control audacious2 over ssh (X forwarding needed)
# author: pgee
#display where audacious2 is running
export DISPLAY=:0
#default settings
style=0
display_next=0
refresh_time=1
new_pos=-1
pos=0
state_refresh=5
i=0
loved_tracks_filename='/home/pgee/loved_tracks.txt'
#generate song info from params
gen_info () {
if [ $1 -eq 0 ]; then
info="$2 - $3"
elif [ $1 -eq 1 ]; then
info="$2 - $4 - $3"
elif [ $1 -eq 2 ]; then
info="$2 - $3 [> $4 <]"
fi
}
#main loop
while true
do
new_pos=`audtool2 playlist-position`
current=`audtool2 current-song-output-length`
#collect data if song changed
if [ $pos -ne $new_pos ]; then
artist=`audtool2 current-song-tuple-data artist`
title=`audtool2 current-song-tuple-data title`
album=`audtool2 current-song-tuple-data album`
length=`audtool2 current-song-length`
gen_info $style "$artist" "$title" "$album"
song_info=$info
current_fname=`audtool2 current-song-filename`
loved=`grep -c "$current_fname" $loved_tracks_filename`
fi
# state update in every $refresh * $state_refresh sec
if [ $i -eq 0 ]; then
state=`audtool2 playback-status`
shuffle=`audtool2 playlist-shuffle-status`
volume=`audtool2 get-volume`
let "i++"
else
let "i++"
let "i%=$state_refresh"
fi
if [ $display_next -gt 0 -a $new_pos -ne $pos ]; then
let "next_pos=$new_pos + 1"
next_artist=`audtool2 playlist-tuple-data artist $next_pos`
next_title=`audtool2 playlist-tuple-data title $next_pos`
next_album=`audtool2 playlist-tuple-data album $next_pos`
gen_info $style "$next_artist" "$next_title" "$next_album"
next_info="[next song: $info]"
fi
let "pos=$new_pos"
clear
#print song details
if [ $display_next -lt 2 ]; then
echo "$song_info"
elif [ $display_next -eq 2 ]; then
echo "$song_info $next_info"
elif [ $display_next -eq 3 ]; then
echo "$song_info"
echo "$next_info"
fi
#print player details
echo "$current ($length) [$state] [vol: $volume] [loved: $loved] [shuffle: $shuffle] [refresh: $refresh_time] [pos: $pos]"
#print next info if needed here
if [ $display_next -eq 1 ]; then
echo "$next_info"
fi
#get command
read -s -t $refresh_time -n 1 cmd;
if [ "$cmd" = "s" ]; then
#play pause
let "i=0"
audtool2 playback-playpause
elif [ "$cmd" = "n" ]; then
#next track
let "i=0"
audtool2 playlist-advance
elif [ "$cmd" = "p" ]; then
#previous track
let "i=0"
audtool2 playlist-reverse
elif [ "$cmd" = "q" ]; then
#volume down
let "i=0"
let "volume-=3"
if [ "$volume" -lt 0 ]; then
volume=0
fi
audtool2 set-volume "$volume"
elif [ "$cmd" = "w" ]; then
#volume up
let "i=0"
let "volume+=3"
if [ "$volume" -gt 100 ]; then
volume=100
fi
audtool2 set-volume "$volume"
elif [ "$cmd" = "r" ]; then
#toggle refresh_time
let "refresh_time%=5";
let "refresh_time++";
elif [ "$cmd" = "l" ]; then
if [ "$loved" -eq 0 ]; then
echo "$current_fname" > $loved_tracks_filename;
else
grep -v "$current_fname" $loved_tracks_filename > $loved_tracks_filename;
fi
loved=`grep -c "$current_fname" $loved_tracks_filename`
elif [ "$cmd" = "v" ]; then
#toggle printing next song
pos=-1
let "display_next++";
let "display_next%=4";
elif [ "$cmd" = "d" ]; then
#change style
let "style++";
let "style%=3";
gen_info $style "$artist" "$title" "$album"
song_info=$info
fi
done;
- pgee blogja
- A hozzászóláshoz be kell jelentkezni
- 1060 megtekintés
Hozzászólások
Az mpd pont erre való. deamon fut a gépen, a telefonra meg szerzel egy klienst.
- A hozzászóláshoz be kell jelentkezni
- A hozzászóláshoz be kell jelentkezni
A telefonos példa csak egy volt, igazából két gépen használom, de nagyon köszi a linket, ezt megnézem, viccesnek tűnik... :D
- A hozzászóláshoz be kell jelentkezni
last.fm scrobbling van?
- A hozzászóláshoz be kell jelentkezni
miért ne lenne?
még válogathatsz is: mpdscibble, scrobby
- A hozzászóláshoz be kell jelentkezni
én ezt használtam ilyesmire: http://audtty.alioth.debian.org/
- A hozzászóláshoz be kell jelentkezni
Hmm... pont ilyesmi kellett volna valóban... :) Köszi.
- A hozzászóláshoz be kell jelentkezni