我正在尝试使用 Arch 上的 xfce 来检测屏幕保护程序是否被禁止。
当 chrome (chromium) 抑制时,此命令有效:
dbus-send --print-reply=literal --type=method_call --dest=org.freedesktop.PowerManagement \
/org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.HasInhibit
但它不适用于 vlc。当我使用 vlc 播放视频时,屏幕保护程序不会启动。
看起来 powermanager 没有收到有关 vlc-s 抑制的通知,但屏幕保护程序收到了通知,但我没有看到一种方法来查询屏幕保护程序有关抑制的信息。
这是我在 dbus on start/stop vlc 上看到的内容以及 Chrome 中的 YouTube 视频。
dbus-monitor --session interface=org.freedesktop.ScreenSaver
--- VLC START ---
method call time=1662491009.469655
sender=:1.1716 ->
destination=org.freedesktop.ScreenSaver serial=25
path=/ScreenSaver; interface=org.freedesktop.ScreenSaver;
member=Inhibit
string "vlc"
string "Playing some media."
--- VLC STOP ---
method call time=1662491018.895743
sender=:1.1716 ->
destination=org.freedesktop.ScreenSaver serial=26
path=/ScreenSaver;
interface=org.freedesktop.ScreenSaver;
member=UnInhibit
uint32 210
--- chrome START ---
method call time=1662491026.467214
sender=:1.2337 -> destination=org.freedesktop.ScreenSaver serial=5
path=/org/freedesktop/ScreenSaver;
interface=org.freedesktop.ScreenSaver;
member=Inhibit
string "/usr/lib/chromium/chromium"
string "Video Wake Lock"
method call time=1662491026.468662
sender=:1.32 ->
destination=:1.34 serial=996
path=/org/freedesktop/ScreenSaver;
interface=org.freedesktop.ScreenSaver;
member=Inhibit
string "xfce4-power-manager"
string "Inhibit requested"
--- chrome STOP ---
method call time=1662491029.945141
sender=:1.2337 ->
destination=org.freedesktop.ScreenSaver serial=8
path=/org/freedesktop/ScreenSaver;
interface=org.freedesktop.ScreenSaver;
member=UnInhibit
uint32 211
method call time=1662491032.135892
sender=:1.32 ->
destination=:1.34 serial=1000
path=/org/freedesktop/ScreenSaver;
interface=org.freedesktop.ScreenSaver;
member=UnInhibit
uint32 212
--------------------------------------
dbus-monitor --session interface=org.freedesktop.PowerManagement.Inhibit
--- VLC START ---
nothing
--- VLC STOP ---
nothing
--- chrome START ---
method call time=1662491438.346199 sender=:1.2340 ->
destination=org.freedesktop.PowerManagement serial=7
path=/org/freedesktop/PowerManagement/Inhibit;
interface=org.freedesktop.PowerManagement.Inhibit;
member=Inhibit
string "/usr/lib/chromium/chromium"
string "Video Wake Lock"
method call time=1662491438.540545 sender=:1.2341 ->
destination=org.freedesktop.PowerManagement serial=5
path=/org/freedesktop/PowerManagement/Inhibit;
interface=org.freedesktop.PowerManagement.Inhibit;
member=Inhibit
string "/usr/lib/chromium/chromium"
string "Playing audio"
--- chrome STOP ---
method call time=1662491440.828614 sender=:1.2340 ->
destination=org.freedesktop.PowerManagement serial=9
path=/org/freedesktop/PowerManagement/Inhibit;
interface=org.freedesktop.PowerManagement.Inhibit;
member=UnInhibit
uint32 6
method call time=1662491443.011514 sender=:1.2341 ->
destination=org.freedesktop.PowerManagement serial=6
path=/org/freedesktop/PowerManagement/Inhibit;
interface=org.freedesktop.PowerManagement.Inhibit;
member=UnInhibit
uint32 14
这是一些错误还是有办法检测 VLC 的抑制?
答案1
我想你自己已经弄清楚了,但这就是答案
VLC 呼叫(从你的例子):
Inhibit
接口和服务的方法org.freedesktop.ScreenSaver
。
Chrome 通话(从你的例子):
Inhibit
接口和服务的方法org.freedesktop.ScreenSaver
。- 其他东西(xfce相关)也调用
org.freedesktop.ScreenSaver.Inhibit
Inhibit
org.freedesktop.PowerManagement.Inhibit
服务接口的方法org.freedesktop.PowerManagement.Inhibit
。
因此,Chrome 实际上从两个不同的界面(ScreenSaver 和 PowerManagement)获取三个抑制锁,而 VLC 仅从 ScreenSaver 界面获取抑制锁。这两个接口来自两个完全不同的服务。假设服务已正确实现,这些服务将使用完全不同的抑制锁集。
(现已弃用)org.freedesktop.PowerManagement
仅抑制挂起[*](CPU 停止),而 org.freedesktop.ScreenSaver
抑制系统进入空闲状态,这实际上会抑制空闲操作,这通常意味着屏幕保护程序启动(通常锁定和清空屏幕)和挂起(CPU 停止)。
[*]:有一个错误报告对于 xfce-power-manager v. 1.6.1 来说,它的org.freedesktop.PowerManagement.Inhibit
实现不正确,并且它禁止还屏幕保护程序(可能会阻止系统空闲)。由于问题仍然存在,该错误可能仍然存在于最新的 xfce-power-manager (4.19) 中。