[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to Run a Command on Screensaver Activation, Only After User Interaction that Session?





On Thu, May 4, 2017 at 2:27 AM, Felix Dietrich <felix.dietrich@sperrhaken.name> wrote:
Kent West <westk@acu.edu> writes:

> On Thu, Apr 27, 2017 at 9:27 PM, Felix Dietrich
> <felix.dietrich@sperrhaken.name> wrote:
>
>     Kent West <westk@acu.edu> writes:
>
> What I needed (and have since solved - below) was help working out the
> syntax of determining human interaction with X.
>
>     You may also want to consider that a user probably should not be
>     able to
>     edit the initialisation script (xinitrc)
>
> In my current setup, the current user can do either of these things,
> but not permanently; his changes are lost upon a restart of X, so the
> changing of .xinitrc is a non-issue.

If the user chooses to overwrite the .xinitrc file the rsync command you
use to reset the home directory at the beginning of that script (as part
of wipe_profile.sh) will not be run.  Maybe you should reset the home
directory at the end of the session (and also as part of the
initialisation during boot in case of a sudden power loss).
wipe_profile.sh also appears to be writeable by the user?

Yeah, I realized this a day or two later, and am updating my process/documentation now; I'm instead running the rsync process as part of my autologin/getty systemd unit as an ExecStartPre just before launching agetty.

That's a good catch about the "wipe_profile.sh" being writable by the user; I'll change that. Thanks for pointing that out.


> The problem is that xinput reports several EVENTs on startup of the
> utility, so I had to figure out a way to do finer-grained testing. My
> solution is below.
>
> xinput test-xi2 --root | egrep -q "EVENT type 2|EVENT type 6"

Event 2 is the KeyPress event, Event 6 is the MotionNotify event.  Maybe
you should check for the ButtonPress event 4 as well to handle mouse
clicks?  I found the events listed in "/usr/include/X11/X.h", which you
can find as part of the x11proto-core-dev package.

I thought about that at the time, but figure any button press would also entail a slight bit of mouse movement in 99.99% of the cases, but since you've done the work for me in finding the event number (thanks! ;-) ), I've now added it. Good idea!
 

I like the usage of grep's "-q" switch; I had forgotten about it.

--
Felix Dietrich




--
Kent West                    <")))><
Westing Peacefully - http://kentwest.blogspot.com

Reply to: