[solved] Auto rotate screen do not work

I recently installed Mabox on the Tablet PC which has the display rotation and touch functions.
How I set it up:
1st

$ udevadm info -n /dev/iio:device0
P: /devices/platform/80860F41:02/i2c-2/i2c-SMO8500:00/iio:device0
M: iio:device0
R: 0
U: iio
T: iio_device
D: c 237:0
N: iio:device0
L: 0
E: DEVPATH=/devices/platform/80860F41:02/i2c-2/i2c-SMO8500:00/iio:device0
E: DEVNAME=/dev/iio:device0
E: DEVTYPE=iio_device
E: MAJOR=237
E: MINOR=0
E: SUBSYSTEM=iio
E: USEC_INITIALIZED=8793512
E: ACCEL_MOUNT_MATRIX=-1,0,0;0,1,0;0,0,1
E: IIO_SENSOR_PROXY_TYPE=iio-poll-accel iio-buffer-accel
E: SYSTEMD_WANTS=iio-sensor-proxy.service
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:

2st

$ sudo dmidecode | grep Manufacture
[sudo] senha para utherbone: 
	Manufacturer: Digibras
	Manufacturer: Digibras
	Manufacturer: Digibras
	Manufacturer: A1_Manufacturer0
	Manufacturer: Intel

3st

$ sudo dmidecode | grep Product
	Product Name: F10-30
	Product Name: F10-30

4st

$ cd /lib/udev/hwdb.d
$ /lib/udev/hwdb.d $

5st

$ sudo nano 61-sensor-local.hwdb
sensor:modalias:acpi:SMO8500*:dmi*:svnDigibras*:pnF10-30:*
 ACCEL_MOUNT_MATRIX=-1,0,0;0,1,0;0,0,1

6st

$ sudo udevadm trigger -v -p DEVNAME=/dev/iio:device0

7st

$ sudo systemd-hwdb update

8st

$ sudo pacman -S iio-sensor-proxy

9st

$ sudo systemctl enable iio-sensor-proxy.service

10st

$ sudo reboot

11st

$ sudo systemctl status iio-sensor-proxy
â—Ź iio-sensor-proxy.service - IIO Sensor Proxy service
     Loaded: loaded (/usr/lib/systemd/system/iio-sensor-proxy.service; static)
     Active: active (running) since Sat 2023-11-11 22:41:51 -04; 14min ago
   Main PID: 389 (iio-sensor-prox)
      Tasks: 4 (limit: 1056)
     Memory: 1.2M
        CPU: 312ms
     CGroup: /system.slice/iio-sensor-proxy.service
             └─389 /usr/lib/iio-sensor-proxy

nov 11 22:41:51 utherbone-f1030 systemd[1]: Starting IIO Sensor Proxy service...
nov 11 22:41:51 utherbone-f1030 systemd[1]: Started IIO Sensor Proxy service.
nov 11 22:41:52 utherbone-f1030 iio-sensor-prox[389]: Could not find trigger name associated with /sys/devices/platform/80860F41:02/i2c-2/i2c-SMO8500:00/iio:device0

12st

$ monitor-sensor
    Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared
=== Has accelerometer (orientation: undefined)
=== No ambient light sensor
=== No proximity sensor
    Accelerometer orientation changed: normal
    Accelerometer orientation changed: right-up
    Accelerometer orientation changed: normal
    Accelerometer orientation changed: left-up
    Accelerometer orientation changed: normal
    Accelerometer orientation changed: bottom-up
    Accelerometer orientation changed: normal
^C

As you can see in step 12 I tested the sensor and it is correct. What I need is for the screen to rotate because I use it at university to present some graphs and articles at meetings, and the rotation function is very much needed. I’d really appreciate it if someone could help me.

NOTE: there is a part when checking sensor status it spits out that there is no trigger name associated with this device.

Source: Regression: display autorotation not working after updating from iio-sensor-proxy-3.0-1 to iio-sensor-proxy-3.3-1 · Issue #409 · dreemurrs-embedded/Pine64-Arch · GitHub

Can you try the solution suggested in the last comment?

==
For anybody who wants a temporary fix until iio-sensor-proxy v3.5 is released just delay iio-sensor-proxy by adding ExecStartPre= /bin/sleep 1 to
/usr/lib/systemd/system/iio-sensor-proxy.service on the line above ExecStart=

If that does not work, we could just try to write a script to change orientation using xrandr

Doe this rotates the screen?

xrandr -o left

If it does, reset it with

xrandr -o normal

@sng writed … Can you try the solution suggested in the last comment?..

this is me iio-sensor… file for .service

[Unit]
Description=IIO Sensor Proxy service

[Service]
Type=dbus
BusName=net.hadess.SensorProxy
ExecStartPre=/usr/bin/sleep 1
ExecStart=/usr/bin/iio-sensor-proxy
#Uncomment this to enable debug
#Environment="G_MESSAGES_DEBUG=all"

# Lockdown
ProtectSystem=true
ProtectControlGroups=true
ProtectHome=true
ProtectKernelModules=true
PrivateTmp=true
PrivateNetwork=true
MemoryDenyWriteExecute=true
RestrictRealtime=true

Do not Work

@sng writed
If that does not work, we could just try to write a script to change orientation using xrandr Doe this rotates the screen?

Yes this command using xrandr is working.

I thought a script would do the trick in loop while, if you have a way of extracting what the monitor-sensor shows when you rotate the device.

NOTE: I tried using TimeoutStartSec= and do not work

ok, here’s a simple script
Mind you, I haven’t tested it (I do not have a tablet pc), I just hope it works ok

If it does not, we will have to debug it together…

Save it to a file, and execute

chmod +x file
./file

and rotate your Tablet :wink:

#!/bin/bash

# configuration
GREP_STRING="orientation changed:"
ORIENTATIONS=("normal" "left-up" "right-up" "bottom-up" "inverted")

# execution
monitor-sensor | while read line
do
    if [[ "$line"  == *"$GREP_STRING"* ]]
    then
        for key in "${ORIENTATIONS[@]}"
        do
            if [[ "$line" == *"$key" ]]
            then
                xranrd -o "${key/-up}"
                break
            fi
        done
    fi
done

Hello, thank you very much. your shellscrit code was very useful, almost everything works except the inverted scream that does not recognize this “bottom” in the xrandr command. I just needed to understand the logic and made an if for when $key is equal to “bottom-up” and execute the xrandr command with the argument -o $key2 which is equal to “inverted”.

#!/bin/bash

# configuration
GREP_STRING="orientation changed:"
ORIENTATIONS=("normal" "left-up" "right-up" "bottom-up")
key2="inverted"

# execution
monitor-sensor | while read line
do
    if [[ "$line" == *"$GREP_STRING"* ]]
    then
        for key in "${ORIENTATIONS[@]}"
        do
            if [[ "$line" == *"$key"* ]]
            then
                if [[ "$key" == *"bottom-up"* ]]
                then
					echo $key2
                    xrandr -o "$key2"
					break
                else
					xrandr -o "${key/-up}"
					break
				fi
            fi
        done
    fi
done

Two more thing, I don’t know anything about ShellScript, so I’m curious why you use the “*” before the string?

How can I make the script start after the kernel, so that it has already started before the light-dm login screen?

Thank you very much indeed. I’m going to publish this on my personal website so that more people have access to the script.

The [[ "$key" == *"bottom-up"* ]] statement means “if the substring bottom-up is anywhere in the key variable, do this”. This would work too: [[ "$key" == *"bottom-up" ]] (if the substring bottom-up is at the end of the key variable, do this.

Just a simple google search :wink:

For example:

You may have to provide the full path for monitor-sensor, though…

I am glad!

Many thanks for the replies, I thought this was very specific about getting started with light-dm, apparently not, and I thought it would be nice to be able to use your configuration file to run scripts.

The Topic has solved!