~mil/sxmo-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
5 3

[PATCH sxmo-utils] device agnostic bindings for volume and power

Details
Message ID
<20230915203001.697802-1-aren@peacevolution.org>
DKIM signature
pass
Download raw message
Patch: +33 -40
If a device without a deviceprofile enters a lock / screenoff state it
isn't possible to wake up currently.

Most of our functionality doesn't need to know what physical device
keycodes come from. The only reasons we care about it are, 1) to set the
repeat rate / delay for the multikey script and 2) to set a keymap to
remap volume and power to up/down/enter.

This patch allows for much better functionality at the cost of a bit of
speed when we're missing a deviceprofile.

Signed-off-by: Aren Moynihan <aren@peacevolution.org>
---
 configs/appcfg/sway_template      |  9 ++++-
 scripts/core/sxmo_swayinitconf.sh | 64 ++++++++++++-------------------
 2 files changed, 33 insertions(+), 40 deletions(-)

diff --git a/configs/appcfg/sway_template b/configs/appcfg/sway_template
index 0ae0726..a516632 100644
--- a/configs/appcfg/sway_template
+++ b/configs/appcfg/sway_template
@@ -27,7 +27,14 @@ exec_always sxmo_swayinitconf.sh
exec_always dbus-update-activation-environment WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP

mode "menu" {
    bindsym --input-device=1:1:1c21800.lradc XF86AudioMute exec nothing # just a placeholder for "menu" mode
    # This is slower than remapping the keys using a keymap, but we don't need
    # to know the device names, so use it as a fallback so this functionality
    # keeps working if a deviceprofile doesn't exist.
    # TODO: the correct way to do this is to implement custom keybindings in
    # bemenu
    bindsym XF86PowerOff exec wtype -k Return
    bindsym XF86AudioRaiseVolume exec wtype -k Up
    bindsym XF86AudioLowerVolume exec wtype -k Down
}

### Key bindings
diff --git a/scripts/core/sxmo_swayinitconf.sh b/scripts/core/sxmo_swayinitconf.sh
index f234d30..4c3fbb5 100755
--- a/scripts/core/sxmo_swayinitconf.sh
+++ b/scripts/core/sxmo_swayinitconf.sh
@@ -16,39 +16,37 @@ vols="${SXMO_VOLUME_BUTTON:-"1:1:1c21800.lradc"}"
multikey_retrocompat() {
	sxmo_multikey.sh clear

	swaymsg -- input "$pwr" repeat_delay 200
	swaymsg -- input "$pwr" repeat_rate 15
	if [ -n "$pwr" ]; then
		swaymsg -- input "$pwr" repeat_delay 200
		swaymsg -- input "$pwr" repeat_rate 15
	fi

	if ! [ "$vols" = "none" ]; then
	if [ -n "$vols" ]; then
		for vol in $vols; do
			swaymsg -- input "$vol" repeat_delay 200
			swaymsg -- input "$vol" repeat_rate 15
		done
	fi

	swaymsg -- bindsym --locked --input-device="$pwr" XF86PowerOff exec sxmo_multikey.sh \
	swaymsg -- bindsym --locked XF86PowerOff exec sxmo_multikey.sh \
		powerbutton \
		powerbutton_one \
		powerbutton_two \
		powerbutton_three

	if ! [ "$vols" = "none" ]; then
		for vol in $vols; do
			swaymsg -- bindsym --locked --input-device="$vol" XF86AudioRaiseVolume exec \
				sxmo_multikey.sh \
				volup \
				volup_one \
				volup_two \
				volup_three

			swaymsg -- bindsym --locked --input-device="$vol" XF86AudioLowerVolume exec \
				sxmo_multikey.sh \
				voldown \
				voldown_one \
				voldown_two \
				voldown_three
		done
	fi
	swaymsg -- bindsym --locked XF86AudioRaiseVolume exec \
		sxmo_multikey.sh \
		volup \
		volup_one \
		volup_two \
		volup_three

	swaymsg -- bindsym --locked XF86AudioLowerVolume exec \
		sxmo_multikey.sh \
		voldown \
		voldown_one \
		voldown_two \
		voldown_three
}

if [ -n "$SXMO_MODEM_GPIO_KEY_RI" ]; then
@@ -67,28 +65,16 @@ focused_name="$(
swaymsg -- input type:touch map_to_output "$focused_name"
swaymsg -- input type:tablet_tool map_to_output "$focused_name"

swaymsg -- input "$pwr" xkb_file "$(xdg_data_path sxmo/xkb/xkb_mobile_normal_buttons)"

if ! [ "$vols" = "none" ]; then
	for vol in $vols; do
		swaymsg -- input "$vol" xkb_file "$(xdg_data_path sxmo/xkb/xkb_mobile_normal_buttons)"
	done
fi

if ! command -v bonsaictl > /dev/null; then
	multikey_retrocompat
	exit
fi

swaymsg -- bindsym --locked --input-device="$pwr" --no-repeat XF86PowerOff exec bonsaictl -e power_pressed
swaymsg -- bindsym --locked --input-device="$pwr" --release XF86PowerOff exec bonsaictl -e power_released
swaymsg -- bindsym --locked --no-repeat XF86PowerOff exec bonsaictl -e power_pressed
swaymsg -- bindsym --locked --release XF86PowerOff exec bonsaictl -e power_released

if ! [ "$vols" = "none" ]; then
	for vol in $vols; do
		swaymsg -- bindsym --locked --input-device="$vol" --no-repeat XF86AudioRaiseVolume exec bonsaictl -e volup_pressed
		swaymsg -- bindsym --locked --input-device="$vol" --release XF86AudioRaiseVolume exec bonsaictl -e volup_released
