tonybaldwin | blog

non compos mentis

Posts Tagged ‘mplayer

Bashful, Ticklish Snoozing (sleeping with bash and tcl)

leave a comment »

So, sometimes you want to take a snooze, or, maybe time something else (like that bacon explosion in the oven).  We can use the bash command “sleep” to help us out.  Something as simple as:

sleep 600 ; echo ‘Hey, get the bacon out the oven, d00d’ &

That will wait 10 minutes (600 seconds), and then print ‘Hey, get the bacon out the oven, d00d’ to your terminal.  The only thing is, that terminal is waiting, and you can’t do anything else in it, so you open another, and then never see the message.  Useless, really… But, say we’re going to take a nap, and we just want to be awakened in an hour.  We won’t be using the terminal (and a printed message isn’t going to wake us up).

Let’s play tunes, instead then!  This one will require mplayer.

sleep 3600 ; mplayer ~/Music/roxors/opeth/blackwater_park/08_blackwater_park.ogg

That’ll get you going!  In one hour, mplayer will pipe up with Opeth’s BlackWater Park! (If that doesn’t wake you, you’ve probably died in your sleep).

Clearly, the path to YOUR Opeth collection may be different, but you get the point.

Now, you could facilitate the whole process with a little script. I have:

# snooze time
echo “How long ya want, pal?”
read m
secs=$(($m * 60 ))
echo Okay, that gives us about $secs seconds
echo Then we will play the Imperial March.
echo Make sure the speakers are on and turned up.
echo That will get you going.
sleep $secs ; mplayer ~/tunes/starwars/03-star_wars_the_empire_strikes_back-the_imperial_march.mp3 &

Or, we can wrap that up in a little gui with some tcl/tk.


# sleep timer with musical wake-up

# set vars

global count
global secs
global tunage

set count “0”
set mins “0”
set secs “0”
set tunage “none”

set filetypes {
{“All files” * }
{“MP3” {.mp3}}
{“OGG” {.ogg}}

# gui

wm title . “Snooze Timer”

grid [ttk::label .secs -text “Minutes:”]\
[ttk::entry .min -textvariable mins]

grid [ttk::button .bu -text “seconds: ” -command sex ]\
[ttk::label .bn -textvariable secs ]

proc sex {} {
if {[catch {
set ::secs [ expr {$::mins * 60} ]
}]!=0} {
set ::secs “?”

grid [ttk::button .chtune -text “Choose song:” -command chutu]\
[ttk::entry .tuna -textvariable tunage]

grid [ttk::button .go -text “SNOOZE” -command snooze]\
[ttk::button .stop -text “QUIT” -command exit]

proc calcu {} {
exec tcalcu

proc chutu {} {
global tunage
set tunage [tk_getOpenFile -filetypes $::filetypes -initialdir “~/Music”]

proc snooze {} {
set snooz “sleep $::secs ; mplayer $::tunage”
exec sh -c $snooz &

That gives you a little gui that sets the time, and even allows you to pick a song (in the image, I picked Ministry’s “Jesus Built My Hot Rod“).  It has a file chooser to pick the song.  You just feed it a number of minutes (press the button to calculate seconds), pick a song, click snooze, and kick back.  After your chosen time interval, your chosen tune will come on and wake you! (or remind you to get the bacon explosion out of the oven).


Written by tonybaldwin

February 2, 2011 at 7:59 am

Posted in free software, gnu/linux, hacking

Tagged with , , , ,

NEW Tickle Tunes release!

leave a comment »

I’ve released Tickle Tunes 0.7.

Added to this release:
support for DVD playing.
support for playing directories recursively (ie. a folder for an artist, and subfolders for albums, or, a folder for a genre, and all the artists and albums thereunder, etc.)

Also, the default theme is gro0vier.

Written by tonybaldwin

September 12, 2008 at 9:56 pm

deeper and deeper…

leave a comment »

I’ve just totally sunk into a world of dark, blackness….
with pretty colored text.

I’m find myself using my terminal for anything I can get away with now…

chatting on irc with irssi
for instance…

listening to tunes while chatting on irc in irssi

the other tabs on my terminal or doing other stuff, too.

Heck, my last post…the long, long list o’ tunes, well, I did
ls -R /mnt/storage/tunes > tuneslist.txt
to pipe the list output from terminal to a text file.
Then I did use a gui text editor, my Tickle Text
to edit the rest of the html to make a web page with it…uploaded it with my TclUP
Before you know it, I’ll be editing html pages in nano in terminal and ftp-ing them to my site in a wish terminal (since tcl has good ftp tools)…
I’ll be writing lj-posts via e-mail with mutt, and reading my friend’s page with Lynx
I’m hopeless…

Written by tonybaldwin

September 2, 2008 at 2:32 pm