Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

XMMS Controller

by throttle (Beadle)
on Nov 03, 2004 at 14:32 UTC ( #404899=sourcecode: print w/replies, xml ) Need Help??
Category: Audio Related Programs
Author/Contact Info If you have any suggestion, please email me at throttlehackcrack(_at_)yahoo(_dot_)it . (instead of (_at_) use @, the same for (
Description: Well, I often listen to music when I'm working, so I put xmms in background and I play all the mp3s that i have. But I don't like all of them, so i have to resume XMMS' icon (in fluxbox it's a bit boring) and change song. So i wrote this little script. It doesn't occupy much space on the screen, so you can have this in the foreground without problem, and you can change song whenever you want, without having to resume xmms (that must be started before you run this script). This was my first working (and someway useful) perl script. I wrote it this summer.
It needs Tk to work properly, so install it.
#!/usr/bin/perl
#XMMS Controller    (C)2004 by Throttle

#This program is free software. You can use, copy, modificate, distrib
+ute it under
#the terms of GNU GPL version 2 or later. The software is provided wit
+h no warranty.


use strict;
use Tk;

my $window = MainWindow->new(-title=>"XMMS Controller");
$window->Button(-text=>"Prev", -command=> sub{click(1)})->pack(-side=>
+'left');
$window->Button(-text=>"Play", -command=> sub{click(2)})->pack(-side=>
+'left');
$window->Button(-text=>"Pause", -command=> sub{click(3)})->pack(-side=
+>'left');
$window->Button(-text=>"Next", -command=> sub{click(4)})->pack(-side=>
+'left');
$window->Button(-text=>"Exit", -command=>[$window=>'destroy'])->pack;

MainLoop;

sub click
{
    my $todo = shift;

    if($todo == 1) {system "xmms -r";}
    if($todo == 2) {system "xmms -p";}
    if($todo == 3) {system "xmms -u";}
    if($todo == 4) {system "xmms -f";}
}
Replies are listed 'Best First'.
Re: XMMS Controller
by Chady (Priest) on Nov 04, 2004 at 07:33 UTC

    a small nitpick; I would write your click() as:

    sub click { my $todo = shift; system "xmms -$todo"; }

    and change the buttons' callbacks to

    $window->Button(-text=>"Prev", -command=> sub{click('r')})->pack(-side +=>'left'); $window->Button(-text=>"Play", -command=> sub{click('p')})->pack(-side +=>'left'); $window->Button(-text=>"Pause", -command=> sub{click('u')})->pack(-sid +e=>'left'); $window->Button(-text=>"Next", -command=> sub{click('f')})->pack(-side +=>'left');

    You might also want to check wmxmms which sits in some kind of dock and can control xmms for you.


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
    Chady | http://chady.net/
    Are you a Linux user in Lebanon? join the Lebanese Linux User Group.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://404899]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2021-10-28 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (95 votes). Check out past polls.

    Notices?