swaymsg -- bindsym --locked --no-repeat XF86AudioRaiseVolume exec bonsaictl -e volup_pressed
swaymsg -- bindsym --locked --release XF86AudioRaiseVolume exec bonsaictl -e volup_released

		swaymsg -- bindsym --locked --input-device="$vol" --no-repeat XF86AudioLowerVolume exec bonsaictl -e voldown_pressed
		swaymsg -- bindsym --locked --input-device="$vol" --release XF86AudioLowerVolume exec bonsaictl -e voldown_released
	done
fi
swaymsg -- bindsym --locked --no-repeat XF86AudioLowerVolume exec bonsaictl -e voldown_pressed
swaymsg -- bindsym --locked --release XF86AudioLowerVolume exec bonsaictl -e voldown_released
-- 
2.42.0

[sxmo-utils/patches/test.yml] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CVJRYCJC8TNN.326EE2XN91U1Y@cirno2>
In-Reply-To
<20230915203001.697802-1-aren@peacevolution.org> (view parent)
DKIM signature
missing
Download raw message
sxmo-utils/patches/test.yml: SUCCESS in 48s

[device agnostic bindings for volume and power][0] from [ArenM][1]

[0]: https://lists.sr.ht/~mil/sxmo-devel/patches/44774
[1]: aren@peacevolution.org

✓ #1058170 SUCCESS sxmo-utils/patches/test.yml https://builds.sr.ht/~mil/job/1058170
Details
Message ID
<CVK60D4KOU5M.FQ5NYK8UHHF9@yellow-orcess>
In-Reply-To
<20230915203001.697802-1-aren@peacevolution.org> (view parent)
DKIM signature
pass
Download raw message
Hey Aren,

The first part, with default bindsym on media keys to emulate Return, Up
and Down, is a brillant idea. I think it should works by itself, and
offer a good enough alternative if sxmo_menumode_toggler.sh fails to
switch the layout.

But I disagree with most of the changes from sxmo_swayinitconf.sh:

First it is pointless to use the legacy sxmo_multikey.sh if we can't set
the input delay and rate. It expects those values.

Then I'm not sure we want to map every media key to bonsaictl. Only the specific
inputs should behave like this imo.


I'd like to know what others thinks about that last part.

Willow
Details
Message ID
<rqfkkvpvybt57e6gw75znd3mdp3vr7toxqlpbpnxn7ukrlqkor@4yhwqbfuhhxc>
In-Reply-To
<CVK60D4KOU5M.FQ5NYK8UHHF9@yellow-orcess> (view parent)
DKIM signature
pass
Download raw message
On Sat, Sep 16, 2023 at 09:31:52AM +0200, Willow Barraco wrote:
> Hey Aren,
> 
> The first part, with default bindsym on media keys to emulate Return, Up
> and Down, is a brillant idea. I think it should works by itself, and
> offer a good enough alternative if sxmo_menumode_toggler.sh fails to
> switch the layout.

Cool, I'll split this part into a separate patch so it's not blocked by
discussion on the rest of this patch.

> But I disagree with most of the changes from sxmo_swayinitconf.sh:
> 
> First it is pointless to use the legacy sxmo_multikey.sh if we can't set
> the input delay and rate. It expects those values.

Perhaps it would make sense to only bind a single button press
(bypassing multikey) if we can't set the repeat rate? That way the
buttons will still work for basic tasks like unlocking.

> Then I'm not sure we want to map every media key to bonsaictl. Only the specific
> inputs should behave like this imo.

I'm firmly of the opinion that not mapping every input adds extra
complexity without much benefit. Currently we have to maintain a
database of every possible input device that should trigger the
inputhandler, which is already getting bulky. If we drop this
requirement it would be a big step towards not needing deviceprofiles
for every new device.

It's inconsistent that dwm maps every input device, and sway only maps
specific ones. And I find it a bit counter-intuitive that some input
devices work one way and others another.

> I'd like to know what others thinks about that last part.
> 
> Willow
Details
Message ID
<CVLUPI1FTSV5.1K3OHJYCTJ5H8@yellow-orcess>
In-Reply-To
<rqfkkvpvybt57e6gw75znd3mdp3vr7toxqlpbpnxn7ukrlqkor@4yhwqbfuhhxc> (view parent)
DKIM signature
pass
Download raw message
> > But I disagree with most of the changes from sxmo_swayinitconf.sh:
> > 
> > First it is pointless to use the legacy sxmo_multikey.sh if we can't set
> > the input delay and rate. It expects those values.
>
> Perhaps it would make sense to only bind a single button press
> (bypassing multikey) if we can't set the repeat rate? That way the
> buttons will still work for basic tasks like unlocking.

Agreed! And we could bypass the multi key script completly in this case.

> > Then I'm not sure we want to map every media key to bonsaictl. Only the specific
> > inputs should behave like this imo.
>
> I'm firmly of the opinion that not mapping every input adds extra
> complexity without much benefit. Currently we have to maintain a
> database of every possible input device that should trigger the
> inputhandler, which is already getting bulky. If we drop this
> requirement it would be a big step towards not needing deviceprofiles
> for every new device.
>
> It's inconsistent that dwm maps every input device, and sway only maps
> specific ones. And I find it a bit counter-intuitive that some input
> devices work one way and others another.

Okay but then let's limit this to non desktop SXMO_DEVICE_NAME. Vol keys
are important when we don't have access to lisgd left edge swipes.
Details
Message ID
<CW4VYBJBQDKA.2GM5XLT69KVVC@willowbarraco.fr>
In-Reply-To
<20230915203001.697802-1-aren@peacevolution.org> (view parent)
DKIM signature
pass
Download raw message
Marked as superseded !
Reply to thread Export thread (mbox)