summaryrefslogtreecommitdiff
path: root/bin
diff options
authorYao Wei (魏銘廷) <yao.wei@canonical.com>2021-09-13 10:23:55 +0800
committerYao Wei (魏銘廷) <yao.wei@canonical.com>2021-09-22 10:45:40 +0800
commitf33feb02a56471e8ea605cabc2d698a40890af6f (patch)
tree038a4b7f720041640bcb8c3f96c87051e2ab172b /bin
parent7e6a412cf72fab51b113c712bc37b98d1481f0f8 (diff)
Check whether screen orientation is fixed on laptops
This is to address LP: #1895110, that the accelerometer on some laptops can cause the screen orientation change by tilting the machine, or is incorrect by default.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fixed_screen_orientation.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/fixed_screen_orientation.sh b/bin/fixed_screen_orientation.sh
new file mode 100755
index 0000000..5fbe162
--- /dev/null
+++ b/bin/fixed_screen_orientation.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+if ! (udevadm info --export-db | grep -q iio_device); then
+ echo "Screen orientation check PASSED:"
+ echo "no iio_device found in this device, therefore rotation should not happen."
+ exit 0
+fi
+
+if dbus-send --system --print-reply --dest=net.hadess.SensorProxy \
+ /net/hadess/SensorProxy \
+ org.freedesktop.DBus.Properties.Get string:net.hadess.SensorProxy string:HasAccelerometer |
+ grep -q "boolean true"; then
+ echo "Screen orientation check FAILED:"
+ echo "this device has an accelerometer that needs to be disabled."
+ echo "==="
+ # list IIO devices for reference
+ echo "udevadm info /sys/bus/iio/devices/iio*"
+ udevadm info /sys/bus/iio/devices/iio*
+ exit 1
+fi
+
+echo "Screen orientation check PASSED:"
+echo "Accelerometer is not enabled."