Command and Control
Many times, I operate my main PC from a few feet away - sshing into it from my laptop. I do this most often when I want to play movies on the widescreen Dell monitor attached to that box. I ssh in, run export DISPLAY=:0
followed by mplayer foo.avi
and then enjoy foo.avi on the 20” screen while surfing on the laptop in my easy chair. Works great except for one small flaw: if the screensaver has been activated, running mplayer is of no use since I can’t see the video. Until today, I’ve worked around this by getting up, giving the PC’s mouse a small flick thereby deactivating the screensaver and returning to my easy chair to enjoy the video. But as you can imagine, this getting up from the easy chair business can get tiring pretty soon. It got tiring today.
Question is, how do you deactivate the screensaver from the ssh commandline. After much (read: 10 minutes) of effort, I’ve found two ways of doing it. First, the generic way is to run xset s reset
- this should deactivate the screen saver irrespective of your windowing environment of choice - KDE, GNOME, XFCE or whatever.
Since I run KDE, this is another way in which I could do it: dcop kdesktop KScreensaverIface quit
. If you are a KDE user and haven’t used DCOP, I suggest you get familiar with it immediately, there’s a hundred ways in which it’ll help you out! Some samplers:
dcop kdesktop KScreensaverIface lock
- activate screensaver and lock screendcop kdesktop KScreensaverIface enable false
- disable screensaverdcop kopete KopeteIface setAway
- set status away on instant messengerdcop kopete KopeteIface disconnectAll
- disconnect on messengerdcop kmix Mixer0 setMasterVolume 80
- set volume on master channel to 80%dcop kmix Mixer0 toggleMute true
- mute volumedcop amarok player nowPlaying
- Show current track namedcop amarok player setRating 8
- Set the current track’s star ratingdcop amarok player next
- Skip trackalias skip='dcop amarok player next'
- Add it to~/.bash_aliases
As you can see, DCOP is quite powerful. And if you thought typing all those long commands would quickly get tiring - fear not! Bash autocomplete works like a charm with dcop
! Or if you prefer, there’s kdcop
- a GUI to explore and use all available DCOP interfaces.
Combine DCOP with a bit of scripting and you can imagine what all becomes possible. Sample this quick Amarok rating script:
#!/bin/sh
OLDRATING=`dcop amarok player rating`
NOWPLAYING=`dcop amarok player nowPlaying`
dcop amarok player setRating `kdialog --inputbox "Enter a rating for $NOWPLAYING (1-10)" $OLDRATING --title "amaroK rating"`
Bind the script to some global hotkey (which is trivially easy in KDE) and you’ve got a neat little solution to rate songs quickly without having to bring Amarok out of the systray.
To sum up: DCOP rules!