You are not logged in.

#1 2015-10-10 19:05:16

Utini
Member
Registered: 2015-09-28
Posts: 481
Website

XFCE + slock + xfce-power-manager how to lock when screen blanks?

Hey there,

I am using XFCE + slock + xfce-power-manager. So far locking the screen automatically when resuming from suspend mode works fine. But how can I also automatically lock the screen when the screen blanks ?

Thanks !


Setup 1: Thinkpad T14s G3, 14" FHD - R7 6850U - 32GB RAM - 2TB Solidigm P44 Pro NVME
Setup 2: Thinkpad X1E G1, 15.6" FHD - i7-8850H - 32GB RAM - NVIDIA GTX 1050Ti - 2x 1TB Samsung 970 Pro NVME
Accessories: Filco Majestouch TKL MX-Brown Mini Otaku, Benq XL2420T (144Hz), Lo(w)gitech G400, Puretrak Talent, Sennheiser HD800S + Meier Daccord FF + Meier Classic FF

Offline

#2 2015-10-10 20:51:49

dockland
Member
From: Sweden
Registered: 2015-06-06
Posts: 861

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Utini wrote:

Hey there,

I am using XFCE + slock + xfce-power-manager. So far locking the screen automatically when resuming from suspend mode works fine. But how can I also automatically lock the screen when the screen blanks ?

Thanks !

Yes, "settings manager/power manager/Settings" and check box "Lock screen when going to sleep"

I use xscreensaver, there is the same option as well.


I possess a device, in my pocket, that is capable of accessing the entirety of information known to man.
I use it to look at funny pictures of cats and to argue with strangers.

Offline

#3 2015-10-11 02:42:56

toz
Member
Registered: 2011-10-28
Posts: 513

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Utini wrote:

But how can I also automatically lock the screen when the screen blanks ?

According to the slock website, you can use xautolock to lock the screen (using slock) after a period of inactivity. In theory, setting the "time" value to the same value as your screen blank timeout should have it lock when the screen blanks.

Offline

#4 2015-10-11 06:50:58

Utini
Member
Registered: 2015-09-28
Posts: 481
Website

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

toz wrote:
Utini wrote:

But how can I also automatically lock the screen when the screen blanks ?

According to the slock website, you can use xautolock to lock the screen (using slock) after a period of inactivity. In theory, setting the "time" value to the same value as your screen blank timeout should have it lock when the screen blanks.

But will xautolock take into account when I am playing a movie / youtube / similiar ? From what I read it only has a countdown (e.g. 10 minutes of inactivity), the countdown can be broken by certain apps though, but adding e.g. firefox do that list would make xautolock useless.

dockland wrote:
Utini wrote:

Hey there,

I am using XFCE + slock + xfce-power-manager. So far locking the screen automatically when resuming from suspend mode works fine. But how can I also automatically lock the screen when the screen blanks ?

Thanks !

Yes, "settings manager/power manager/Settings" and check box "Lock screen when going to sleep"

I use xscreensaver, there is the same option as well.

"Lock screen when going to sleep" and "Lock screen when it is blanking out" are different things? And the second one is what I want to achieve. My laptop never goes to sleep when I am connected to the charger. But the display blanks after 10 minutes of inactivity, and for security/privacy reasons that should also automatically lock the laptop wink


Setup 1: Thinkpad T14s G3, 14" FHD - R7 6850U - 32GB RAM - 2TB Solidigm P44 Pro NVME
Setup 2: Thinkpad X1E G1, 15.6" FHD - i7-8850H - 32GB RAM - NVIDIA GTX 1050Ti - 2x 1TB Samsung 970 Pro NVME
Accessories: Filco Majestouch TKL MX-Brown Mini Otaku, Benq XL2420T (144Hz), Lo(w)gitech G400, Puretrak Talent, Sennheiser HD800S + Meier Daccord FF + Meier Classic FF

Offline

#5 2015-10-11 13:41:27

toz
Member
Registered: 2011-10-28
Posts: 513

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Utini wrote:
toz wrote:
Utini wrote:

But how can I also automatically lock the screen when the screen blanks ?

According to the slock website, you can use xautolock to lock the screen (using slock) after a period of inactivity. In theory, setting the "time" value to the same value as your screen blank timeout should have it lock when the screen blanks.

But will xautolock take into account when I am playing a movie / youtube / similiar ? From what I read it only has a countdown (e.g. 10 minutes of inactivity), the countdown can be broken by certain apps though, but adding e.g. firefox do that list would make xautolock useless.

Using xautolock addresses your initial request - to automatically lock the screen when the screen blanks. To prevent dpms actions when certain applications (e.g. media players, flash, etc) are playing, is a slightly different issue. xfce4-power-manager has a "Presentation Mode" (right-click the plugin to see option). Unfortunately, this is still broken in version 1.4.4 (the version in the official repos) bur appears to have been fixed in the 1.5x tree (at least it now works for me). You can try it via the AUR.

As does @dockland, I also use xscreensaver and for me it meets both of the requirements you have outlined. I've never used xautolock, so YMMV.

Offline

#6 2015-10-11 14:32:28

Chazza
Wiki Maintainer
Registered: 2013-06-02
Posts: 506

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Presentation mode isn't broken in the current xfpm version. It just doesn't play nicely with XScreenSaver. This being because XScreenSaver overrides the DPMS and screensaver timeouts which are set by xfpm. Presentation mode works just fine without XScreenSaver around as xfpm has sole control of the timeouts.

Regarding xautolock, it doesn't care about screensaver timeouts or DPMS, it will just run the command you gave it at the specified interval. There is a workaround though. If you give it a lock command like this:

if [ $(xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode) = false ]; then gnome-screensaver-command --lock; fi

then you will get the desired behaviour - that there's no blanking or screen locking when presentation mode is enabled. The lock command will still be run at the specified interval, it just won't do anything.

(Of course, you don't have to query the presentation mode setting, you could add some other test instead. This just happens to be the way I use xautolock so that's why I suggested it.)

Last edited by Chazza (2015-10-11 14:48:54)

Offline

#7 2015-10-11 17:22:39

Utini
Member
Registered: 2015-09-28
Posts: 481
Website

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Chazza wrote:

Presentation mode isn't broken in the current xfpm version. It just doesn't play nicely with XScreenSaver. This being because XScreenSaver overrides the DPMS and screensaver timeouts which are set by xfpm. Presentation mode works just fine without XScreenSaver around as xfpm has sole control of the timeouts.

Regarding xautolock, it doesn't care about screensaver timeouts or DPMS, it will just run the command you gave it at the specified interval. There is a workaround though. If you give it a lock command like this:

if [ $(xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode) = false ]; then gnome-screensaver-command --lock; fi

then you will get the desired behaviour - that there's no blanking or screen locking when presentation mode is enabled. The lock command will still be run at the specified interval, it just won't do anything.

(Of course, you don't have to query the presentation mode setting, you could add some other test instead. This just happens to be the way I use xautolock so that's why I suggested it.)

Thanks for that workaround with xautolock. Is presentation-mode enabled automatically when e.g. vlc plays a video or when youtube is running in firefox ? If not, is there also a way to query if the DPMS mode/setting indicate that something is playing and therefor the display should not blank?

Thanks again !

OR:

Maybe there is a way to run a "disable xautolock" command when DPMS is indicating an event of where the screen should not be blanked. And when that even it over (e.g when closing vlc) it will "enable xautolock" again ? That should be more ressources friendly. As my linux/shell scripting is really bad atm, the script could look smth like this:

If dpms = keep-display-active then
     wait 10000 milliseconds
     If dpms = keep-display-active then
         disable xautolock
     endif
else
     if xautolock = disabled then
         enable xautolock
     endif
     wait 10000 milliseconds
endif

Any ideas for that? tongue


Setup 1: Thinkpad T14s G3, 14" FHD - R7 6850U - 32GB RAM - 2TB Solidigm P44 Pro NVME
Setup 2: Thinkpad X1E G1, 15.6" FHD - i7-8850H - 32GB RAM - NVIDIA GTX 1050Ti - 2x 1TB Samsung 970 Pro NVME
Accessories: Filco Majestouch TKL MX-Brown Mini Otaku, Benq XL2420T (144Hz), Lo(w)gitech G400, Puretrak Talent, Sennheiser HD800S + Meier Daccord FF + Meier Classic FF

Offline

#8 2015-10-12 09:16:38

Chazza
Wiki Maintainer
Registered: 2013-06-02
Posts: 506

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Utini wrote:

Thanks for that workaround with xautolock. Is presentation-mode enabled automatically when e.g. vlc plays a video or when youtube is running in firefox ?

Unfortunately, no. It must be activated and deactivated manually. I came up with another workaround which I've detailed at the bottom.

Utini wrote:

If not, is there also a way to query if the DPMS mode/setting indicate that something is playing and therefor the display should not blank?

The Screen Saver timeout and DPMS timeouts are X settings and can be queried with xset -q. But as for not blanking when a video is playing, I don't think there's any simple way to do this because I don't think X cares about what's running. If the idle timeout is reached, then it's reached. The monitor will be blanked or switched off or whatever. You would need some sort of script running in the background simulating user activity when a program that plays video, like vlc or firefox for instance, is running.

Leaving the screensaver and DPMS idle timeouts aside for a second, I did come up with an idea for automatically preventing xautolock from locking the screen if something is playing. My thinking is that if the window that has focus is fullscreen, then something is almost certainly playing. So I came up with this horrible mess which should detect whether the focussed window is fullscreen:

xprop -id $(wmctrl -l | grep "$(xdotool getwindowfocus getwindowname)" | cut -d " " -f1) | grep "_NET_WM_STATE(ATOM) =" | grep "_NET_WM_STATE_FULLSCREEN"

Basically, if the window that has focus is also fullscreen, it will return a string. If not, it should return nothing.

So your xautolock lock command could look like this:

if [ ! "$(xprop -id "$(wmctrl -l | grep "$(xdotool getwindowfocus getwindowname)" | cut -d " " -f1)" | grep "_NET_WM_STATE(ATOM) =" | grep "_NET_WM_STATE_FULLSCREEN")" ]; then gnome-screensaver-command --lock; fi

With this lock command, xautolock should lock the screen when the focussed window is not fullscreen but do nothing when it is. Emphasis on the should by the way, I haven't really tested this much. wmctrl, xdotool and xorg-xprop required.

Utini wrote:

Maybe there is a way to run a "disable xautolock" command when DPMS is indicating an event of where the screen should not be blanked. And when that even it over (e.g when closing vlc) it will "enable xautolock" again ? That should be more ressources friendly.

Well first of all, DPMS does not "indicate an event of where the screen should not be blanked". The Screen Saver timeout and DPMS timeouts are just that, timeouts. The former will blank the screen and the latter will suspend, standby and then switch off the monitor as per the settings. The best you could do here I think is parse the output of xset -q to see when the screen is supposed to be blanked/switched off etc and then have the script act accordingly.

EDIT: Regarding automatically disabling the Screen Saver and DPMS timouts when a video is playing, an idea just occurred to me! You could have a second xautolock process running at a more frequent interval than the one that locks the screen (say 5 minutes instead of 10). This one could have a command which uses the logic I suggested above to detect whether the window that has focus is fullscreen. It could then use xfconf-query to enable/disable the presentation mode which would, as discussed earlier, disable the Screen Saver and DPMS timeouts. The command could be like the following:

if [ "$(xprop -id "$(wmctrl -l | grep "$(xdotool getwindowfocus getwindowname)" | cut -d " " -f1)" | grep "_NET_WM_STATE(ATOM) =" | grep "_NET_WM_STATE_FULLSCREEN")" ]; then xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s true; else xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s false; fi

So this will check if the focussed window is fullscreen. If so, pres mode will be enabled. If not, it will be disabled.

Last edited by Chazza (2015-10-12 11:47:55)

Offline

#9 2015-10-12 12:45:14

Utini
Member
Registered: 2015-09-28
Posts: 481
Website

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Chazza wrote:
Utini wrote:

Thanks for that workaround with xautolock. Is presentation-mode enabled automatically when e.g. vlc plays a video or when youtube is running in firefox ?

Unfortunately, no. It must be activated and deactivated manually. I came up with another workaround which I've detailed at the bottom.

Utini wrote:

If not, is there also a way to query if the DPMS mode/setting indicate that something is playing and therefor the display should not blank?

The Screen Saver timeout and DPMS timeouts are X settings and can be queried with xset -q. But as for not blanking when a video is playing, I don't think there's any simple way to do this because I don't think X cares about what's running. If the idle timeout is reached, then it's reached. The monitor will be blanked or switched off or whatever. You would need some sort of script running in the background simulating user activity when a program that plays video, like vlc or firefox for instance, is running.

Leaving the screensaver and DPMS idle timeouts aside for a second, I did come up with an idea for automatically preventing xautolock from locking the screen if something is playing. My thinking is that if the window that has focus is fullscreen, then something is almost certainly playing. So I came up with this horrible mess which should detect whether the focussed window is fullscreen:

xprop -id $(wmctrl -l | grep "$(xdotool getwindowfocus getwindowname)" | cut -d " " -f1) | grep "_NET_WM_STATE(ATOM) =" | grep "_NET_WM_STATE_FULLSCREEN"

Basically, if the window that has focus is also fullscreen, it will return a string. If not, it should return nothing.

So your xautolock lock command could look like this:

if [ ! "$(xprop -id "$(wmctrl -l | grep "$(xdotool getwindowfocus getwindowname)" | cut -d " " -f1)" | grep "_NET_WM_STATE(ATOM) =" | grep "_NET_WM_STATE_FULLSCREEN")" ]; then gnome-screensaver-command --lock; fi

With this lock command, xautolock should lock the screen when the focussed window is not fullscreen but do nothing when it is. Emphasis on the should by the way, I haven't really tested this much. wmctrl, xdotool and xorg-xprop required.

Utini wrote:

Maybe there is a way to run a "disable xautolock" command when DPMS is indicating an event of where the screen should not be blanked. And when that even it over (e.g when closing vlc) it will "enable xautolock" again ? That should be more ressources friendly.

Well first of all, DPMS does not "indicate an event of where the screen should not be blanked". The Screen Saver timeout and DPMS timeouts are just that, timeouts. The former will blank the screen and the latter will suspend, standby and then switch off the monitor as per the settings. The best you could do here I think is parse the output of xset -q to see when the screen is supposed to be blanked/switched off etc and then have the script act accordingly.

EDIT: Regarding automatically disabling the Screen Saver and DPMS timouts when a video is playing, an idea just occurred to me! You could have a second xautolock process running at a more frequent interval than the one that locks the screen (say 5 minutes instead of 10). This one could have a command which uses the logic I suggested above to detect whether the window that has focus is fullscreen. It could then use xfconf-query to enable/disable the presentation mode which would, as discussed earlier, disable the Screen Saver and DPMS timeouts. The command could be like the following:

if [ "$(xprop -id "$(wmctrl -l | grep "$(xdotool getwindowfocus getwindowname)" | cut -d " " -f1)" | grep "_NET_WM_STATE(ATOM) =" | grep "_NET_WM_STATE_FULLSCREEN")" ]; then xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s true; else xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s false; fi

So this will check if the focussed window is fullscreen. If so, pres mode will be enabled. If not, it will be disabled.

First of all, thank you a lot for your detailed reply and the provided solutions !

I just feel like something is missing there. I mean, it is and should be state-of-the-art that the system detects whether the screen can go into blank / system into standby or not. For example on windows I have never occurred the problem that when playing a video, watching a game as spectator or similiar, that the screen would turn off or the system would go into standby. Is this really not implemented into XFCE / Arch linux ?

Having a solution which decides on fullscreen/focus is glitchy. For example I have firefox very often focused and in fullscreen when leaving the laptop. The key factor there would be youtube running or not.

Thanks again smile


Setup 1: Thinkpad T14s G3, 14" FHD - R7 6850U - 32GB RAM - 2TB Solidigm P44 Pro NVME
Setup 2: Thinkpad X1E G1, 15.6" FHD - i7-8850H - 32GB RAM - NVIDIA GTX 1050Ti - 2x 1TB Samsung 970 Pro NVME
Accessories: Filco Majestouch TKL MX-Brown Mini Otaku, Benq XL2420T (144Hz), Lo(w)gitech G400, Puretrak Talent, Sennheiser HD800S + Meier Daccord FF + Meier Classic FF

Offline

#10 2015-10-12 13:38:57

Chazza
Wiki Maintainer
Registered: 2013-06-02
Posts: 506

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

I'm aware that they're far from perfect solutions. They were just the best I could come up right now.

Utini wrote:

Is this really not implemented into XFCE / Arch linux ?

Well remember that Arch is just a base. I don't think it's going to have some complicated system in place that tries to guess when you want the display blanking/powersaving timeouts to be inhibited and when you don't.

Maybe you could file a bug against Xfce power manager asking them to come up with a solution that intelligently enables/disables presentation mode. Maybe Ubuntu or one of the other distros billed as user friendly has this kind of functionality. If so, you could try and replicate whatever they've done in your Arch environment. You could try and find another program that somebody else has written which accomplishes this. I'm sure there will be some around. Google is your friend here.

Ultimately you might have to try and pull something together yourself. One approach would be to think to yourself, what programs do I use which run video? How can I detect whether these programs are running from the shell? For instance:

wmctrl -l | grep YouTube

is a simple way of detecting the presence of YouTube.

Once you have ways of detecting all your programs, you could put them all into a bash function which returns something like 1 for program detected and 0 if none are detected. You then need to decide what to do with the output. You could have xautolock toggle presentation mode like I mentioned above. Or you could have xdotool simulate some activity like a mouse movement. It's up to you.

Hopefully you find a solution that works for you. Personally, I'm happy just toggling the presentation mode manually (it's just two mouseclicks) and having xautolock querying the setting as a condition of whether to lock when it reaches its idle timeout.

Last edited by Chazza (2015-10-12 13:45:14)

Offline

#11 2015-10-14 13:36:01

Utini
Member
Registered: 2015-09-28
Posts: 481
Website

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Chazza wrote:

I'm aware that they're far from perfect solutions. They were just the best I could come up right now.

Utini wrote:

Is this really not implemented into XFCE / Arch linux ?

Well remember that Arch is just a base. I don't think it's going to have some complicated system in place that tries to guess when you want the display blanking/powersaving timeouts to be inhibited and when you don't.

Maybe you could file a bug against Xfce power manager asking them to come up with a solution that intelligently enables/disables presentation mode. Maybe Ubuntu or one of the other distros billed as user friendly has this kind of functionality. If so, you could try and replicate whatever they've done in your Arch environment. You could try and find another program that somebody else has written which accomplishes this. I'm sure there will be some around. Google is your friend here.

Ultimately you might have to try and pull something together yourself. One approach would be to think to yourself, what programs do I use which run video? How can I detect whether these programs are running from the shell? For instance:

wmctrl -l | grep YouTube

is a simple way of detecting the presence of YouTube.

Once you have ways of detecting all your programs, you could put them all into a bash function which returns something like 1 for program detected and 0 if none are detected. You then need to decide what to do with the output. You could have xautolock toggle presentation mode like I mentioned above. Or you could have xdotool simulate some activity like a mouse movement. It's up to you.

Hopefully you find a solution that works for you. Personally, I'm happy just toggling the presentation mode manually (it's just two mouseclicks) and having xautolock querying the setting as a condition of whether to lock when it reaches its idle timeout.

I have thought about a different approach:

So far it seems like XFCE will recognize wether it can put the laptop into sleep/blank the screen or not. So e.g. if I watch a video in VLC then xfce will not blank the screen.
Is there a way to execute a command when the screen gets blanked? Similiar to running post/pre scripts of sleep/resume ?

That way I could run a command (e.g. run slock) as soon as XFCE blanks the screen.


Setup 1: Thinkpad T14s G3, 14" FHD - R7 6850U - 32GB RAM - 2TB Solidigm P44 Pro NVME
Setup 2: Thinkpad X1E G1, 15.6" FHD - i7-8850H - 32GB RAM - NVIDIA GTX 1050Ti - 2x 1TB Samsung 970 Pro NVME
Accessories: Filco Majestouch TKL MX-Brown Mini Otaku, Benq XL2420T (144Hz), Lo(w)gitech G400, Puretrak Talent, Sennheiser HD800S + Meier Daccord FF + Meier Classic FF

Offline

#12 2015-10-15 08:59:54

Chazza
Wiki Maintainer
Registered: 2013-06-02
Posts: 506

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Utini wrote:

So far it seems like XFCE will recognize wether it can put the laptop into sleep/blank the screen or not. So e.g. if I watch a video in VLC then xfce will not blank the screen.

Oh really? Well I don't think it's Xfce doing that - it certainly blanks the screen for videos in the web browser for me. Perhaps VLC is inhibiting the timeouts itself somehow.

Utinit wrote:

Is there a way to execute a command when the screen gets blanked? Similiar to running post/pre scripts of sleep/resume ?

That way I could run a command (e.g. run slock) as soon as XFCE blanks the screen.

I don't know of any nice way of doing this myself. I guess you could have a script with an infinite loop which gets the Screen Saver timeout from xset -q and then checks that against the current idle time once a second. There's a nice program called xprintidle which can give you the current idle time.

Here's my demo:

while true
do
  TIMEOUT=$(expr "$(xset -q | grep timeout | cut -d ' ' -f5)" \* 1000)
  IDLE=$(xprintidle)
  if [ "$IDLE" -ge "$TIMEOUT" ]; then
    #Do something
  fi
  sleep 1
done

EDIT: Thanks for the explanation Alad.

Last edited by Chazza (2015-10-15 09:46:18)

Offline

#13 2015-10-15 09:41:27

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,421
Website

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Chazza wrote:
Utini wrote:

So far it seems like XFCE will recognize wether it can put the laptop into sleep/blank the screen or not. So e.g. if I watch a video in VLC then xfce will not blank the screen.

Oh really? Well I don't think it's Xfce doing that - it certainly blanks the screen for videos in the web browser for me. Perhaps VLC is inhibiting the timeouts itself somehow.

VLC uses xdg-screensaver for this. There's also xss-inhibit, and players like mpv do it natively.

Utinit wrote:

Is there a way to execute a command when the screen gets blanked? Similiar to running post/pre scripts of sleep/resume ?

That way I could run a command (e.g. run slock) as soon as XFCE blanks the screen.

https://aur.archlinux.org/packages/xss/
https://aur.archlinux.org/packages/xss-lock-git/

Last edited by Alad (2015-10-15 09:44:11)


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#14 2015-10-15 12:26:25

Utini
Member
Registered: 2015-09-28
Posts: 481
Website

Re: XFCE + slock + xfce-power-manager how to lock when screen blanks?

Chazza wrote:
Utini wrote:

So far it seems like XFCE will recognize wether it can put the laptop into sleep/blank the screen or not. So e.g. if I watch a video in VLC then xfce will not blank the screen.

Oh really? Well I don't think it's Xfce doing that - it certainly blanks the screen for videos in the web browser for me. Perhaps VLC is inhibiting the timeouts itself somehow.

Utinit wrote:

Is there a way to execute a command when the screen gets blanked? Similiar to running post/pre scripts of sleep/resume ?

That way I could run a command (e.g. run slock) as soon as XFCE blanks the screen.

I don't know of any nice way of doing this myself. I guess you could have a script with an infinite loop which gets the Screen Saver timeout from xset -q and then checks that against the current idle time once a second. There's a nice program called xprintidle which can give you the current idle time.

Here's my demo:

while true
do
  TIMEOUT=$(expr "$(xset -q | grep timeout | cut -d ' ' -f5)" \* 1000)
  IDLE=$(xprintidle)
  if [ "$IDLE" -ge "$TIMEOUT" ]; then
    #Do something
  fi
  sleep 1
done

EDIT: Thanks for the explanation Alad.

You were right, it must have been xscreensaver doing it... I switched to it from slock.. but still not perfect.

xscreensaver won't blank/lock when VLC is playing.
How ever, XFCE will put the laptop into sleep mode, even if VLC is playing.


Setup 1: Thinkpad T14s G3, 14" FHD - R7 6850U - 32GB RAM - 2TB Solidigm P44 Pro NVME
Setup 2: Thinkpad X1E G1, 15.6" FHD - i7-8850H - 32GB RAM - NVIDIA GTX 1050Ti - 2x 1TB Samsung 970 Pro NVME
Accessories: Filco Majestouch TKL MX-Brown Mini Otaku, Benq XL2420T (144Hz), Lo(w)gitech G400, Puretrak Talent, Sennheiser HD800S + Meier Daccord FF + Meier Classic FF

Offline

Board footer

Powered by FluxBB