xssstate
--------

This is the xssstate utility from suckless.org.

This tool is a simple tool that retrieves the X screensaver state.
The screensaver states include the idle time, the screensaver state,
and the time how long to wait until the screensaver should be active.

The values for the screensaver states in X can be changed using
xset(1).

Turn off the screensaver:

  % xset s 0
  % xset s 0ff

Turn on the screensaver after 60 seconds inactivity:

  % xset s 60

Force the screensaver to be active:

  % xset s blank

For more options, see xset(1).

Why
---

I created this package, because I needed this one utility to control
my screensaver and lock my screen with a simple tool.

The same utility is bundled in the suckless-tools package on
slackbuilds.org. If you need the other utilities in that package,
you can use that. B. Watson did a nice job including these
into one package.

I did not have use for the other utilities in that package, and
have created this package.

Example usage
-------------

In the section below, an xss_idle.sh script is given. This script
is an example on how to use this for a background service that
will control your screensaver. This can be used to invoke xlock(1)
using the following command.

  % xss_idle.sh xlock &

This can be usefull in your $HOME/.xinitrc file.

You can also use slock, or any other utility that can lock the
screen.

Example script: xss_idle.sh
---------------------------

#!/bin/sh
#
# Use xset s $time to control the timeout when this will run.
#

if [ $# -lt 1 ];
then
  printf "usage: %s cmd\n" "$(basename $0)" 2>&1
  exit 1
fi
cmd="$@"

while true
do
  if [ $(xssstate -s) != "disabled" ];
  then
    tosleep=$(($(xssstate -t) / 1000))
    if [ $tosleep -le 0 ];
    then
      $cmd
    else
      sleep $tosleep
    fi
  else
    sleep 10
  fi
done
