Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Custom script on screen blank / unblank
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
shimitar
Apprentice
Apprentice


Joined: 23 Nov 2003
Posts: 274
Location: Italy, Torino

PostPosted: Thu Oct 08, 2015 2:52 pm    Post subject: [SOLVED] Custom script on screen blank / unblank Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7051
Location: almost Mile High in the USA

PostPosted: Thu Oct 08, 2015 5:01 pm    Post subject: Reply with quote

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@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
shimitar
Apprentice
Apprentice


Joined: 23 Nov 2003
Posts: 274
Location: Italy, Torino

PostPosted: Thu Oct 08, 2015 6:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7051
Location: almost Mile High in the USA

PostPosted: Thu Oct 08, 2015 6:42 pm    Post subject: Reply with quote

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@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
shimitar
Apprentice
Apprentice


Joined: 23 Nov 2003
Posts: 274
Location: Italy, Torino

PostPosted: Fri Oct 09, 2015 6:47 am    Post subject: Reply with quote

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
View user's profile Send private message
shimitar
Apprentice
Apprentice


Joined: 23 Nov 2003
Posts: 274
Location: Italy, Torino

PostPosted: Sun Oct 11, 2015 4:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum