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 "http://www.google.fr/search?q=lyrics+%22'+urllib.quote(track)+'%22" &')

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

Top

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:

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

Top

Thunar

See the ThunarProjectWiki/Documentation/Tips&Tricks page.

Top

Make a Debian package

Reminders:

  • 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

Top

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" ]
  then
    precmd() {
      #ie: /home/user/devel
      print -Pn "\e]0;%/\a"
    }
    preexec () {
      #ie: less .zshrc /home/user
      print -Pn "\e]0;$1 %/\a"
    }
fi

Top

Earlier posts