diff --git a/bin/omarchy-cmd-mic-mute b/bin/omarchy-cmd-mic-mute index 3931d0b807..daf389067c 100755 --- a/bin/omarchy-cmd-mic-mute +++ b/bin/omarchy-cmd-mic-mute @@ -6,6 +6,8 @@ if omarchy-hw-match "XPS"; then omarchy-cmd-mic-mute-xps elif omarchy-hw-match "ThinkPad"; then omarchy-cmd-mic-mute-thinkpad +elif omarchy-hw-match "ThinkBook"; then + omarchy-cmd-mic-mute-thinkbook else omarchy-swayosd-client --input-volume mute-toggle fi diff --git a/bin/omarchy-cmd-mic-mute-thinkbook b/bin/omarchy-cmd-mic-mute-thinkbook new file mode 100755 index 0000000000..f0a8ff2273 --- /dev/null +++ b/bin/omarchy-cmd-mic-mute-thinkbook @@ -0,0 +1,20 @@ +#!/bin/bash + +# Toggle microphone mute on ThinkBook systems. Uses wpctl for reliable toggling +# (swayosd-server on some systems does not propagate input-volume mute-toggle +# to WirePlumber). Syncs the platform::micmute LED, then fires swayosd's native +# input-volume OSD via +0 so the mic-level progress bar is preserved. + +wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle >/dev/null + +if pactl get-source-mute @DEFAULT_SOURCE@ | grep -q 'yes'; then + led_value=1 +else + led_value=0 +fi + +brightnessctl --device="platform::micmute" set "$led_value" >/dev/null 2>&1 || true + +# +0 reads current input volume state and shows the native bar OSD without +# changing anything — swayosd displays muted/unmuted icon + level bar. +omarchy-swayosd-client --input-volume +0 diff --git a/bin/omarchy-cmd-mic-mute-thinkpad b/bin/omarchy-cmd-mic-mute-thinkpad index a6e551a78a..5e087d3571 100755 --- a/bin/omarchy-cmd-mic-mute-thinkpad +++ b/bin/omarchy-cmd-mic-mute-thinkpad @@ -1,23 +1,20 @@ #!/bin/bash # Toggle microphone mute on ThinkPad systems. Uses wpctl for reliable toggling -# and syncs the platform::micmute LED via brightnessctl. +# (swayosd-server on some systems does not propagate input-volume mute-toggle +# to WirePlumber). Syncs the platform::micmute LED, then fires swayosd's native +# input-volume OSD via +0 so the mic-level progress bar is preserved. wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle >/dev/null if pactl get-source-mute @DEFAULT_SOURCE@ | grep -q 'yes'; then - osd_message='Microphone muted' - osd_icon='microphone-sensitivity-muted-symbolic' led_value=1 else - osd_message='Microphone on' - osd_icon='audio-input-microphone-symbolic' led_value=0 fi brightnessctl --device="platform::micmute" set "$led_value" >/dev/null 2>&1 || true -swayosd-client \ - --monitor "$(omarchy-hyprland-monitor-focused)" \ - --custom-message "$osd_message" \ - --custom-icon "$osd_icon" +# +0 reads current input volume state and shows the native bar OSD without +# changing anything — swayosd displays muted/unmuted icon + level bar. +omarchy-swayosd-client --input-volume +0 diff --git a/bin/omarchy-cmd-mute b/bin/omarchy-cmd-mute new file mode 100755 index 0000000000..1ffbfbab30 --- /dev/null +++ b/bin/omarchy-cmd-mute @@ -0,0 +1,15 @@ +#!/bin/bash + +# Toggle speaker mute with OSD. On ThinkBook systems, also syncs the +# platform::mute hardware LED to match WirePlumber state. + +omarchy-swayosd-client --output-volume mute-toggle + +if omarchy-hw-match "ThinkBook"; then + if pactl get-sink-mute @DEFAULT_SINK@ | grep -q 'yes'; then + led_value=1 + else + led_value=0 + fi + brightnessctl --device="platform::mute" set "$led_value" >/dev/null 2>&1 || true +fi diff --git a/bin/omarchy-hw-thinkbook b/bin/omarchy-hw-thinkbook new file mode 100755 index 0000000000..659bef3de6 --- /dev/null +++ b/bin/omarchy-hw-thinkbook @@ -0,0 +1,6 @@ +#!/bin/bash + +# Detect Lenovo ThinkBook hardware via DMI product_family. +# Usage: omarchy-hw-thinkbook (returns exit 0 if ThinkBook, non-zero otherwise) + +omarchy-hw-match "ThinkBook" diff --git a/default/hypr/bindings/media.conf b/default/hypr/bindings/media.conf index c02872dc81..3f08681b1a 100644 --- a/default/hypr/bindings/media.conf +++ b/default/hypr/bindings/media.conf @@ -1,7 +1,7 @@ # Laptop multimedia keys for volume and LCD brightness (with OSD) bindeld = ,XF86AudioRaiseVolume, Volume up, exec, omarchy-swayosd-client --output-volume raise bindeld = ,XF86AudioLowerVolume, Volume down, exec, omarchy-swayosd-client --output-volume lower -bindeld = ,XF86AudioMute, Mute, exec, omarchy-swayosd-client --output-volume mute-toggle +bindeld = ,XF86AudioMute, Mute, exec, omarchy-cmd-mute bindeld = ,XF86AudioMicMute, Mute microphone, exec, omarchy-cmd-mic-mute bindeld = ,XF86MonBrightnessUp, Brightness up, exec, omarchy-brightness-display +5% bindeld = ,XF86MonBrightnessDown, Brightness down, exec, omarchy-brightness-display 5%- diff --git a/install/config/all.sh b/install/config/all.sh index 6926719579..7166f2fa2b 100644 --- a/install/config/all.sh +++ b/install/config/all.sh @@ -57,6 +57,7 @@ run_logged $OMARCHY_INSTALL/config/hardware/apple/fix-spi-keyboard.sh run_logged $OMARCHY_INSTALL/config/hardware/apple/fix-suspend-nvme.sh run_logged $OMARCHY_INSTALL/config/hardware/apple/fix-t2.sh +run_logged $OMARCHY_INSTALL/config/hardware/lenovo/fix-thinkbook-led-permissions.sh run_logged $OMARCHY_INSTALL/config/hardware/fix-bcm43xx.sh run_logged $OMARCHY_INSTALL/config/hardware/fix-surface-keyboard.sh run_logged $OMARCHY_INSTALL/config/hardware/fix-yt6801-ethernet-adapter.sh diff --git a/install/config/hardware/lenovo/fix-thinkbook-led-permissions.sh b/install/config/hardware/lenovo/fix-thinkbook-led-permissions.sh new file mode 100644 index 0000000000..37c36fefe7 --- /dev/null +++ b/install/config/hardware/lenovo/fix-thinkbook-led-permissions.sh @@ -0,0 +1,14 @@ +# Grant users in the video group write access to the ThinkBook platform mute LEDs. +# Without this, only root can update platform::mute and platform::micmute, +# so keybinding scripts cannot sync the hardware LED to WirePlumber state. + +if omarchy-hw-match "ThinkBook"; then + sudo tee /etc/udev/rules.d/99-lenovo-thinkbook-leds.rules << 'EOF' +# Allow users in the video group to control ThinkBook platform mute LEDs +SUBSYSTEM=="leds", KERNEL=="platform::mute", ACTION=="add|change", RUN+="/usr/bin/chgrp video /sys%p/brightness", RUN+="/usr/bin/chmod 0664 /sys%p/brightness" +SUBSYSTEM=="leds", KERNEL=="platform::micmute", ACTION=="add|change", RUN+="/usr/bin/chgrp video /sys%p/brightness", RUN+="/usr/bin/chmod 0664 /sys%p/brightness" +EOF + + sudo udevadm control --reload-rules + sudo udevadm trigger --subsystem-match=leds +fi diff --git a/migrations/1777020424.sh b/migrations/1777020424.sh new file mode 100644 index 0000000000..f78aea4d62 --- /dev/null +++ b/migrations/1777020424.sh @@ -0,0 +1,14 @@ +echo "Sync ThinkBook hardware mute LEDs with WirePlumber state" + +# Install udev rule so users in the video group can write to the platform mute LED nodes. +# On ThinkBook laptops, the kernel exposes platform::mute and platform::micmute +# under /sys/class/leds/ with root-only write permissions by default. +if omarchy-hw-match "ThinkBook"; then + sudo tee /etc/udev/rules.d/99-lenovo-thinkbook-leds.rules > /dev/null << 'EOF' +# Allow users in the video group to control ThinkBook platform mute LEDs +SUBSYSTEM=="leds", KERNEL=="platform::mute", ACTION=="add|change", RUN+="/usr/bin/chgrp video /sys%p/brightness", RUN+="/usr/bin/chmod 0664 /sys%p/brightness" +SUBSYSTEM=="leds", KERNEL=="platform::micmute", ACTION=="add|change", RUN+="/usr/bin/chgrp video /sys%p/brightness", RUN+="/usr/bin/chmod 0664 /sys%p/brightness" +EOF + sudo udevadm control --reload-rules + sudo udevadm trigger --subsystem-match=leds +fi