diff --git a/configs/default_hooks/sxmo_hook_contextmenu.sh b/configs/default_hooks/sxmo_hook_contextmenu.sh index 8185b7f..57a3cb8 100755 --- a/configs/default_hooks/sxmo_hook_contextmenu.sh +++ b/configs/default_hooks/sxmo_hook_contextmenu.sh @@ -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 diff --git a/scripts/core/sxmo_keyboard_autorotate.sh b/scripts/core/sxmo_keyboard_autorotate.sh new file mode 100755 index 0000000..dbf03e7 --- /dev/null +++ b/scripts/core/sxmo_keyboard_autorotate.sh @@ -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