Repository navigation
The side mute switch follows its position; keyboards' Mute keys still toggle - #104
Merged
Merged
Conversation
The kernel reports the ring/silent switch (mainline Apple device trees) as gpio-keys' KEY_MUTE, held down while on silent. labwc's XF86AudioMute binding toggled the mute and repeated while the key was held, so the mute flickered on and off for seconds with the OSD, again at every boot and resume, and flipping the switch back toggled instead of following it. omarchy-mute-switch (/usr/libexec, from the session's autostart) finds a gpio-keys device with KEY_MUTE, sets the default output's mute to the switch's position at login (quietly) and follows it with the volume OSD (omarchy-volume mute-on|mute-off). Each change is read back from the switch (EVIOCGKEY) after a short settle, so the release and press the kernel reports around a suspend change nothing. It exits without such a switch, looks for a lost one again, and ends with labwc. The Mute key binding becomes omarchy-volume mute-key, which toggles only while no switch is followed (the helper's pid in $XDG_RUNTIME_DIR). labwc cannot tell the switch from a keyboard's Mute key, so on such a device the helper also follows the Mute keys of the other input devices (Bluetooth or USB keyboards, also ones that connect later): a press toggles the mute with the OSD, repeats change nothing. A migration rewrites the shipped binding in existing users' rc.xml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SFMaVf5sMxs7xEyPFZWGEj
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SFMaVf5sMxs7xEyPFZWGEj
gpio-keys names its input device after the device tree node's label when it has one, so a labelled node would not be called gpio-keys and its side switch would be taken for a keyboard's Mute key. The driver always sets phys to gpio-keys/input0: a device with that phys is a switch too. Assisted-by: LLM
Assisted-by: LLM
Contributor
|
Welcome, and thank you, Rick! This is merged as you wrote it. With it, the side switch now just mutes on silent and unmutes on ring. The flickering after boot and wake is gone, and keyboard Mute keys still toggle. It's tagged Two small changes on top, both on your branch before the merge:
If you work from your fork's |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The side mute switch follows its position
On the iPhone and the older iPads the kernel reports the ring/silent switch the way Apple's device trees in mainline do: as KEY_MUTE of the
gpio-keysinput device, held down while the switch is on silent. labwc takes it for a Mute key. It runsomarchy-volume mute-toggleon every repeat while the key is held, so with the switch on silent the mute turns on and off for about five seconds and the volume OSD flickers. This happens again after every boot and every wake, because the input core releases held keys at suspend and gpio-keys reports them again at resume. A toggle is also the wrong behaviour for a switch: the mute should follow the switch's position, not flip each time it moves.The kernel's convention (KEY_MUTE held as the switch's state) is the same across Apple's device trees, so this is fixed in the session, not in the kernel.
What changes
omarchy-mute-switch(desktop/configuration/mute-switch, installed as/usr/libexec/omarchy-mute-switchand started from the labwc autostart). It is a small Python helper that uses only the standard library.gpio-keysdevice that has KEY_MUTE.omarchy-volume mute-on|mute-off, which shows the OSD.omarchy-volume:mute-onandmute-off.mute-key, which labwc's XF86AudioMute now runs. It does nothing while the helper follows a switch (its pid is in$XDG_RUNTIME_DIR/omarchy-mute-switch), and toggles as before otherwise.omarchy-volume mute-toggle); repeats change nothing.1795508927.shrewrites the shippedomarchy-volume mute-togglebinding in existing~/.config/labwc/rc.xmlfiles. A user's own bindings are left alone.tests/test_mute_switch.py: detection of switches and keyboards from a fake sysfs, the decisions, repeats, the suspend release and press, bounce, keyboard presses and toggling, the migration.test_volume_keys.pyandtest_package_staging.py.docs/tablet-sensors.md.Tested
iPhone 6s Plus (N66) on omarchy-a 0.3.2. The helper was copied to
~/.local/bin, and the binding was pointed at that copy'smute-key:python -m unittest discover -s testsin apython:3.11container set up like CI: 418 tests, OK (29 skipped).Not tested:
/dev/uinputneeds root. The keyboard path is tested with unit tests, and with a simulation of the main loop over pipes: a keyboard that connects, presses Mute with repeats, presses again and disconnects gives exactly two toggles.gpio-keysnode.Seen while testing: on the N66 speaker the mute is PipeWire's software mute. The speaker's ALSA route has no mute control, so
wpctl get-volumedoes not show[MUTED], although the node is muted (softMute: true) and nothing is heard. As a result the OSD icon may stayvolume-highwhen muting there. That comes from the route and is not part of this change.🤖 Generated with Claude Code
https://claude.ai/code/session_01SFMaVf5sMxs7xEyPFZWGEj