您尚未登录。

#1 2024-05-19 19:29:00

SpreadZhao
会员
注册时间: 2024-05-11
帖子: 2

按照wiki使用acpid进行音量按键控制,只有静音生效,音量的+-控制无效

1. 我的设置

按照 wiki中acpi的音量控制案例进行设置,我的设置如下:

# 以下三个文件均使用root用户创建
# /etc/acpi/events/vol-m
event=button/mute
action=sudo -u spreadzhao XDG_RUNTIME_DIR=/run/user/1000 amixer set Master toggle

# /etc/acpi/events/vol-u
event=button/volumeup
action=sudo -u spreadzhao XDG_RUNTIME_DIR=/run/user/1000 amixer set Master 5%+

# /etc/acpi/events/vol-d
event=button/volumedown
action=sudo -u spreadzhao XDG_RUNTIME_DIR=/run/user/1000 amixer set Master 5%-

同时,也已经取消了xmodmap中这三个按键的绑定。

2. 表现

使用

sudo systemctl restart acpid.service

重启服务之后进行测试,发现只有静音/取消静音的按键正常工作,控制音量的按键无效。

3. 尝试分析

输出日志,发现:

May 19 18:56:00 spread-tb-arch root[2350]: ACPI group/action undefined: button/volumedown / VOLDN
May 19 18:56:00 spread-tb-arch root[2352]: ACPI group/action undefined: button/volumeup / VOLUP
May 19 18:56:00 spread-tb-arch root[2354]: ACPI group/action undefined: button/volumedown / VOLDN
May 19 18:56:00 spread-tb-arch root[2356]: ACPI group/action undefined: button/volumeup / VOLUP
May 19 18:56:00 spread-tb-arch root[2358]: ACPI group/action undefined: button/volumedown / VOLDN
May 19 18:56:00 spread-tb-arch root[2360]: ACPI group/action undefined: button/volumeup / VOLUP
May 19 18:56:01 spread-tb-arch root[2362]: ACPI group/action undefined: button/volumedown / VOLDN
May 19 18:56:01 spread-tb-arch root[2364]: ACPI group/action undefined: button/volumeup / VOLUP
May 19 18:56:01 spread-tb-arch root[2366]: ACPI group/action undefined: button/volumedown / VOLDN
May 19 18:56:01 spread-tb-arch root[2368]: ACPI group/action undefined: button/volumeup / VOLUP
May 19 18:56:01 spread-tb-arch root[2370]: ACPI group/action undefined: button/volumedown / VOLDN
May 19 18:56:01 spread-tb-arch root[2372]: ACPI group/action undefined: button/volumeup / VOLUP
May 19 18:56:01 spread-tb-arch root[2374]: ACPI group/action undefined: button/volumedown / VOLDN
May 19 18:56:02 spread-tb-arch root[2376]: ACPI group/action undefined: button/volumeup / VOLUP
May 19 18:56:02 spread-tb-arch root[2378]: ACPI group/action undefined: button/volumedown / VOLDN
May 19 18:56:02 spread-tb-arch root[2380]: ACPI group/action undefined: button/volumeup / VOLUP
May 19 18:56:02 spread-tb-arch root[2382]: ACPI group/action undefined: button/volumedown / VOLDN

以上日志为/etc/acpi/handler.sh中的脚本,因此怀疑发送的acpi事件被/etc/acpi/events/anything中的配置捕获,并没有被我的/etc/acpi/events/vol-u和/etc/acpi/events/vol-d捕获。

尝试在/etc/acpi/events/anything中加入对应的监听:

button/volumeup)
        sudo -u spreadzhao XDG_RUNTIME_DIR=/run/user/1000 amixer set Master 5%+
        ;;

bash中的一个case,监听音量+的按键

经过这样的设置后,音量+按键可以正常工作了。

4. 问题

所以,为啥只有静音键正常呢?难道是被其他的进程捕获了吗?但是如果这样的话,为什么日志里/etc/acpi/events/anything还能检测到音量+-的按键行为呢?

5. 我的环境
                   -`                    spreadzhao@spread-tb-arch
                  .o+`                   -------------------------
                 `ooo/                   OS: Arch Linux x86_64
                `+oooo:                  Host: 21J1 ThinkBook 14 G5+ APO
               `+oooooo:                 Kernel: 6.9.1-arch1-1
               -+oooooo+:                Uptime: 26 mins
             `/:-:++oooo+:               Packages: 604 (pacman)
            `/++++/+++++++:              Shell: zsh 5.9
           `/++++++++++++++:             Resolution: 2880x1800
          `/+++ooooooooooooo/`           WM: dwm
         ./ooosssso++osssssso+`          Theme: Adwaita [GTK3]
        .oossssso-````/ossssss+`         Icons: Adwaita [GTK3]
       -osssssso.      :ssssssso.        Terminal: st
      :osssssss/        osssso+++.       Terminal Font: Terminus (TTF)
     /ossssssss/        +ssssooo/-       CPU: AMD Ryzen 7 7840H (16) @ 4.350GHz
   `/ossssso+/:-        -:/+osssso+-     GPU: AMD ATI 64:00.0 Phoenix1
  `+sso+:-`                 `.-/+oso:    Memory: 2137MiB / 27746MiB
 `++:.                           `-/+/
 .`                                 `/

离线

#2 2024-05-19 20:22:42

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,698
个人网站

Re: 按照wiki使用acpid进行音量按键控制,只有静音生效,音量的+-控制无效

建议不要使用 acpid / alsa。直接在你的桌面环境监听多媒体按键然后用 pamixer 调整音量。

离线

页脚