Re: [off-topic] How to auto-run xlock?
>
>
> I have a program that I want to run only while my PC is unattended. I
> don't need the screen locked necessarily.
>
> xlock does this for me:
>
> xlock +nolock -startCmd startsetiathome -mode blank
>
> but I have to run it manually. When I log back in, it does kill the
> running command (startsetiathome) just like I want.
>
> I'd like this exact behaviour but somehow I need xlock to always be
> running, waiting to jump in after the idle period.
I thought about this problem before, and now realised you can check
keyboard and mouse activity looking at /proc/interrupts. You could then
start a script like this in your .xsession file (adapt the variables at
the start to your needs):
runsaver:
------------------------------------------------------------------------
#! /bin/sh
# these are the interrupts of your keyboard and mouse,
# check out your /proc/interrupts:
INTERRUPTS="1 4"
# this is the interval in seconds between checks of /proc/interrupts
SLEEPTIME=30
# if more than MAXINTERVALS * SLEEPTIME seconds pass without activity,
# the xlock program will run
MAXINTERVALS=10
# command line options for xlock
XLOCKFLAGS="-nolock -mode bat"
checkactive () {
TOTALS=""
INTERVALS=0
while true; do
OLDTOTALS=$TOTALS
TOTALS=""
for x in $INTERRUPTS; do
TOTALS="$TOTALS `grep "\<$x:" /proc/interrupts | \
sed -e 's/^.*: *\([0-9]*\).*/\1/'`"
done
if [ "$TOTALS" = "$OLDTOTALS" ]; then
INTERVALS=`expr $INTERVALS + 1`
if [ $INTERVALS -ge $MAXINTERVALS ]; then
break
fi
else
INTERVALS=0
fi
sleep $SLEEPTIME
done
}
while true; do
checkactive
xlock $XLOCKFLAGS
done
------------------------------------------------------------------------
Note I have only just barely tested this.
> If anyone is interested, the program that I'm running is the SETI at Home
> client. SETI is "The Search for Extraterrestrial Intelligence".
Great, sent my regards to the aliens once you find them :)
HTH,
Eric
--
E.L. Meijer (tgakem@chem.tue.nl)
Eindhoven Univ. of Technology
Lab. for Catalysis and Inorg. Chem. (SKA)
Reply to: