I fall asleep better when I listen to music. Trouble is I hate waking up to it. I wrote a really simple script that kills xmms in 2 hours but it is very inflexible. Here is the script in it's current sad state, any help would be greatly appreciated in making it more usable.
#!/bin/bash
# I would like to have the script figure out the pid of xmms on it's own
# Xmms has several processes running at once, killing any one of them
# kills them all
echo Killing xmms pid 11470 in 2 hours
# It's optional but it should ask the user how long it should wait
sleep 7200
# Again it should be able to figure out the pid on it's own
kill 11470
# Rather than killing it, is there a way to simply tell xmms to stop playing?
Basic scripting question
Started by
kizzle
, Nov 23 2003 04:54 AM
5 replies to this topic
#1
Posted 23 November 2003 - 04:54 AM
#2
Posted 23 November 2003 - 05:39 AM
If you're going to sleep at roughly the same time every night, this should work-
Have cron run it at at the appropriate time.
But if sleepy time is going to be variable, something like this might work-
Name it whatever you like, but for the sake of demonstration I'll call it "XmmsGenocide".
It's usage would be: XmmsGenocide "sleep_time_in_seconds"
Hope this helps. If not, call me a faggot and I'll try to get it right next time.
#!/bin/bash killall XMMS
Have cron run it at at the appropriate time.
But if sleepy time is going to be variable, something like this might work-
#!/bin/bash sleep $1 killall XMMS
Name it whatever you like, but for the sake of demonstration I'll call it "XmmsGenocide".
It's usage would be: XmmsGenocide "sleep_time_in_seconds"
Hope this helps. If not, call me a faggot and I'll try to get it right next time.
#3
Posted 23 November 2003 - 10:01 PM
I've made the script much more usefull. Thanks for the help!
#!/bin/bash
echo Stopping current song xmms is playing in $1 minutes
sleep $1m
xmms -u #pauses the current song
echo Done
#!/bin/bash
echo Stopping current song xmms is playing in $1 minutes
sleep $1m
xmms -u #pauses the current song
echo Done
#4
Posted 24 November 2003 - 07:25 PM
paracord you sexy bish.Hope this helps. If not, call me a faggot and I'll try to get it right next time.
#5
Posted 25 November 2003 - 06:37 PM
lol
#6
Posted 26 November 2003 - 09:11 AM
In case anyone wants to know how to do what he originally wanted I have a script that does just that
you can change it to grep whatever you want, the [] keeps grep from matching its own process, if more than one process matches the string it will kill them all. Also you could expand on it more taking command line arguments for what process to search for and kill and how long to wait.
#!/bin/bash
PID="`ps -aux | grep [s]ystemlog | awk '{print $2}'`"
kill $PID
you can change it to grep whatever you want, the [] keeps grep from matching its own process, if more than one process matches the string it will kill them all. Also you could expand on it more taking command line arguments for what process to search for and kill and how long to wait.
BinRev is hosted by the great people at Lunarpages!












