dragonflylee / switchfin

Third-party native Jellyfin client for Nintendo Switch
Apache License 2.0
292 stars 6 forks source link

wayland: 播放视频时阻止锁屏 #70

Closed moetayuko closed 2 months ago

moetayuko commented 2 months ago

Is your feature request related to a problem? Please describe.

目前在 wayland 播放视频似乎不会阻止系统自动锁屏

Describe the solution you'd like

wayland 有 idle-inhibit-unstable-v1 协议用于阻止锁屏,glfw 里也进行了集成 https://github.com/glfw/glfw/blob/b35641f4a3c62aa86a0b3c983d163bc0fe36026d/src/wl_window.c#L481 ,本项目可能没有调用相应的接口

Describe alternatives you've considered

No response

Additional context

No response

xfangfang commented 2 months ago

@moetayuko 可以提供一下应用运行的log、桌面环境和环境变量。同时确保系统相关设置正常(比如同一时间其他应用可以阻止系统锁屏)

switchfin 依赖的跨平台UI库没有使用GLFW自带的功能来实现阻止锁屏,因为开发相关功能时实测 steamdeck 桌面端无法正常触发阻止锁屏。于是参考 VLC 的实现,用dbus来完成的相关功能。

moetayuko commented 2 months ago

@moetayuko 可以提供一下应用运行的log、桌面环境和环境变量。同时确保系统相关设置正常(比如同一时间其他应用可以阻止系统锁屏)

启动 switchfin 的时候能观察到如下 dbus 日志,之后就没有了,包括播放/暂停视频也没有

❯ dbus-monitor | grep ScreenSaver -A5
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.freedesktop.ScreenSaver'"
method return time=1726643916.866943 sender=org.freedesktop.DBus -> destination=:1.1393 serial=4294967295 reply_serial=4294901765
method call time=1726643916.866946 sender=:1.1393 -> destination=org.freedesktop.DBus serial=4294901766 path=/; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.ScreenSaver"
method return time=1726643916.866950 sender=org.freedesktop.DBus -> destination=:1.1393 serial=4294967295 reply_serial=4294901766
   string ":1.17"
method call time=1726643916.866954 sender=:1.1393 -> destination=org.freedesktop.DBus serial=4294901767 path=/; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0namespace='org.mpris.MediaPlayer2.org.player.switchfin'"
method return time=1726643916.866959 sender=org.freedesktop.DBus -> destination=:1.1393 serial=4294967295 reply_serial=4294901767
--
      string "org.freedesktop.ScreenSaver"
      string "org.freedesktop.impl.portal.PermissionStore"
      string "org.freedesktop.impl.portal.desktop.darkman"
      string "org.freedesktop.impl.portal.desktop.gtk"
      string "org.freedesktop.impl.portal.desktop.hyprland"
      string "org.freedesktop.network-manager-applet"
--
   string "org.freedesktop.ScreenSaver"
method return time=1726643916.867494 sender=org.freedesktop.DBus -> destination=:1.1393 serial=4294967295 reply_serial=4294901773
   string ":1.17"
method call time=1726643916.867498 sender=:1.1393 -> destination=org.freedesktop.DBus serial=4294901774 path=/; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.portal.Desktop"
method return time=1726643916.867502 sender=org.freedesktop.DBus -> destination=:1.1393 serial=4294967295 reply_serial=4294901774
--
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.freedesktop.ScreenSaver'"
method return time=1726643916.903897 sender=org.freedesktop.DBus -> destination=:1.1394 serial=4294967295 reply_serial=4294901765
method call time=1726643916.903900 sender=:1.1394 -> destination=org.freedesktop.DBus serial=4294901766 path=/; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.ScreenSaver"
method return time=1726643916.903903 sender=org.freedesktop.DBus -> destination=:1.1394 serial=4294967295 reply_serial=4294901766
   string ":1.17"
