Tips & Tricks

Mike Massonnet | Posted 1 month ago on April 21, 2006

Search lyrics from MPD

I wrote a little script which I run from verve, especially because it does auto-completion, to search lyrics from the current played track by MPD.

I had like to wrote it in Perl but I don't know much this language. So I wrote it in python :) It uses dillo as browser and mpc as front-end to mpd to grab the played track.

import urllib # quote()
import commands, os # getoutput(), system()
track=commands.getoutput('mpc --format "%artist% - %title%" | head -1')
os.system('dillo "'+urllib.quote(track)+'%22" &')

Also I found a nasty shell script to put the current played song in Gajim: GajimAndMpd.


WordReference in a nutshell

Do you know WordReference? It is pretty useful to translate words mutually from french to english.

Indeed it is useful, but opening a web interface all the time started to annoy me that much that I started to write a shell script. Another crappy script with ugly seds, don't blame me :-). Here is the script:

if [[ $# < 2 || "$1" != "enfr" && "$1" != "fren" ]]
    echo "Usage: `basename $0` fren|enfr word"
    exit -1
curl -s "$1/$2" | grep "'ToW'" | \
sed 's/.*<td class='"'ToW'"'>\(.*\)<\/td>.*/\1/g' | html2text



See the ThunarProjectWiki/Documentation/Tips&Tricks page.


Make a Debian package


  • apt-get source <package> to retrieve sources from a Debian package
  • dpkg-source -x *.dsc to extract a package and apply the Debian patches
  • dh_make to create a debian/ directory with all the necessary files
    • Four important files to edit: changelog, control, copyright, rules
  • dpkg-buildpackage -rfakeroot to compile the sources and build the package
  • apt-get build-dep <package> to install the necessary packages to compile the sources


Zsh: Set a title to the terminal

With precmd() to set the title when you are at the prompt and with preexec() when you are in an application.

if [ "$TERM" = "xterm" ]
    precmd() {
      #ie: /home/user/devel
      print -Pn "\e]0;%/\a"
    preexec () {
      #ie: less .zshrc /home/user
      print -Pn "\e]0;$1 %/\a"


Earlier posts