Saturday, 20 October 2012

Conky Exaile updated

Seems like dbus' reputation for being a bit 'changeable' is well deserved (or my code worked because of a bug). In any case, since a recent dbus update my conky exaile script had a problem - it would always start exaile if it wasnt running.

Fear not....


 #!/usr/bin/env python  
 import sys  
 import dbus  
 reload(sys)  
 sys.setdefaultencoding('utf8')  
 bus = dbus.SessionBus()  
 if bus.name_has_owner('org.exaile.Exaile'):  
  remote_object = bus.get_object("org.exaile.Exaile","/org/exaile/Exaile")  
 else:  
  print("Exaile not running")  
  sys.exit()  
 iface = dbus.Interface(remote_object, "org.exaile.Exaile")  
 status = iface.Query()  
 #print "Status: "+status  
 if status == "Not playing.":  
  print("Exaile not playing")  
  sys.exit()  
 elif "paused" in status:  
  print("Exaile is paused")  
  sys.exit()  
 title = iface.GetTrackAttr("title")  
 album = iface.GetTrackAttr("album")  
 artist = iface.GetTrackAttr("artist")  
 if iface.IsPlaying():  
  print("%s - %s (%s)"%(title, artist, album))  
 else:  
  print "Exaile is not playing"  

Friday, 6 July 2012

First bite of the Pi

Started playing around with the raspi properly today. Already booted up XBMC when I first got it, just to make sure everything worked. Very cool but a bit unoriginal and boring.

First thing I did was whack a decent distro on there. Sorry Debian lovers - I'm a fedora man. Tried the official raspi 'fedora remix' but it was a bit old - based on F14 so nowhere near bleeding edge. Found a Fedora 17 based raspi build here. Much better.

First thing to do was Quake III - what else?! Not much to say really, everyone's seen the youtube clips. It runs OK. Crazy to think my desktop struggled with this when it first came out.

I have a plan (finally) for my raspi.... more soon :)

Thursday, 5 July 2012

Conky Exaile

Just a quick one but I'm a big fan of conky and exaile. Disappointingly it seems Exaile changed its DBUS API so my 'now playing' script (shamefully pulled from google) no longer worked.

I've been dabbling with python a bit so had a go at writing my own replacement script. Its the first time I've really used DBUS - quite impressed so far, especially after finding dbus-cli

Anyway - here's the code. Quick, dirty and just what I needed:


 #!/usr/bin/env python  
   
 import sys  
 import dbus  
 reload(sys)  
   
 sys.setdefaultencoding('utf8')  
   
 bus = dbus.SessionBus()  
 try:  
  remote_object = bus.get_object("org.exaile.Exaile","/org/exaile/Exaile")  
 except dbus.exceptions.DBusException:  
  print("Exaile not running")  
  sys.exit()  
   
 iface = dbus.Interface(remote_object, "org.exaile.Exaile")  
 status = iface.Query()  
 #print "Status: "+status  
   
   
   
 if status == "Not playing.":  
  print("Exaile not playing")  
  sys.exit()  
 elif "paused" in status:  
  print("Exaile is paused")  
  sys.exit()  
   
 title = iface.GetTrackAttr("title")  
 album = iface.GetTrackAttr("album")  
 artist = iface.GetTrackAttr("artist")  
   
 if iface.IsPlaying():  
  print("%s - %s (%s)"%(title, artist, album))  
 else:  
  print "Exaile is not playing"  
   

Friday, 29 June 2012

Raspberry Pi

Just a quick one but I was lucky enough to get my Raspberry Pi delivered last week. Havent really done much with it yet but found a use for an old business card case:



Thursday, 24 May 2012

Latest Arcade pics

Almost forgot to upload this but heres the current state of the cab. I havent really done much over the last few months and still have to do a new marquee and tidy up the speakers. Aside from that its pretty much done :)


Wednesday, 25 April 2012

Xbox DVD Dongle and lirc

I've started building the new man room in the house complete with a projector. Before its all finished I've decided to tackle the software side of things. The PJ will be hooked up to my Linux desktop via HDMI

