eonpatapon / gnome-shell-extension-caffeine

Disable screensaver and auto suspend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request: Restore DPMS settings when toggling caffeine off

greatquux opened this issue · comments

If I configure DPMS to turn off my monitor displays to save power, for instance with xset dpms 300 600 900 then turning caffeine on will set it back to 0 - which is fine, that's what you want when caffeine is enabled. However turning caffeine off will leave those settings at 0. Perhaps a way to run a custom script when toggling caffeine would be a nice way to add this?

Since Caffeine doesn't directly modify DPMS values, I feel like this should be reported elsewhere as well.

As for the scripts, this seems like a bit of a hacky fix that doesn't belong here. I don't feel like that should be implemented, but that depends on what the other maintainers think too.

The script thing was just something I threw out there, figured maybe it could be generalized for other things people might need to run when enabling/disabling. I created a short movie clip that shows (via xset q|grep display) that the DPMS settings go to 0 when I click Caffeine on. Could GNOME be doing this when it gets the inhibit signal from Caffeine? I wonder how to get it to restore them then...
https://github.com/eonpatapon/gnome-shell-extension-caffeine/assets/1655942/17d1f9dd-7a04-4a1a-832f-75cea9ccf1bb

I'm not super familiar with how GNOME, DBus and systemd handle inhibitors, but I'd assume at some point in that stack it changes the DPMS values when an inhibitor is added.

I went down a rabbit hole trying to figure it out, but eventually I just decided it was simpler to use the instructions in caffeine's README for checking whether it's enabled or not, and running a script every minute to set the DPMS values if caffeine is disabled. So now when I turn on caffeine, DPMS is set to all 0's (disabled), and when I disable it, within a minute they'll get set back. So I can save some power by turning off my monitors and help save the planet. :)

STATE=`gsettings --schemadir ~/.local/share/gnome-shell/extensions/caffeine@patapon.info/schemas/ get org.gnome.shell.extensions.caffeine toggle-state`
if [ "$STATE" == "false" ]; then
        xset dpms 300 600 900 
fi