diff options
| author | Philip Wittamore <philip@wittamore.com> | 2026-07-12 11:08:50 +0200 |
|---|---|---|
| committer | Philip Wittamore <philip@wittamore.com> | 2026-07-12 11:08:50 +0200 |
| commit | 420ceb49b53a8fa9d8ba8443e42e50cd7bd7cea9 (patch) | |
| tree | 3009f0564d75e3f7d1ca38507e7ebb92deaded07 /articles/2025/DWM-Dunst-and-Thinkpad-audio-keys.html | |
update
Diffstat (limited to 'articles/2025/DWM-Dunst-and-Thinkpad-audio-keys.html')
| -rwxr-xr-x | articles/2025/DWM-Dunst-and-Thinkpad-audio-keys.html | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/articles/2025/DWM-Dunst-and-Thinkpad-audio-keys.html b/articles/2025/DWM-Dunst-and-Thinkpad-audio-keys.html new file mode 100755 index 0000000..ee184b8 --- /dev/null +++ b/articles/2025/DWM-Dunst-and-Thinkpad-audio-keys.html @@ -0,0 +1,113 @@ +<!doctype html> +<html lang="EN"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="/style.css"> + <title>DWM Dunst and Thinkpad audio keys</title> + </head> + <body> + <header> + <h1>Bloggings</h1> + <a href="/index.php">Back</a> + + </header> + +<main> +<article> +<h2>DWM Dunst and Thinkpad audio keys</h2> +<h3>2025-04-24</h3> +<h4>How I got them working, microphone mute led included</h4> +<p>DWM isn't a desktop environment, so there are a few things to add, like notifications and +audio keys.</p> +<p>I installed dunst and acpid. Dunst is managed by systemd, if you edit ~/.config/dunst/dunstrc +restart dunst with <b>systemctl --user restart dunst.service</b></p> +<p><a href="https://github.com/dunst-project/dunst">Dunst web page</a></p> +<p><a href="https://wiki.archlinux.org/title/Acpid">Acpid Arch page</a></p> + + +<h4>dwm/config.h</h4> +<p>The audio keys are registered in <b>dwm/config.h</b> +<pre> +... +{ 0, XF86XK_AudioMicMute, spawn, SHCMD("~/.local/bin/dwm-audio mictoggle") }, +{ 0, XF86XK_AudioMute, spawn, SHCMD("~/.local/bin/dwm-audio voltoggle") }, +{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("~/.local/bin/dwm-audio volquieter") }, +{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("~/.local/bin/dwm-audio vollouder") }, +... +</pre> + +<h4>~/.local/bin/dwm-audio</h4> +<p>The audio keys run a bash script which sets volume, speaker mute, and microphone mute.</p> +<pre> +#!/bin/bash +# Manage Thinkpad Audio keys + +msgTag="Audio" + +# Microphone +if [[ "$@" == "mictoggle" ]]; then + pamixer --default-source -t + micmute="$(pamixer --default-source --get-mute)" + if [[ "$micmute" == "true" ]]; then + # Mic muted notification + dunstify -t 1000 -a "Microphone" -u low -i audio-input-microphone \ + -h string:x-dunst-stack-tag:$msgTag "Microphone muted" + else + # Mic unmuted notification + dunstify -t 1000 -a "Microphone" -u low -i audio-input-microphone \ + -h string:x-dunst-stack-tag:$msgTag "Microphone unmuted" + fi + exit 0 +fi + +# Speakers +if [[ "$@" == "voltoggle" ]]; then + pamixer --toggle-mute +elif [[ "$@" == "vollouder" ]]; then + pamixer -i 10 +elif [[ "$@" == "volquieter" ]]; then + pamixer -d 10 +fi + +volume="$(pamixer --get-volume-human)" +mute="$(pamixer --get-mute)" +if [[ $volume == 0 || "$mute" == "true" ]]; then + # Sound muted notification + dunstify -t 1000 -a "changeVolume" -u low -i audio-speakers \ + -h string:x-dunst-stack-tag:$msgTag "Volume muted" +else + # Volume notification + dunstify -t 1000 -a "changeVolume" -u low -i audio-speakers \ + -h string:x-dunst-stack-tag:$msgTag -h int:value:"$volume" "Volume: ${volume}" +fi +</pre> + +<h4>Microphone mute led</h4> +<p>I'm running Arch Linux on a Thinkpad X220, so I need to make the mic/mute button's led +lights up when muted. This can't be done with normal user permissions, so I installed acpid. +On Arch linux all acpi events are passed to <b>/etc/acpi/handler.sh</b>, so I added another +function to this file. +</p> +<pre> +... +button/micmute) + if [[ "$(cat /sys/devices/platform/thinkpad_acpi/leds/platform\:\:micmute/brightness)" == "1" ]]; then + echo "0" > /sys/devices/platform/thinkpad_acpi/leds/platform\:\:micmute/brightness + else + echo "1" > /sys/devices/platform/thinkpad_acpi/leds/platform\:\:micmute/brightness + fi +;; +... +</pre> + +</article> +</main> +<footer> + +<p> </p> + +<p>ยง</p> + </footer> +</body> +</html> |
