arch/pkg/de-p1st-rotate/usr/bin/de-p1st-auto-rotate

33 lines
793 B
Plaintext
Raw Normal View History

2021-06-17 16:25:38 +02:00
#!/bin/bash
2021-06-17 16:37:04 +02:00
#
# Inspired by https://linuxappfinder.com/blog/auto_screen_rotation_in_ubuntu
2021-06-17 16:25:38 +02:00
# Output of "monitor-sensor --accel | grep 'orientation'":
# === Has accelerometer (orientation: normal)
# Accelerometer orientation changed: right-up
# Feed output of 'monitor-sensor' and stop after first match of 'orientation'
ORIENTATION_STR="$(grep -m 1 'orientation' <( monitor-sensor ))" || exit $?
case "${ORIENTATION_STR}" in
*": normal"*)
ORIENTATION="normal";
;;
*": bottom-up"*)
ORIENTATION="inverted";
;;
*": right-up"*)
ORIENTATION="left";
;;
*": left-up"*)
ORIENTATION="right";
;;
*)
echo "Could not parse ORIENTATION_STR!";
exit 1;
esac
# echo "Detected device orientation ${ORIENTATION}"
de-p1st-rotate-screen "${ORIENTATION}"