Is there a way to suspend auto sleep activation?

I want to have sleep active on my system like if I got busy and not computer is really idle I want it active, but I also want to set exceptions for it like when doing a download or upgrade or something when computer is doing its thing when I am not there, I want to automate it so I don’t have to go to menu and change the settings everytime. I like to use something like sxhkd to activate it with a hot key. How can I do such a thing, with out need to reboot and anything like that?

I use caffeine extension in gnome. When I work I click on the coffee icon to avoid suspend. Which DE are you using?

https://extensions.gnome.org/extension/517/caffeine/

Depending on what you want to do, you could define udev rules to run scripts based on certain conditions.

If you want to suspend the system 60 seconds after the rule is triggered, you could simply write the script as something like:

sleep 60
systemctl suspend

You can read more about udev here
https://wiki.archlinux.org/title/udev

1 Like

I am on Xfce unfortunatly.

Interesting, So I can make a trigger for when no input from mouse or keyboard received for x seconds, like how power manager does, which is a bit complicated but practical. Still lets say I have a script like that , how I can a toggle daemon like that with a script?

udev’s daemon should already be running when you boot into your system. You can check now if you want. Fire up htop and search for udevd. It is that daemon that detects events.

I thought XFCE has this feature built into its power manager already? Regardless, if that’s what you want, I don’t think udev rules are the best way to go about it. udev rules are used to perform an action when an event is detected.

To toggle a daemon (presumably with a set of keybindings), you need to first write the script and then execute it either by setting a keybinding for it—or by making a cron job if you want the script to be executed periodically.

There are many ways to daemonize a script, so you’ll have to look it up and pick the right method for what you want to implement.

1 Like

Yeah. If you in the XFCE Power Manager select General → System tray icon you can by rclicking said icon enable Presentation mode, i.e., disable the system going to sleep.

If OP insists on binding it to a key: you’d in Keyboard → Application Shortcuts add one for

xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -T
2 Likes

Now this is a much better solution, with this there is no need for a hotkey.

IIRC xdg-screensaver can do this thing. You may need to create a script that reads a parameter (for the program you need to let work).
Package is xdg-utils. Read man page for usage.

1 Like

Thanks

1 Like

Is there a way to have this icon at start up. Everytime I reboot it disappears form tray. Also is there anywhere to look for more info or a man page for this command? I want to make sure it is on or off instead of just toggling it. If I can get the state info I can pip it into a notification and would work for me

I believe you may in fact rather than my above mentioned route want to disable the system tray icon from Power Manager again and add “Power Manager Plugin” from <rclick panel> → Panel → “Add New Items…”. Same functionality.

And that said: the by Power Manager set systray icon also certainly does not disappear from my tray on reboot so if the “more different plugin one” also does for you you may have something generic to fix.

1 Like

Sorry , after your explanation I tried again and realized that that was a duplicated power manager icon which disappeared on startup, the original one also has this presentation mode icon in it. I still like to know how to get the status of presentation mode tho. Just in case

If you mean as per script or alike, and also referring to my original reply:

rene@hp8k:~$ xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode
false
rene@hp8k:~$ xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -T
rene@hp8k:~$ xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode
true
rene@hp8k:~$ xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -T
rene@hp8k:~$ xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode
false

Note; you need to have set it once per power manager (plugin) to have that key exist.

Thanks that should work, altho I noticed the icon it shows in the tray so there is no need for that anymore. Is there a way to access xfce window manger command via something like that?

I use caffeine in XFCE. Works perfectly for me.
Install caffeine-ng from the AUR.

1 Like

Thanks , that feature that says it automatically detects full-screen video and disables looks really interesting.