[vox-tech] cdcd

nbs vox-tech@lists.lugod.org
Tue, 10 Sep 2002 13:10:26 -0700


I've been listening to CDs a lot at work lately (for the past two years,
I pretty much never did for some reason)

Anyway, I installed a little tiny CD player applet into one of my gnome panels,
but have found that I always forget to pause before I lock my screen...
and that if I need to pause (or do anything else), I have to use the mouse.

"So?" you might be asking.  Well, I almost NEVER use the mouse at work.

If I want a terminal, I hit F1.  Need a new Netscape window? F2.
Minimize a window?  Keypad-Minus.
Vertically maximize my terminal?  Keypad-PgUp.
Lock my screen?  Pause.

Heck, I can even slide windows around using the Keypad-Arrow keys! :)


This is all thanks to the SawFish window manager, and its nifty keybinding
("Shortcuts") feature.


So, I decided I'd figure out how to control my CD player with keys
(since I don't have one of those ridiculous "internet keyboards" with
dozens of buttons at the top).

I poked around dselect until I noticed "cdcd", a command-line and console
CD player.

It has just what I need!  I can run the command:

  cdcd pause

...and it'll pause the track.  Or:

  cdcd resume

...and it'll unpause.  And so forth.



Since I didn't see any obvious "toggle pause/unpause" option,
I decided to whip up the following little Perl script, which I now
have bound to my "Break" key (Shift+Pause; so if I want to walk away
from my computer, I can just hit Shift+Pause, Pause, and it'll pause my
CD and lock my screen):

--------------------------------------------- toggle_cd.pl ----------------
#!/usr/local/bin/perl

my $i=`cdcd status`;

if ($i =~ m/^Playing /)
{
  system "cdcd pause";
}
elsif ($i =~ m/^Stopped/)
{
  system "cdcd play";
}
elsif ($i =~ m/^Paused /)
{
  system "cdcd resume";
}
---------------------------------------------------------------------------


For changing tracks, I just bound the commands "cdcd next" and "cdcd prev"
to Shift+Keypad-Right and Shift+Keypad-Left.


Anyway, thought I'd share it with everyone, cuz it's pretty nifty,
and doesn't need any bloated apps like XMMS.  (Just a bloated windowmanager ;)

("cdcd" was an approx. 86K download via apt-get)


-bill!