xssstate

a simple utility to get the X screensaver state
git clone git://git.suckless.org/xssstate
Log | Files | Refs | README | LICENSE

xsidle.sh (360B)


      1 #!/bin/sh
      2 #
      3 # Use xset s $time to control the timeout when this will run.
      4 #
      5 
      6 if [ $# -lt 1 ];
      7 then
      8 	printf "usage: %s cmd\n" "$(basename $0)" 2>&1
      9 	exit 1
     10 fi
     11 cmd="$@"
     12 
     13 while true
     14 do
     15 	if [ $(xssstate -s) != "disabled" ];
     16 	then
     17 		tosleep=$(($(xssstate -t) / 1000))
     18 		if [ $tosleep -le 0 ];
     19 		then
     20 			$cmd
     21 		else
     22 			sleep $tosleep
     23 		fi
     24 	else
     25 		sleep 10
     26 	fi
     27 done
     28