I use the i3 window manager and have
set $Locker i3lock --color=000000 && sleep 1
exec --no-startup-id xautolock -time 5 -locker "$Locker"
in its config file, so that it locks after 5 minutes.
The problem is that the 5 minutes timer counts down even when I'm whatching a video, which I definitely don't like. (Btw, I usually watch movies with mplayer
, but sometimes I go on streaming websites as well, using qutebrowser
.) On the contrary, I'd like to prevent xautolock
s action in such situations.
One possible solution I was thinking of is changing the second line to
exec --no-startup-id myscript -time 5 -locker "$Locker"
where myscript
is a bash/whatever script/program passing all options to xautolock
only if I'm not watching some video stuff. But I don't know what to check with this hypothetical script.
To disable an already running xautolock process, use the -disable option. To re-enable it, use -enable. To toggle it between both states, use -toggle. Using this method is preferable to using sending it SIGSTOP and SIGCONT signals, because while disabled xautolock will still be emptying its event queue.
xss-lock hooks up your favorite locker to the MIT screen saver extension for X and also to systemd's login manager. The locker is executed in response to events from these two sources: X signals when screen saver activation is forced or after a period of user inactivity (as set with xset s TIMEOUT).
One possible way to do this, without needing to implement all of xautolock's options in myscript
would be to write your $Locker
as a script or program to determine if the conditions are met to prevent locking. Otherwise, call the screen locker:
xautolock -locker should_screen_lock.sh
|
Yes <- fullscreen YouTube? -> No
| |
Abort Lock
You can use xprop -root
to learn the ID of the active window in the window manager and xprop -id
against that ID to see if it's running in fullscreen mode.
From there, it's just putting the two together and calling your window locker (i3lock
in this case, but you could also have that as a custom script for a fancier lock screen).
Here's my attempt at doing exactly this. Of note, I don't run xautolock
from i3's config: It's a systemd user service. The locker (lock_screen.sh
), however, is bound to a the keyboard so that I may bypass xautolock in case I have something in full screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With