iye/lightsOn

Enhancement: Use `xdg-screensaver` for broad desktop environment support

Opened this issue · 1 comments

Reason: An xdg-utils package should be present in all Linux/BSD distributions updated in the past decade. This package is a standardized way for apps to have cross-desktop-environment compatibility/integration. In particular, it supports screensaver management via xdg-screensaver. They also encourage bundling whichever xdg tools you use for a stronger compatibility guarantee; the license looks BSD-like.

If I'm right about xdg-screensaver working on all distros that people want to run this on, then you can simultaneously fix issues #6 and #19 (and prevent future issues of that sort until desktop environments stop supporting xdg-utils) by removing lines 55-68 (screensaver detection) and replacing lines 191-212 with delayScreensaver() { xdg-screensaver reset; }

To test if this would work on a given system, run xdg-screensaver status. It should print enabled if you're on a modern-ish system with a screensaver. If you want to test with a video, here's a Bash/Zsh/sh one-liner: while true; do xdg-screensaver reset; sleep 50; done

In theory, media-playing apps like VLC and browsers should be running xdg-screensaver suspend WindowID with the ID of whichever window is playing media. In practice, they're not all doing that properly or lightsOn.sh wouldn't exist. ;-)

.

(Personal xdg-screensaver and lightsOn.sh experience, incidental advert for my code, and long run-on sentence: This is essentially what I do in my own lights-on.sh script that was originally copy-paste-forked from lightsOn.sh, minimized and fixed for just KDE4, split into a pair of scripts for enabling/disabling "keep screen on" mode, deleted out of frustration when updates way later broke it again, and rewritten from scratch just a few hours ago.)

For information: on Linux Mint 19.2 Cinnamon - where I am having a hard time working out how to programmatically inhibit the screensaver - xdg-screensaver status returns disabled.