application icongmusicbrowser

This is an old revision of the document!


Xchat plugin: commands gmusicbrowser from xchat

It's at a very early stage so be kind. It is inspired from rythmbox xchat perl plugin.

I added some checks so that it fails to load gracefully.

the script is now capable of launching gmusicbrowser It will load gmusicbrowser automatically upon startup

If you close gmusicbrowser then use one of the command it will let you know that it needs restarting. A new commands lets you do that.

Installing the script

Changing the message displayed

Edit the script (in your editor of choice) and update the message printed.

# message string
my $playing ="écoute sur son magnétophone numérique"; #replace with your own message  

The script can display all the informations provided by Dbus to modify the output: Dbus provides album, artist, disc, length, title, track. The current scrip displays artist - title - album

as shown below.

sub gm_play{
	my $info= $object->CurrentSong;
	# hash keys are : album, artist, disc, length, title, track
	# $info hash contains the keys value above. you can change below to display information you need. keep "me" (command will generate the slash).
	Xchat::command "me $playing $info->{artist} - $info->{title} - $info->{album}";
}

To display say artist - album - song - tracknumber

you would use

Xchat::command "me $playing $info->{artist} - $info->{album} - $info->{title} - $info->{track}";

Once you are happy with it Load it into xchat. Xchat Menu → Load plugin or script → Browse to the location of the script.

If you messed up you will get an error message :-P Along those lines… Compare the original script with your update, above or on the line number given.

 Error loading '/home/laurent/.xchat2/gmplay.pl':
 Bareword found where operator expected at (eval 29) line 60, near ")
 Xchat::print"
 syntax error at (eval 29) line 60, near ")
 Xchat::print"

if everything is fine Xchat will let you know by printing the message

 Loaded gmusic XChat 0.0.5:

gmusicbrowser is not loaded already.

The script will start it and wait 4 seconds. It is possible that your machine is slower to load gmusicbrowser. In that case the script will not load correctly as it has not waited long enough.

 starting gmusic browser
 Error loading '/home/laurent/.xchat2/gmplay.pl':
 org.freedesktop.DBus.Error.ServiceUnknown: The name org.gmusicbrowser was not provided by any .service files

If gmusicbrowser loads anyway then you just need to update the script.

Search the script file around the line 150 for

sleep (4);

change it to 6 or more to lengthen the time margin your script will wait before it attempts to connect via Dbus.

Commands available

Help

Now that you have installed and updated your script.

What can it do ?

in xchat type

/gm_help

You will be able to View this:

 gmusic XChat Help:
   * Script Version:     0.0.5
  About:
   * Author: Laurent Coudeur <####################">
  Commands:
  * /gm_start	- starts gmusic browser when it has been closed.
  * /gm_play - Display the current song playing to a channel.
  * /gm_next - Skip to the next track.
  * /gm_prev - Skip to the previous track.
  * /gm_pause - Pause/start playback.
  * /gm_browse - Open Gmusic UI window.
  * /gm_volup - Increase volume.
  * /gm_voldown - Decrease volume.
  * /gm_help - Display this help screen.

there you have it

  • /gm_start Starts gmusicbrowser if it's not present on dbus. It will not start a second instance. It pauses 4 seconds to allow the application to start.
  • /gm_play does what it says on the tin. Displays the currently playing song information as set in previous paragraph.
  • /gm_next skips the current song
  • /gm_prev plays the previous song
  • /gm_pause will pause a playing song, or restart a paused song.
  • /gm_browse opens the gmusic browser window
  • /gm_volup increase the volume (if your at the maximum level it won't)
  • /gm_voldown decrease the volume (…)

Todo list

any suggestions

third_party_apps/xchat.1240739362.txt.gz · Last modified: 2022/05/23 01:30 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0