I have been using my Samsung Galaxy Tab A (2015) with PostmarketOS on and off since last year. It serves as a really good e-book reader with KOReader installed on it.
Have tried phosh and plasma-mobile on it, works nicely but slows the device down heavily (2 GB RAM and old processor) so I use MATE Desktop environment on it.
Lately I have started using this tablet along with my laptop as a second screen for work. And it has been working super nicely for that. The only issue being that I have to manually rotate the screen to landscape every time I reboot the device. It resets the screen orientation to portrait after a reboot. So I went through the pmOS wiki and a neat nice hack documented there worked very well for me.
First we will test if the auto-rotate sensor works and if we can read values from it. So we install some basic necessary packages
$ sudo apk add xrandr xinput inotify-tools iio-sensor-proxy
Enable the service for iio-sensor-proxy
sudo rc-update add iio-sensor-proxy
Reboot the device.
Now in the device terminal start the sensor monitor-sensor
user@samsung-gt58 ~> monitor-sensor
Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared
=== Has accelerometer (orientation: normal, tilt: vertical)
=== Has ambient light sensor (value: 5.000000, unit: lux)
=== No proximity sensor
=== No compass
Light changed: 14.000000 (lux)
Accelerometer orientation changed: left-up
Tilt changed: tilted-down
Light changed: 12.000000 (lux)
Tilt changed: vertical
Light changed: 13.000000 (lux)
Light changed: 11.000000 (lux)
Light changed: 13.000000 (lux)
Accelerometer orientation changed: normal
Light changed: 5.000000 (lux)
Light changed: 6.000000 (lux)
Light changed: 5.000000 (lux)
Accelerometer orientation changed: right-up
Light changed: 3.000000 (lux)
Light changed: 4.000000 (lux)
Light changed: 5.000000 (lux)
Light changed: 12.000000 (lux)
Tilt changed: tilted-down
Light changed: 19.000000 (lux)
Accelerometer orientation changed: bottom-up
Tilt changed: vertical
Light changed: 1.000000 (lux)
Light changed: 2.000000 (lux)
Light changed: 4.000000 (lux)
Accelerometer orientation changed: right-up
Tilt changed: tilted-down
Light changed: 11.000000 (lux)
Accelerometer orientation changed: normal
Tilt changed: vertical
Tilt changed: tilted-down
Light changed: 18.000000 (lux)
Light changed: 21.000000 (lux)
Light changed: 22.000000 (lux)
Light changed: 19.000000 (lux)
Accelerometer orientation changed: left-up
Light changed: 17.000000 (lux)
Tilt changed: vertical
Light changed: 14.000000 (lux)
Tilt changed: tilted-down
Light changed: 16.000000 (lux)
Light changed: 18.000000 (lux)
Light changed: 17.000000 (lux)
Light changed: 18.000000 (lux)
Light changed: 17.000000 (lux)
Light changed: 18.000000 (lux)
Light changed: 17.000000 (lux)
Light changed: 18.000000 (lux)
Light changed: 17.000000 (lux)
As you can see we can read the rotation values from the sensor as I am rotating the tablet in different orientations.
Now we just need to use a script which changes the screen orientation using xrandr according to the sensor value.
#!/bin/sh
killall monitor-sensor
monitor-sensor > /dev/shm/sensor.log 2>&1 &
while inotifywait -e modify /dev/shm/sensor.log; do
ORIENTATION=$(tail /dev/shm/sensor.log | grep 'orientation' | tail -1 | grep -oE '[^ ]+$')
case "$ORIENTATION" in
normal)
xrandr -o normal
xinput set-prop "Goodix Capacitive TouchScreen" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
;;
left-up)
xrandr -o left
xinput set-prop "Goodix Capacitive TouchScreen" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
;;
bottom-up)
xrandr -o inverted
xinput set-prop "Goodix Capacitive TouchScreen" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
;;
right-up)
xrandr -o right
xinput set-prop "Goodix Capacitive TouchScreen" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
;;
esac
done
auto-rotate-screen.sh
You need to replace the name of your touch input device in the script, you can get the name by using xinput --list
, make sure to type this on the device terminal.
user@samsung-gt58 ~> xinput --list
* Virtual core pointer id=2 [master pointer (3)]
* * Virtual core XTEST pointer id=4 [slave pointer (2)]
* * Zinitix Capacitive TouchScreen id=10 [slave pointer (2)]
* * Toad One Plus id=12 [slave pointer (2)]
* Virtual core keyboard id=3 [master keyboard (2)]
* Virtual core XTEST keyboard id=5 [slave keyboard (3)]
* GPIO Buttons id=6 [slave keyboard (3)]
* pm8941_pwrkey id=7 [slave keyboard (3)]
* pm8941_resin id=8 [slave keyboard (3)]
* Zinitix Capacitive TouchScreen id=11 [slave keyboard (3)]
* samsung-a2015 Headset Jack id=9 [slave keyboard (3)]
In our script here we are using a Zinitix
capacitive screen, it will be different for yours.
Once your script is ready with the correct touchscreen name. Save and make the script executable. chmod +x auto-rotate-screen.sh
Then test your script in your terminal ./auto-rotate.sh
, stop the script using Ctrl + C
Now we need add this script to auto-start. On MATE DE you can go to System > Control Center > Startup Applications, then click on Custom Add button, browse the script location, give it a name and then click on Add button.
Now reboot the tablet/device, login and see the auto rotation working.
- Auto-Rotation wiki article on PostmarketOS Wiki https://wiki.postmarketos.org/wiki/Auto-rotation