小编use*_*.dz的帖子

脚本在被 acpi 和 udev 事件调用时行为不正常

我在/etc/acpi/events和 中有以下文件/etc/udev/rules.d

  • /etc/acpi/events/lidclose

    # Pass all events to our one handler script
    event=button/lid
    action=/etc/acpi/monitors.sh
    
    Run Code Online (Sandbox Code Playgroud)
  • /etc/udev/rules.d/80-monitor.rules

    # change monitor settings when monitor is plugged in or o$
    ACTION=="change", SUBSYSTEM=="drm", HOTPLUG=="1", RUN+="/etc/acpi/monitors.sh"
    
    Run Code Online (Sandbox Code Playgroud)
  • 现在,(可执行并由 root 拥有) /etc/acpi/monitors.sh

    #!/bin/sh
    
    # default monitor is LVDS1
    STATE=internal
    INTERNAL=LVDS1
    EXTERNAL=HDMI3
    
    # functions to switch from LVDS1 to VGA and vice versa
    function internal {
        echo "Switching to internal"
        xrandr --output $EXTERNAL --off --output $INTERNAL --auto
        STATE=internal
    }
    function external {
        echo "Switching to …
    Run Code Online (Sandbox Code Playgroud)

udev xrandr acpi

4
推荐指数
1
解决办法
2889
查看次数

标签 统计

acpi ×1

udev ×1

xrandr ×1