Playscript is Happy
First, I should mention that I've posted the sleepscript and the alarmscript here at the bottom. Feel free to scroll down the bottom of this post if you care at all:-P
I (think I've) finished a third script. This one loads a specified playlist, chooses a place at random in that script to start, then plays from there, once the current song (if any) is done playing. It turns off the randomness as soon as it starts playing from the new script, so it'll keep the order once it starts.
So, if I want to play my playlist named 'Progressive', I type the following:
$ ./playscript.sh Progressive
playscript:
DISPLAY=:0.0
export DISPLAY
fileString="file:///home/paithan/.kde/share/apps/amarok/playlists/$1.m3u"
echo $fileString
dcop amarok player enableRandomMode true
dcop amarok playlist clearPlaylist
dcop amarok playlist addMedia $fileString
sleep 1
if [ "$(dcop amarok player isPlaying)" = "true" ];then
totalSeconds=$(dcop amarok player trackTotalTime)
secondsPlayed=$(dcop amarok player trackCurrentTime)
secondsLeft=$(( totalSeconds - secondsPlayed ))
echo "amaroK is currently playing"
echo "The new playlist will begin playing in $secondsLeft seconds."
sleep $((secondsLeft + 1))
else
sleep 1
dcop amarok player play
fi
dcop amarok player enableRandomMode false
Now, as promised, here are the other two scripts.
sleepscript:
DISPLAY=:0.0
export DISPLAY
echo "Time to go to sleep, Kyle..."
echo "Stopping amaroK..."
dcop amarok player stop
echo "Setting your machine's volume..."
aumix -v 4
echo "Enabling amaroK's randomness..."
dcop amarok player enableRandomMode true
echo "Clearing the previous playlist..."
dcop amarok playlist clearPlaylist
echo "Loading the Sleep playlist..."
dcop amarok playlist addMedia file:///home/paithan/.kde/share/apps/amarok/playlists/Sleep.m3u
echo "Playing in 3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
echo "Now."
dcop amarok player play
echo "Go to sleep, Kyle..."
for i in $(seq 71)
do
j=$((70-i))
dcop amarok player setVolume $j
sleep $i
done
dcop amarok player stop
alarmscript:
DISPLAY=:0.0
export DISPLAY
aumix -v 9
echo "It's time to wake Kyle up..."
echo "Enabling Randomness..."
dcop amarok player enableRandomMode true
echo "Clearing the previous playlist..."
dcop amarok playlist clearPlaylist
echo "Stopping amaroK..."
dcop amarok player stop
echo "Loading the Awaken playlist..."
dcop amarok playlist addMedia file:///home/paithan/.kde/share/apps/amarok/playlists/Awaken.m3u
echo "Maximizing amaroK's volume..."
dcop amarok player setVolume 65
echo "AmaroK will play in 3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
echo "Now."
dcop amarok player play
echo "Here's the weather"
firefox http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Boston%2C+MA
I (think I've) finished a third script. This one loads a specified playlist, chooses a place at random in that script to start, then plays from there, once the current song (if any) is done playing. It turns off the randomness as soon as it starts playing from the new script, so it'll keep the order once it starts.
So, if I want to play my playlist named 'Progressive', I type the following:
$ ./playscript.sh Progressive
playscript:
DISPLAY=:0.0
export DISPLAY
fileString="file:///home/paithan/.kde/share/apps/amarok/playlists/$1.m3u"
echo $fileString
dcop amarok player enableRandomMode true
dcop amarok playlist clearPlaylist
dcop amarok playlist addMedia $fileString
sleep 1
if [ "$(dcop amarok player isPlaying)" = "true" ];then
totalSeconds=$(dcop amarok player trackTotalTime)
secondsPlayed=$(dcop amarok player trackCurrentTime)
secondsLeft=$(( totalSeconds - secondsPlayed ))
echo "amaroK is currently playing"
echo "The new playlist will begin playing in $secondsLeft seconds."
sleep $((secondsLeft + 1))
else
sleep 1
dcop amarok player play
fi
dcop amarok player enableRandomMode false
Now, as promised, here are the other two scripts.
sleepscript:
DISPLAY=:0.0
export DISPLAY
echo "Time to go to sleep, Kyle..."
echo "Stopping amaroK..."
dcop amarok player stop
echo "Setting your machine's volume..."
aumix -v 4
echo "Enabling amaroK's randomness..."
dcop amarok player enableRandomMode true
echo "Clearing the previous playlist..."
dcop amarok playlist clearPlaylist
echo "Loading the Sleep playlist..."
dcop amarok playlist addMedia file:///home/paithan/.kde/share/apps/amarok/playlists/Sleep.m3u
echo "Playing in 3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
echo "Now."
dcop amarok player play
echo "Go to sleep, Kyle..."
for i in $(seq 71)
do
j=$((70-i))
dcop amarok player setVolume $j
sleep $i
done
dcop amarok player stop
alarmscript:
DISPLAY=:0.0
export DISPLAY
aumix -v 9
echo "It's time to wake Kyle up..."
echo "Enabling Randomness..."
dcop amarok player enableRandomMode true
echo "Clearing the previous playlist..."
dcop amarok playlist clearPlaylist
echo "Stopping amaroK..."
dcop amarok player stop
echo "Loading the Awaken playlist..."
dcop amarok playlist addMedia file:///home/paithan/.kde/share/apps/amarok/playlists/Awaken.m3u
echo "Maximizing amaroK's volume..."
dcop amarok player setVolume 65
echo "AmaroK will play in 3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
echo "Now."
dcop amarok player play
echo "Here's the weather"
firefox http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Boston%2C+MA
0 Comments:
Post a Comment
<< Home