Kent West <westk@acu.edu> writes:
> On Wed, Apr 26, 2017 at 4:52 PM, Kent West <westk@acu.edu> wrote:
> I've got 90% of it done, but I need it to logout after a certain
> time of inactivity, but only after the computer has been used at
> least once since the last start of X (otherwise it'll just be in a
> slow loop of restarting X).
>
> - boot into X
> - sit idly for 20 minutes, 2 hours, 3 days, whatever, screensaver
> running, until a guest comes up and uses the kiosk
Do you mean the display manager is running waiting for a user to log in,
possibly allowing a passwordless guest login?
Upon login the display
manager executes an initialisation script, possibly .xinitrc. In this
script you can set up the kiosk session:
- start the program/script that will forcibly log the user out once
a certain time has passed.
- start a program/script to monitor the xscreensavers state
- start some basic programs (window manager, panels) so that a user
can actually do something
- whatever else you can think of
You may also want to consider that a user probably should not be able to
edit the initialisation script (xinitrc) or kill the program/script that
will exit the session automatically after a certain time has passed.
When using a display manager the FRESH_X variable might not be
necessary.
> In my .xinitrc, I have
>
> export FRESH_X=TRUE
>
> Then I want to have a script that sits and waits for a keypress or a
> mouse activity; this is where I need the syntax help.
When you refer to "script" do you mean a separate script file that you
call or simply more commands following the shells "export" command?
> When that script sees keyboard or mouse activity, it will export
> FRESH_X=FALSE
In case you are talking of a script file you run (instead of source [1])
be aware that the value of environment variables is not shared among
processes: a parent process can pass environment variables to a child
process on execution, but once the child exists both parent and child
have their own copy of the environment.
> But I need help with the syntax of checking for a keypress or mouse
> activity. I've looked at xinput and xev and another tool something
> like xenv, but I can't figure out the syntax in a bash if/then
> statement.
The following snipped can be used to block further script execution
until xinput reports an event. It reads lines from xinput until it
encounters a line starting with "EVENT" using, instead of the "if"
statement, the "case" statement [2] , which supports a simple form of
pattern matching.
xinput --test-xi2 --root | while read line
do
case $line in
EVENT*)
break
;;
esac
done
> I'll configure the xscreensaver-command --watch to watch for the
> screen saver to go BLANK, and when it does I check the status of
> FRESH_X ; if FRESH_X is FALSE, and the screensaver activates, I can
> set a 10-second time, check again to make sure the screensaver is
> still active, and then run my logout.
Searching the web, I found the xautolock [3] program. You may be able
to use its "-killer", "-killtime", "-locker", "-time" parameters to
realise your kiosk idea and save you some scripting.
Happy hacking. :)