Auto rotate screen on physical keyboard opened/closed

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
This commit is contained in:
pedja
2023-08-11 17:13:55 +02:00
committed by Willow Barraco
parent df539391e5
commit e55d30d2ad
2 changed files with 30 additions and 0 deletions

View File

@@ -93,6 +93,10 @@ case "$WMCLASS" in
sxmo_daemons.sh running autorotate -q &&
printf "%s" "$icon_ton" || printf "%s" "$icon_tof"
) ^ 1 ^ toggle_daemon 'Autorotate' autorotate sxmo_autorotate.sh
$([ -n "$SXMO_KEYBOARD_SLIDER_EVENT_DEVICE" ] && echo "$icon_ror Autorotate on Keyboard Open/Close $(
sxmo_daemons.sh running kb_autorotate -q &&
printf "%s" "$icon_ton" || printf "%s" "$icon_tof"
) ^ 1 ^ toggle_daemon 'Keyboard Autorotate' kb_autorotate sxmo_keyboard_autorotate.sh")
$icon_ror Rotate ^ 1 ^ sxmo_rotate.sh rotate
$icon_trm Hooks ^ 0 ^ sxmo_hookmenu.sh
$icon_upc Upgrade Pkgs ^ 0 ^ sxmo_terminal.sh sxmo_upgrade.sh

View File

@@ -0,0 +1,26 @@
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
keyboard_opened() {
if sxmo_rotate.sh isrotated ; then
sxmo_rotate.sh rotnormal
fi
}
keyboard_closed() {
if [ "$(sxmo_rotate.sh isrotated)" != "left" ]; then
sxmo_rotate.sh rotleft
fi
}
evtest "$SXMO_KEYBOARD_SLIDER_EVENT_DEVICE" | while read -r line; do
# shellcheck disable=SC2254
case $line in
($SXMO_KEYBOARD_SLIDER_CLOSE_EVENT) keyboard_closed ;;
($SXMO_KEYBOARD_SLIDER_OPEN_EVENT) keyboard_opened ;;
esac
done