Feb 21, 2011

tmpwm

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="
"; select FOLDER in `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
select FILE in `ls ~/media/video/$FOLDER`
do
`ratpoison -c "tmpwm $WM" & mplayer -fs ~/media/video/$FOLDER/$FILE && killall $WM`

# Break, otherwise endless loop
break
done

exit 0

3 comments: