What’s the better cross-DE way to disable the screensaver in Linux? I found something here but it’s only for gnome-screensaver. I’m wondering if there’s any way to simulate a keystroke or some X.Org API to disable screensaver activation.
What’s the better cross-DE way to disable the screensaver in Linux? I found something
Share
I have been looking into this a while ago and finally ended up using
xdg-screensaverwhich I call viasubprocess.This is not ideal but apparently there is no other solution that would not involve messing around with DE-specific stuff like
dbusorgnome-screensaver-command.I don’t really like the call to
xwininfoand wish there was a cleaner way but so far could not find anything better. Another issue with thexwininfoapproach is that it uses the id of the root window instead of the app window. Using the app window id instead of the root window would remove the need for theresume_screensavermethod since it would then resume as soon as the window is destroyed.And if you want to simulate keystrokes here is a naive bash script I have been using for some time. It does require
xdotoolwhich has to be installed separately.UPDATE
After having used the python solution above for over a year, it was found to occasionally create zombie processes and/or too many instances of
xdg-screensaver, so after digging around, I found a simpler alternative which is Gnome-specific, but works for me even in a non-Gnome DE (XFCE) since the core Gnome libraries are required by many GTK-based apps even if you don’t have a Gnome desktop.