09/07/2009

Brute force presentation clock


Prerequisites: KDE 4.2, Superkaramba, Acrobat reader.
The idea is to force the relative placement of the Adobe Reader and a Karamba clock widget. This doesn't work with Plasma widgets and the Okular presentation mode, as both seem to override Kwin placement rules (plasma is desktop-integrated anyway).
Get a suitable Karamba clock or countdown widget from kde-look.org (small and preferably with transparency) and put it onto your dektop.
Back up your present window rules:
$ cp ~/.kde4/share/config/kwinrulesrc ~/.kde4/share/config/kwinrulesrc.backup
Start Personal Settings->Window Behaviour->Window-Specific, define a new rule. In the Window tab, grab the widget properties with "Detect Window Properties" and by clicking on the widget.
In the Preferences tab, set "Keep above" to "Force". Additionally, you can force a fixed position in the Geometry tab (in the image above, it's [1080,80] on a 1280x1024 screen, but remember that a projector will have a different resolution).
Next, we define a rule for acroread. Open a presentation, switch to presentation mode with Ctrl+L. Change with Alt+Tab to the Personal Settings window and define a new rule by grabbing the fullscreen presentation in the background and forcing the placement to "Keep below".
This will place the presentation below all windows including the Plasma panel, so you have to minimise all windows and auto-hide the panel with Configure Panel -> More Settings…->Auto Hide.

If you use Acroread and the Clock widget outside presentation, these rules can be pretty annoying. So we define a shell script presmode (download) to change the config files and reload Kwin. Make it executable, (chmod a+x presmode), usage presmode -p or presmode -n.
You have to resart/reload Superkaramba and Acroread for the new settings to take effect.
#!/bin/bash
killall kwin
sleep 1
while getopts ":pn" opt; do
case $opt in
p) #presentation case
d=`diff ~/.kde4/share/config/kwinrulesrc ~/.kde4/share/config/kwinrulesrc.presentation | wc -m `
if [ "$d" -le "100" ]; then #avoid overwriting normal backup with presentation mode.
echo "already in presentation mode";
else
cp ~/.kde4/share/config/kwinrulesrc ~/.kde4/share/config/kwinrulesrc.backup
cp ~/.kde4/share/config/kwinrulesrc.presentation ~/.kde4/share/config/kwinrulesrc
echo "presentation mode";
fi
;;
n) #normal case
cp ~/.kde4/share/config/kwinrulesrc.backup ~/.kde4/share/config/kwinrulesrc
echo "normal mode"
;;
\?) #all other options
echo "unknown option"
;;
esac
done
sleep 1
kwin --replace --nocrashhandler & > /dev/null

Possible improvements: Merge the backup script with the Acroread embedded movie workaround.

NB: A beamer sample document for the presentation style used above can be found here: .tex, .pdf.

No comments: