Skip to content

Commit 773944a

Browse files
committed
xwin-tabletd: Allow manual override from sxhkd if and when accelerometer fails
1 parent acc2e98 commit 773944a

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

.config/sxhkd/default

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ ctrl + alt + {Delete,Insert}
4949
# rotate display orientation
5050
shift + super + {Up,Down,Left,Right}
5151
sfx-synth btn & \
52-
xrandr --output "$(xrandr | grep '[^dis]connected' | tr -s ' ' '\t' | cut -f1)" \
53-
--rotate "{inverted,normal,right,left}"
52+
echo '{bottom-up,normal,right-up,left-up}' >> ~/.rotate
5453

5554
## function keys
5655
# F1: power/reboot

.local/bin/xwin-tabletd

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22

3-
# xwin-tabletd v0.2
3+
# xwin-tabletd v0.3
44
# rotates display and digitizer input based on accelerometer
55

66
# detect primary display
@@ -15,14 +15,19 @@ ptr_devices="$(xinput list --name-only | egrep -i '(touchpad|trackpoint)')"
1515

1616
trap 'kill $!' 0 1 2 3 6 15
1717

18-
# workaround: repeatedly poke at iio-sensor-proxy on a timer to avoid
19-
# aggressive battery optimization
18+
# workarounds for iio-sensor-proxy
19+
# repeatedly poke accelerometer on a timer to avoid aggressive battery optimization
2020
while :; do
2121
cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw > /dev/null
2222
sleep 2
2323
done &
2424

25-
monitor-sensor | while read -r line; do
25+
# sxhkd: allows manual override if and when accelerometer stops responding
26+
RFIFO="$HOME/.rotate"
27+
[ ! -p "$RFIFO" ] && mkfifo "$RFIFO"
28+
monitor-sensor >> "$RFIFO" &
29+
30+
while read -r line; do
2631
state="${line##* }"
2732
unset rot mat
2833
case "$state" in
@@ -48,4 +53,4 @@ monitor-sensor | while read -r line; do
4853
[ "$rot" = "normal" ] && xinput enable "$f" || xinput disable "$f"
4954
done &
5055
fi
51-
done
56+
done < "$RFIFO"

0 commit comments

Comments
 (0)