I used to forgot to log off from Kopete when going home after work. So I wrote this script to automatically disconnect Kopete, if hour is eveningish and screensaver is running. It uses DCOP to check for screensaver and to talk to Kopete.
Put this script to crontab and configure username and evening hours.
I used to forgot to log off from Kopete when going home after work. So I wrote this script to automatically disconnect Kopete, if hour is eveningish and screensaver is running. It uses DCOP to check for screensaver and to talk to Kopete.
Put this script to crontab and configure username and evening hours.
#!/bin/sh # This script will wait until screen is blanked and then log off from Kopete # If it still runs after MORNING_START or before EVENING_START then it exits # Author: Laas Toom # The user, whose dcop we will connect to DCOP_USER="some-user" # Where dcop is DCOP="/opt/kde3/bin/dcop" kopete_disconnect(){ $DCOP --all-sessions --user $DCOP_USER kopete KopeteIface disconnectAll } # If -f flag is used, then log out forcibly, regardless of screensaver state getopts f flag if [ "$flag" == "f" ] then kopete_disconnect fi IS_BLANKED="$DCOP --all-sessions --user $DCOP_USER kdesktop KScreensaverIface isBlanked" HOUR=`date +%k` # The time when morning starts MORNING_START=7 # the time when evening starts EVENING_START=18 # How long to sleep between screensaver polls SLEEP_TIME="5m" # while no screensaver, sleep while [ "`$IS_BLANKED`" == "false" ] do # If in the middle of day, exit if [ $HOUR -lt $EVENING_START -a $HOUR -ge $MORNING_START ] then exit fi sleep $SLEEP_TIME done # If while ended, then screensaver is enabled, so logout kopete_disconnect