Daemon Diaries

cat /var/blog | grep posts | more

MPD OSD , 2 ways

with one comment

To play my music I use a program called MPD or Music Player Daemon … I put a bunch of keybindings in my Openbox config file to control MPD … but I never knew the name of the song that was playing currently without launching an MPD client ,
so I wrote a script to solve the problem … I mapped this to a key , it looks like this

There are two versions of the script , one in ruby and one in python , choose whichever floats your boat
for the ruby version , you need two gems


sudo gem install librmpd
sudo gem install libxosd-ruby

here’s the code


#!/usr/bin/env ruby
require 'rubygems'                              # Rubygems
require 'librmpd'                               # MPD Library
require 'xosd'                                  # OSD Library

mpd = MPD.new 'localhost', 6600                 # Init MPD
mpd.connect                                     # Connect to MPD Server
song = mpd.current_song                         # Get the current song

osd = XOSD::Xosd.new(5)                         # Init XOSD
osd.font = "-adobe-courier-*-r-*-*-24"          # Choose XOSD Font
osd.color = "#287D28"                           # Choose XOSD color (dark green)

if song.title then                              # Check to see if the song has a title
  osd.display_message(3, song.title)            # If so , display the title
  sleep(2)                                      # Display it for 2 seconds
else
  osd.display_message(3, song.file)             # if there is no title, display the filename
  sleep(2)                                      # Display it for 2 seconds
end

UPDATE: If you are running the latest version of Ubuntu (now Intrepid Ibex) you can skip these steps and just run the following command


sudo apt-get install python-osd python-mpd

If you’re not, follow on –

Then for the python version you need two modules:

http://ichi2.net/pyosd/pyosd-0.2.14.tar.gz
Extract that tarball and run


tar zxvf pyosd-0.2.14.tar.gz
sudo python setup.py install

then go to
http://pypi.python.org/pypi/python-mpd/
and Choose the format you want (zip,bzip,or gzip) , and decompress it
then run

sudo python setup.py install

ok , after all that…here’s the code


#!/usr/bin/env python
import mpd 					                        # Import MPD Library
import pyosd										            # Import OSD Library
import time											            # Import Internal Time Module

client = mpd.MPDClient()							      # Init MPD Client
client.connect("localhost", 6600)					  # Connect to local MPD Server

cs = client.currentsong()                   # Get the currentsong dict
if 'title' in cs:                           # Check to see if "title" title exists in the dict
 	songtitle = cs['title']                   # If it does set songtitle to the id3 title
elif 'file' in cs:                          # If it doesn't have a title use the filename
 	songtitle = cs['file']                    # Set songtitle to the filename

FONT = "-*-helvetica-*-r-normal--34-*-*"    # Set the font

COLOR = "#287D28"									          # Set the color (dark green)
p = pyosd.osd(font=FONT, colour=COLOR)		  # init pyosd with the font and color
p.display(songtitle)								        # Finally use Pyosd to display the song title

time.sleep(2)                               # Show the message for 2 seconsd

If you have any questions regarding this script or any other post of mine , please do not hesitate to contact me at
mike3.1459@mikedonghy.org minus pi

Written by leachim6

June 22, 2008 at 4:30 pm

FreeBSD , Install , Brief How-To

with 2 comments

I recently installed FreeBSD on my laptop … here is how it went:

Read the rest of this entry »

Written by leachim6

June 12, 2008 at 10:32 pm

2 weeks with linux , thoughs…

with 3 comments

I guess I should tell you a bit about myself
My name is Mike , I am a huge geek who loves
things such as , programming , podcasts, and Linux, anyhow … lets jump right in
I recently installed Ubuntu Linux on an old dell laptop I had as a test
I had heard before that Linux extremely well on older hardware , I was shocked
The specs of my laptop are

  • 700 mhz pentium
  • 128 mb of ram
  • 10 gb hard drive
  • cd rom drive (no rw)

now for any other operating system … these specs seem a bit ridiculous…
maybe it could run windows 98 or something….
so after the install… I boot up expecting a
horribly slow system , and what do I find ?

I find a system that is just as fast as m 3 ghz+ windows box…
Linux really is awesome for old systems…

for my window manager , which is basically the desktop environment1
I chose the reasonably lightweight and extremely usable xfce which
should be easier to grasp for windows users than something more Linuxy2 like fluxbox3 for instance
anyhow…if you are a geek like me…you like to see pictures among the boring words…
xfce looks really awesome…kinda like this:


(annotated version here)
Well…that’s about it for now, check out linux using a live cd4 from ubuntu Here

Footnotes

  1. Yes…I know that window managers and desktop environments are not the same…I also know that you linux geeks reading are reaching for your email client of choice (probably mutt) to fire off an email to set me straight … I get it…please do not revoke my nerd license…thank you
  2. I love making up words
  3. Fluxbox is an awesome window manager by the way if you are a hardcore hacker and [A control Freak!] also like having complete control over your desktop [Literally down to the pixel]
  4. A Live CD is a cd that runs an entire operating system completely in ram , without touching your hard drive … good for evaluation purposes

Written by leachim6

November 18, 2007 at 3:01 am