Skip to content

Instantly share code, notes, and snippets.

@erik
Created October 12, 2011 03:32
Show Gist options
  • Save erik/1280193 to your computer and use it in GitHub Desktop.
Save erik/1280193 to your computer and use it in GitHub Desktop.
import dbus
import commands
import sys
if not 'banshee' in commands.getoutput('ps -A'):
print("nothing, since banshee isn't open\n")
sys.exit()
bus = dbus.SessionBus()
try:
banshee = bus.get_object("org.bansheeproject.Banshee",
"/org/bansheeproject/Banshee/PlayerEngine")
playing = ""
npDict = banshee.GetCurrentTrack()
title = str(npDict['name'])
album = str(npDict['album'])
artist = str(npDict['artist'])
print("%s - %s [%s]\n" % (artist, title, album))
except dbus.exceptions.DBusException:
print("\n")
#!/usr/bin/perl
use vars qw($VERSION %IRSSI);
use Irssi;
use Thread;
use strict;
$VERSION = '1.0';
%IRSSI = (
authors => 'Erik Price',
contact => 'erik',
name => 'np',
description => 'Shows the song playing in mpd in the active window (channel or query).',
license => 'BSD',
);
sub cmd_mprisnp {
my ($data, $server, $witem) = @_;
my $cmd;
my $output;
$cmd = "python dbus-np,py";
if ($witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq "QUERY")) {
$output = `$cmd`;
$witem->command("ACTION ".$witem->{name}." is listening to $output");
} else {
Irssi::print("This is not a channel/query window :b");
}
}
Irssi::command_bind('np', 'cmd_mprisnp');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment