Ale*_*nov 6 linux suspend linux-kernel
当Xviewer或者VLC是在Linux Mint的全屏模式,我的笔记本电脑没有进入睡眠状态。其他一些应用程序(例如mpv全屏模式)不会阻止睡眠。
XviewerGUI 中没有关于保持唤醒状态的选项。
如何Xviewer预防和如何关闭?
如何为我认为这种行为有益的应用程序开启睡眠预防Transmission,例如?
Yur*_*ruk 12
Linux 应用程序通过D-Bus调用禁止挂起org.gnome.SessionManager.Inhibit
请注意,抑制与阻止不同。禁止屏幕保护程序、屏幕锁定或挂起只会在计算机空闲时阻止操作发生,而不会在用户或其他程序手动激活时发生。
传输有一个用于禁止睡眠的复选框:Preferences-> Desktoptab -> Inhibit hibernation when torrents are active。
我下载了传输的源代码,看到它调用了一个 D-Bus 方法 ( org.gnome.SessionManager.Inhibit) 到 Cinnamon D-Bus 会话。
我使用dbus-monitor来发现 Firefox 在播放视频时会做什么。当视频开始播放时,Firefox 会发送两个调用:
$ 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
. . .
Run Code Online (Sandbox Code Playgroud)
调用最后一个方法后,创建了以下抑制剂:
$ 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"
]
Run Code Online (Sandbox Code Playgroud)
视频停止后,将移除抑制剂:
$ 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 [
]
Run Code Online (Sandbox Code Playgroud)
VLC 以与 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"
]
Run Code Online (Sandbox Code Playgroud)
当您播放幻灯片时,Xviewer 会调用类似于上述程序的 D-Bus 方法。
有两种流行的小程序可用于抑制睡眠/暂停:Caffeine和Inhibit Applet(内置Cinnamon 小程序:右键单击底部面板 -> Add Applets to Panel-> Inhibit Applet。但这些小程序手动打开和关闭抑制暂停功能,而不是自动打开它在某些应用程序运行时打开和关闭。