method call time=1726643916.903907 sender=:1.1394 -> destination=org.freedesktop.DBus serial=4294901767 path=/; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0namespace='org.mpris.MediaPlayer2.org.player.switchfin'"
method return time=1726643916.903911 sender=org.freedesktop.DBus -> destination=:1.1394 serial=4294967295 reply_serial=4294901767
--
      string "org.freedesktop.ScreenSaver"
      string "org.freedesktop.impl.portal.PermissionStore"
      string "org.freedesktop.impl.portal.desktop.darkman"
      string "org.freedesktop.impl.portal.desktop.gtk"
      string "org.freedesktop.impl.portal.desktop.hyprland"
      string "org.freedesktop.network-manager-applet"
--
   string "org.freedesktop.ScreenSaver"
method return time=1726643916.904728 sender=org.freedesktop.DBus -> destination=:1.1394 serial=4294967295 reply_serial=4294901773
   string ":1.17"
method call time=1726643916.904734 sender=:1.1394 -> destination=org.freedesktop.DBus serial=4294901774 path=/; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.portal.Desktop"
method return time=1726643916.904740 sender=org.freedesktop.DBus -> destination=:1.1394 serial=4294967295 reply_serial=4294901774

注意上述日志中没有 Inhibit 和 UnInhibit 这两个方法的调用。

系统为 Arch,桌面 hyprland,锁屏控制器 hypridle,switchfin 是 flatpak 版。firefox 可以正常阻止锁屏,dbus-monitor 能观察到他调用 Inhibit 和 UnInhibit

xfangfang commented 2 months ago

@moetayuko 可以提供一下应用运行的log和环境变量吗

moetayuko commented 2 months ago

知道了,我的 XDG_CURRENT_DESKTOP=Hyprland,会匹配到 org.freedesktop.PowerManagement 这个接口而不是 org.freedesktop.ScreenSaver https://github.com/xfangfang/borealis/blob/1c85be17b9d0ce907c0d8393dba65b114664829e/library/lib/platforms/desktop/desktop_platform.cpp#L260

播放暂停视频时 dbus-monitor 里也确实会调用 /org/freedesktop/PowerManagement/Inhibit,不过失败了

moetayuko commented 2 months ago

或许可以动态查询各个 dbus 接口是否存在,而不是通过 XDG_CURRENT_DESKTOP 来查表

xfangfang commented 2 months ago

欢迎提供PR,这里是参考代码:https://github.com/videolan/vlc/blob/44486475911067b6ac6c07a5559577c514bd9788/modules/misc/inhibit/dbus.c#L204-L215

moetayuko commented 2 months ago

不知道发生了什么操作,我现在打不开这个程序了,会卡在这个地方然后段错误。。难绷

❯ flatpak run org.player.switchfin                              
20:11:01.785[INFO] XDG_CURRENT_DESKTOP: HYPRLAND
20:11:01.785[INFO] CURRENT_DESKTOP: DEFAULT
20:11:01.787[INFO] init Linux v0.5.2-8653e46 device 816047b5832d72824a6a887d879f6fb6 from /home/xxx/.var/app/org.player.switchfin/config/Switchfin/config.json
20:11:01.788[INFO] Auto set app locale: en-US
dragonflylee commented 2 months ago

@moetayuko 删除配置文件 config.json 试试呢?

moetayuko commented 2 months ago

@moetayuko 删除配置文件 config.json 试试呢?

没用。flathub 里所有依赖卸了重装也没用

moetayuko commented 2 months ago

卡在 glfwInit 不动,不知道是系统滚挂了还是咋回事


EDIT: archcn 裙友的 wiliwili 也起不来了


EDIT2: [2024-09-18T18:49:32+0800] [ALPM] upgraded adwaita-icon-theme-legacy (46.2-1 -> 46.2-2) 这个包导致的,降级就好了

dragonflylee commented 2 months ago

已更新上游的 https://github.com/xfangfang/borealis