Feb 21, 2011

Ratpoison doesn't always handle windows/frames/applications the way I want it to. One example is mplayer playing files with a lower resolution than the actual screen which results in transparent borders around the player. To fix this i wrote a quick and dirty script in zsh that uses ratpoisons built in tmpwm-command to launch mplayer in another window manager.

The script is written with my folder hierarchy in mind so you might want to change the affected lines or you could add something like:

# Choose folder that contains videofolders

echo-e "vidfolder:\\n"

PS3='viddir: '

read VIDDIR

echo

And then replace the "~/media/video/" with $VIDDIR

The following script is nowhere near perfect so feel free to post improvments

#!/bin/zsh

## details: play mplayer videos in tmpwm

## depend: ratpoison + ls + mplayer

# Choose temporary WM. Must be a valid and installed WM

clear

echo-e "Enter tmpwm of choice:\\n"

PS3='wm: '

read WM

echo

# Select video folder from a list

echo-e"FOLDERS:\\n"

PS3='Select a folder: '

OLD_IFS=${IFS}; IFS="

";selectFOLDERin`ls ~/media/video`

do

OLD_IFS=${IFS}; IFS="

";cd~/media/video/$FOLDER

# Break, otherwise endless loop

break

done;IFS=${OLD_IFS}

echo

# Select a file in $FOLDER to play

echo-e"FILES:\\n"

PS3='Select a file: '

# Opens the selected file in Mplayer under $WM and kills the temporary wm when mplayer exits

As this is a shell script it can be written on a single line or in multiple lines as above. If you decide to write it in multiple lines don't forget to separate them with backslashes so that the script is read by the shell as a single line. No backslash on the last line.

The first line is, of course, the shebang. The next line runs ratmenu with the fixed-medium-semicondensed font. I have the menu set up with gray text on a black background.

Lines 3 -9:

> Opens my ratpoison configuration file in vim for quick editing.

> Launches ncmpcpp (music player) in a terminal

> Launches mutt (mail client) in a terminal

> Uses zenity to display a colorpicker. I use this when editing my .Xdefaults and such.

> Pipes top (system information summary) to the ratpoison message area

> Pipes battery information to the ratpoison message area

> Prints the message buffer of the kernel in the ratpoison message area