August 17, 2014


Like many other scripts, the bash shell function "up" is a by product of my laziness. As the name vaguely indicates, it can move you up in the directory tree. If you want to move 3 levels up in the directory tree, you invoke the function as up 3 instead of cd ../../../  which saves a ton of typing. The shell function can be downloaded from my GitHub repo. 

# Go n level up in the directory structure.
# License : GPLv3
function up ()
        if [[ ! -z "$1" ]]
                for i in `seq $1`

        # Will land up in / if n is too large.
        cd ${lvls}

The ShellUtils repo contains few other shell scripts that might be interesting. See the Readme file in the repo to find out what those scripts are doing.

August 2, 2014

Dbus-MPRIS Music Player Controller

The Short story :
Here is a shell script that can control media players like Amarok, Clementine, mpd & VLC :

The long story :
Like most of the programmers, I'm a big fan of command line. Since I can touch type, things get done really faster. There will be a music player running in my system and most of the time I will be using mpd with ncmpcpp. Only problem is that I keep forget which key is used to stop/pause ncmpcpp. This problem was quickly resolved by installing mpc and few aliases. Things were pretty fine and I even wrote a script ( to extract the album art of the song being played in mpd and show it on Conky .

Problems cropped up when Amarok or Clementine were used. The controls were on top for Amarok and in case of Clementine it was just opposite. I could use the media keys in the keyboard, but I hardly use them as mpd does not respond to them. The search of consistency ended with MPRIS. Quickly put together a script and any of these media players could be controlled with a single script. Few aliases and I can control the media player without leaving vim :)

For VLC and mpd, MPRIS need to be enabled manually. The VLC player need to be started as vlc --control dbus. In case of mpd, mpDris2 need to be running.