View previous topic :: View next topic |
Author |
Message |
shimitar Guru
Joined: 23 Nov 2003 Posts: 320 Location: Italy, Torino
|
Posted: Thu Oct 08, 2015 2:52 pm Post subject: [SOLVED] Custom script on screen blank / unblank |
|
|
Hi!
i need to run a custom script each time the screen goes blank/unblank due to power saving and such.
And i need to make it happen system-wide, not just for a single user.
Of course, on Xorg.
This is because i need to lock the touchscreen when this happen and unlock it when the screen is restored.... In short, i need to mimick the Android lock-screen behaviour which locks the touchscreen as well as blanking the screen...
Any suggestion?
I could install xscreensaver if i really need to, but i would prefer a simpler approach, since i don't need to run any screensaver at all. _________________ Willy Gardiol
willy@gardiol.org
Last edited by shimitar on Sun Oct 11, 2015 4:14 pm; edited 1 time in total |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9679 Location: almost Mile High in the USA
|
Posted: Thu Oct 08, 2015 5:01 pm Post subject: |
|
|
You might well use xscreensaver. Else you'll have to hack Xorg itself to add hooks (if you were depending on the "xset s" power saving/screensaver).
If you were running a DE with a power manager, then this is seamless as you can add a hook into dbus to do these things... then again you probably wouldn't be asking this if you were using a DE. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
shimitar Guru
Joined: 23 Nov 2003 Posts: 320 Location: Italy, Torino
|
Posted: Thu Oct 08, 2015 6:11 pm Post subject: |
|
|
Aveva DM but a bit in the custom side.
Odeally i would lime to replace xscreensaver with my own script, there must be a way since xscreensaver does it... _________________ Willy Gardiol
willy@gardiol.org |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9679 Location: almost Mile High in the USA
|
Posted: Thu Oct 08, 2015 6:42 pm Post subject: |
|
|
Yeah basically it disables the built-in xorg screensaver and monitors activity on its own, and then runs xlock once its internal monitor times out... So you'd basically be redoing the same functionality that xscreensaver does (at least the detect/lock).
Even this is not complete, xscreensaver doesn't know how to deal with suspend/hibernate. Additional cases other than just idle timeout.
That's where the full unified DE knows about this situation, and feeds it all to run the lock program when needed. (Also can incorporate dealing with running programs that should automatically disable screensavers/idle timeout, like watching movies... but this functionality can be questionable.) _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
shimitar Guru
Joined: 23 Nov 2003 Posts: 320 Location: Italy, Torino
|
Posted: Fri Oct 09, 2015 6:47 am Post subject: |
|
|
Well, suspend and resume is out of the question since it's not supported on my tablet, but still it seems quite overkill for what i need.
I just need some kind of hooks so that i can run my script.
Supposing i install xscreensaver, do you know how i can hook on it system-wide, not user-specific setting?
... maybe i could replace xlock with my script... i don't need password or other stuff, i just need to lock the touch screen... _________________ Willy Gardiol
willy@gardiol.org |
|
Back to top |
|
|
shimitar Guru
Joined: 23 Nov 2003 Posts: 320 Location: Italy, Torino
|
Posted: Sun Oct 11, 2015 4:13 pm Post subject: |
|
|
Ok, i found a good way.
Installed xscreensaver and then wrote small script:
Code: |
tf700t etc # cat /etc/X11/xinit/xinitrc.d/97-lock-on-blank
#!/bin/bash
killall lock-on-blank.sh
lock-on-blank.sh&
|
And the core of the script is:
Code: |
tf700t etc # cat /usr/local/tf700/bin/lock-on-blank.sh
#!/bin/bash
function check_lock()
{
while read line
do
case "$line" in
UNBLANK*)
echo unlock
;;
BLANK*)
echo lock
;;
*)
;;
esac
done
}
xscreensaver-command -watch | check_lock
|
_________________ Willy Gardiol
willy@gardiol.org |
|
Back to top |
|
|
|