#!/bin/sh # This file is maintained at http://git.mdcc.cx/ad1810-tachod . # Copyright: © 2007 Joost van Baal # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License, as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. There is NO warranty. A copy of the GNU GPL is available from # http://www.gnu.org/licenses/. # ad1810-tachod - annoy the user and chase it away from the computer when it # shouldn't be working # Written 2007-11 # # Do not annoy more often than every $sleep period. Choose # e.g. sleep=10m or sleep=30s. See sleep(1). # sleep=10m # # Time to do stuff to leave the system # grace=1s # # Text to display when annoying the user # message="Stop!" # # We'll annoy before hour $morning and after hour $evening. # E.g. when setting # morning=8 # evening=21 # this program will annoy you when you're using your mouse or keyboard # between 0:00 and 8:00, and it will annoy you when you're active between # 21:00 and 23:59. # morning=9 evening=21 # overrule above default settings rcfile=$HOME/.ad1810-tachod.rc test -f $rcfile && . $rcfile interrupts_keyboard=0 interrupts_mouse=0 annoy() { # possible other implementations: # # echo "$message" # # killall ogg123 # # from http://mdcc.cx/draai: # draai quit # draai some/annoying/artist # # xscreensaver-command -lock # # from the x11-apps Debian package: # xeyes # in Debian package x11-utils. FIXME: document fvwm tweaks to grab mouse and focus xmessage -nearmouse -timeout 3600 "$message" } active(){ $active_keyboard || $active_mouse } checkactive() { interrupts_keyboard_old=$interrupts_keyboard interrupts_mouse_old=$interrupts_mouse active_keyboard=false active_mouse=false while read irq interrupts rest do # /proc/interrupts : # 1: 1440117 IO-APIC-edge i8042 (keyboard) # 12: 10506555 IO-APIC-edge i8042 (mouse) # # this is probably i386-centric case "$irq" in "1:") interrupts_keyboard=$interrupts ;; "12:") interrupts_mouse=$interrupts ;; esac done