First problem: I dont want to use a keyboard/mouse to watch videos. I want a remote.

I did have a working homebrew serial IR receiver but it looks like its died at some point. The next best thing I have laying around is an old Xbox 1 DVD dongle (and remote). Easy you would think... nope.

Firstly I had to be able to physically connect the dongle to a USB port. The Xbox used the USB protocol but just a non-standard connector (thanks M$). 5 minutes with a soldering iron and that problem was solved:



Now to the software side of things. In lirc the xbox dongle used the atiusb kernel module which, for whatever reason, is no longer maintained and doesnt work with newer kernels. Thankfully someone has split it from the atiusb module and created a working lirc_xbox module - all well and good until I find out that its only available in lirc-0.9.1 and higher. My yum repo is only on lirc-0.9.0 :(

Thanks to someone on the ubuntu forums there are instructions for getting the module compiled separately to the main lirc software and avoiding rpm dependency hell.

For Fedora 16 I did the below and all is good:

git clone git://lirc.git.sourceforge.net/gitroot/lirc/lirc
wget http://old.nabble.com/attachment/31787507/0/lirc_0.9.1_lirc_xbox_driver.patch
cd lirc/
patch -p1 <../lirc_0.9.1_lirc_xbox_driver.patch
vi drivers/lirc_xbox/lirc_xbox.c

remove the line #include <linux/smp_lock.h>
./autogen.sh ./configure -with-driver=userspace cd drivers/lirc_xbox/ make make install
 A quick test with irw and it looks good:

$ irw
00000000000000a6 00 UP XboxDVDDongle
00000000000000a6 01 UP XboxDVDDongle
00000000000000a6 02 UP XboxDVDDongle
00000000000000a7 00 DOWN XboxDVDDongle
00000000000000a7 01 DOWN XboxDVDDongle
00000000000000a9 00 LEFT XboxDVDDongle
00000000000000a9 01 LEFT XboxDVDDongle
00000000000000a9 00 LEFT XboxDVDDongle
00000000000000a9 01 LEFT XboxDVDDongle
00000000000000dd 00 SKIP- XboxDVDDongle
00000000000000a8 00 RIGHT XboxDVDDongle
00000000000000a8 01 RIGHT XboxDVDDongle
00000000000000a8 02 RIGHT XboxDVDDongle
00000000000000ea 00 PLAY XboxDVDDongle
00000000000000ea 01 PLAY XboxDVDDongle
00000000000000ea 02 PLAY XboxDVDDongle

Even works with XBMC out of the box :)

Saturday, 25 February 2012

Conky SABnzbd script

Just a quick script Ive knocked up for conky to show SABnzbd's current status:


 #!/bin/bash  
 prntvalue () {  
      echo $XML | xmlstarlet sel -t -v "$1"  
 }  
 prntnumber () {  
      printf "%.2f\n" $(prntvalue "$1")  
 }  
 XML=$(wget -q -O - "http://YOUR-SAB-HOST:PORT/sabnzbd/api?mode=qstatus&output=xml&apikey=YOUR-API-KEY")  
 state=$(prntvalue "/queue/state")  
 state=`echo $state | tr [A-Z] [a-z]`  
 let nojobs=$(echo $XML | xmlstarlet sel -t -v "count(/queue/jobs/job)")  
 if [[ $nojobs > 0 ]];then  
      timeleft=$(prntvalue "/queue/timeleft")  
      totmbleft=$(prntnumber "/queue/mbleft")  
      totmb=$(prntnumber "/queue/mb")  
      kbpersec=$(prntnumber "/queue/kbpersec")  
      if [ $state == "paused" ]; then  
           echo "SABnzbd+ $state. $nojobs items queued."  
      else       
           echo "SABnzbd+ $state @$kbpersec k/s Downloading $nojobs items ETA:$timeleft"  
      fi  
 else  
      echo -e "SABnzbd+ is $state"  
 fi  
 exit 0 
It outputs something like this:
 SABnzbd+ paused. 14 items queued.  
Also, thanks to http://codeformatter.blogspot.com/ :)