Ubuntu 桌面 22.04.3 LTS - Raspberry Pi 4 Model B 2GB - 如何通过脚本打开/关闭显示器?

Ubuntu 桌面 22.04.3 LTS - Raspberry Pi 4 Model B 2GB - 如何通过脚本打开/关闭显示器?

我想使用 cron 或类似程序来打开/关闭运行 MagicMirror2 的 Rpi 所连接的显示器。

user@user-desktop:~/MagicMirror/config$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
user@user-desktop:~/MagicMirror/config$ uname -a
Linux user-desktop 5.15.0-1045-raspi #48-Ubuntu SMP PREEMPT Tue Jan 16 13:24:44 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

我已经尝试过 xrandr:

user@user-desktop:~/MagicMirror/config$ xrandr --listmonitors
Monitors: 1
 0: +*XWAYLAND0 1920/520x1080/290+0+0  XWAYLAND0
user@user-desktop:~/MagicMirror/config$ xrandr --output XWAYLAND0 --off
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  139 (RANDR)
  Minor opcode of failed request:  7 (RRSetScreenSize)
  Serial number of failed request:  20
  Current serial number in output stream:  22
user@user-desktop:~/MagicMirror/config$  

设置:

user@user-desktop:~/MagicMirror/config$ export DISPLAY=:0.0
user@user-desktop:~/MagicMirror/config$ xset -q
<snip>
DPMS (Energy Star):
  Server does not have the DPMS Extension
user@user-desktop:~/MagicMirror/config$ sleep 1 && xset dpms force off
server does not have extension for dpms option
xset:  unknown option force
<snip>

电视服务:

user@user-desktop:~/MagicMirror/config$ sudo tvservice -o
[sudo] password for user:
tvservice is not supported when using the vc4-kms-v3d driver.
Similar features are available with standard linux tools
such as modetest from libdrm-tests.
user@user-desktop:~/MagicMirror/config$ sudo modetest
sudo: modetest: command not found

命令行

user@user-desktop:~/MagicMirror/config$ vcgencmd display_power 0
VCHI initialization failed
user@user-desktop:~/MagicMirror/config$ sudo vcgencmd display_power 0
display_power=1

我应该使用其他东西或安装一些配置/软件才能使上述功能正常工作吗?

编辑。尝试以下建议:

user@user-desktop:~$ WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --off
failed to connect to display

答案1

尝试运行以下命令:

#!/bin/bash
# From https://forums.raspberrypi.com/viewtopic.php?t=360281
WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --off

测试其是否正常工作后,将其保存到文件中,将其标记为可执行文件,然后使用“cron 或类似程序”进行注册。该WAYLAND_DISPLAY="wayland-1"部分允许在图形会话之外启动的进程(如 cron 或 SSH)找到 Wayland。HDMI-A-1是您的主要输出,您可以替换它以指定 Raspberry Pi 上的其他输出。

相关内容