7

When Xviewer or VLC are in full-screen mode on Linux Mint, my laptop does not go to sleep. Some other apps, e.g. mpv in full screen, do not prevent sleep.

There is no options in Xviewer GUI on keep awake status.

How does Xviewer do prevention and how to turn in off?

How to turn-on sleep prevention for apps where I consider this behavior beneficial, like Transmission for example?

3
  • What is the Desktop Environment? Apr 14, 2018 at 12:16
  • @Yurij Goncharuk, Linux Mint 18.3, Cinnamon Apr 16, 2018 at 3:02
  • I describe my discover in details. Apr 17, 2018 at 15:23

2 Answers 2

13

Linux applications inhibit suspend through a D-Bus call to org.gnome.SessionManager.Inhibit

Contrasting inhibit vs. prevent

Note that inhibit is different than prevent. Inhibiting a screensaver, screen lock, or suspend only prevents the action from occurring when the computer is idle, not when it is manually activated by the user or another program.

How specific applications inhibit suspend

Transmission

Transmission has a checkbox for inhibiting sleep in: Preferences-> Desktop tab -> Inhibit hibernation when torrents are active.

I downloaded the source code of Transmission and saw that it calls a D-Bus method (org.gnome.SessionManager.Inhibit) to the Cinnamon D-Bus session.

Firefox

I used dbus-monitor to discover what Firefox does when a video is playing. When the video starts to play, then Firefox send two calls:

$ dbus-monitor
. . .
# disable screensaver
method call time=1523976795.844938 sender=:1.104 ->
destination=org.freedesktop.ScreenSaver serial=9 path=/ScreenSaver;
interface=org.freedesktop.ScreenSaver; member=Inhibit
  string "firefox"
  string "video-playing"
# disable sleeping
method call time=1523976795.893407 sender=:1.21 -> destination=:1.3
serial=61 path=/org/gnome/SessionManager;
interface=org.gnome.SessionManager; member=Inhibit
  string "firefox"
  uint32 0
  string "video-playing"
  uint32 8
. . .

After calling the last method, the following inhibitor was created:

$ dbus-send --session --type=method_call --print-reply
--dest=org.gnome.SessionManager /org/gnome/SessionManager
org.gnome.SessionManager.GetInhibitors
method return time=1523969881.311742 sender=:1.3 -> destination=:1.188
serial=491 reply_serial=2
  array [
     object path "/org/gnome/SessionManager/Inhibitor6"
  ]

When the video has been stopped, then inhibitor is being removed:

$ dbus-send --session --type=method_call --print-reply
--dest=org.gnome.SessionManager /org/gnome/SessionManager
org.gnome.SessionManager.GetInhibitors
method return time=1523969881.311742 sender=:1.3 -> destination=:1.188
serial=493 reply_serial=2
  array [
  ]

VLC

VLC inhibits sleep/suspend in the same way as Firefox:

$ dbus-monitor
. . .
method call time=1523977809.526716 sender=:1.8017 ->
destination=org.freedesktop.ScreenSaver serial=3 path=/ScreenSaver;
interface=org.freedesktop.ScreenSaver; member=Inhibit
  string "vlc"
  string "Playing some media."
method call time=1523977809.527152 sender=:1.21 -> destination=:1.3
serial=91 path=/org/gnome/SessionManager;
interface=org.gnome.SessionManager; member=Inhibit
  string "vlc"
  uint32 0
  string "Playing some media."
  uint32 8
. . .

$ dbus-send --session --type=method_call --print-reply
--dest=org.gnome.SessionManager /org/gnome/SessionManager
org.gnome.SessionManager.GetInhibitors
method return time=1523977813.424421 sender=:1.3 ->
destination=:1.8018 serial=85789 reply_serial=2
  array [
     object path "/org/gnome/SessionManager/Inhibitor7750"
  ]

Xviewer

When you play a slideshow, Xviewer calls a D-Bus method similar to the above programs.

How to manually inhibit suspend

There are two popular applets exists for inhibiting sleep/suspend: Caffeine and Inhibit Applet (built-in Cinnamon applet: Right Click on Bottom Panel -> Add Applets to Panel -> Inhibit Applet. But these applets manually turn on and off inhibit suspend functionality, rather than automatically turning it on and off when certain applications are running.

4
  • And if there is no gnoem manager, where do I send the dbug msg to? Aug 6, 2018 at 8:49
  • You need to discover the method of your desktop environment which is exists on the Session Bus. There are many tools (cli or gui) can be useful for this: qdbusviewer, dbus-monitor, dbusexplorerer ... This article about linuxjournal.com/article/10455 (Control Your Linux Desktop with D-Bus) can be helpful in your task. Aug 6, 2018 at 13:12
  • This does not prevent sleep.
    – ed22
    Aug 26, 2019 at 6:21
  • 1
    There is also this Python program github.com/gsauthof/utility/blob/… which sends the D-Bus method call org.gnome.SessionManager.Inhibit (successfully tested) and probably man.archlinux.org/man/extra/gnome-session/… (not tested)
    – Seb35
    Nov 21, 2023 at 19:33
2

systemd-inhibit --what=idle mpv will inhibit idle timeout.

You can also inhibit sleep (including via lid switch etc) or shutdown (including via power button). See man systemd-inhibit. This command has been available in systemd since 2012.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .