-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(hardware): sync ThinkBook mute LEDs with WirePlumber state #5431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Dev-solder124
wants to merge
1
commit into
basecamp:dev
Choose a base branch
from
Dev-solder124:feat/thinkbook-led-sync
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
install/config/hardware/lenovo/fix-thinkbook-led-permissions.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
|
Dev-solder124 marked this conversation as resolved.
|
||
| EOF | ||
| sudo udevadm control --reload-rules | ||
| sudo udevadm trigger --subsystem-match=leds | ||
|
Dev-solder124 marked this conversation as resolved.
|
||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.