笔记本 快捷键 切换静音小脚本 acpi

danny posted @ 2012年8月18日 21:34 in shell with tags linux code DIY shell , 2241 阅读

虽然安装了acpi-support,但我的笔记本依然不能启用静音切换的快捷键,很不方便,于是自己写了个切换静音小脚本。至于调节音量,类推就行了。

 

# /etc/acpi/events/mutebtn
# Called when the user presses the mute button

event=button[ /]mute
action=/etc/acpi/mute.sh

 

#!/bin/sh
# /etc/acpi/mute.sh
vol=`amixer | sed -r "s/(\[|\])//g"  | sed -rn "/'Master'/,+6{h;/Playback.*%/{p;q}}" | awk '{print $5}'`
if test $vol != 0%; then
    echo $vol > /etc/acpi/volstore.dat
    amixer set Master front 0
else
    vol=`cat /etc/acpi/volstore.dat`
    amixer set Master front $vol
fi
exit 0


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter