Bug 384066 - Auto-rotate screen not working for Accelerometer sensors
Summary: Auto-rotate screen not working for Accelerometer sensors
Alias: None
Product: KScreen
Classification: Plasma
Component: common (show other bugs)
Version: 5.10.5
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Sebastian Kügler
: 376349 396481 (view as bug list)
Depends on:
Blocks: 254563
  Show dependency treegraph
Reported: 2017-08-27 01:52 UTC by sac
Modified: 2021-06-14 01:02 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.18


Note You need to log in before you can comment on or make changes to this bug.
Description sac 2017-08-27 01:52:06 UTC
When the tablet / convertible is rotated Fedora 26 & Ubuntu 17.04 & 17.10 are automatically rotating the screen as well, which is not working in KDE :/

- Rotation is possible with iio-sensor-proxy (IIO sensors to D-Bus proxy, https://github.com/hadess/iio-sensor-proxy) that comes pre-shipped with Kubuntu & Neon.
- executing "monitor-sensor" generates proper d-bus messages ("Accelerometer orientation changed: left-up"), Yoga 900s tablet Kernel 4.11.12

"With gnome this is picked up by gnome-settings-daemon if I'm correct. How do I inform lightdm to use this information to auto-rotate the screen? Although it's definitely possible to run my own script to pull all the time for changes, I prefer to have it in an event loop that checks d-bus anyway, so I'm not suddenly creating some kind of battery drain."
Comment 1 Sebastian Kügler 2017-09-18 08:01:23 UTC
I'm working on a solution, but it's going a bit slow since I have a ton of other tasks. If you can help to speed it up, hit me up. (Involves writing C++ code.)
Comment 2 lpotter 2017-10-05 06:02:55 UTC
Note that QtSensors has a iio-sensor-proxy backend plugin since Qt 5.7.

As well, sensorfw also supports bio sensors. QtSensors also has a sensorfw backend.
Comment 3 lpotter 2017-10-05 06:03:59 UTC
I am willing to help, just not sure where to look in the sources.
Comment 4 Sebastian Kügler 2017-10-05 14:00:55 UTC
Hey Lorn, cool that you want to help us out! Here's some information that hopefully gets you started:

We have discussed a solution on the plasma list here: https://www.mail-archive.com/plasma-devel@kde.org/msg73143.html

Code can be found in the sebas/touchscreen branch of the libkscreen repository, it's currently only some test code, but overall it's not too much work I think, nevertheless, help is greatly appreciated. Feel free to email plasma-devel or catch us on IRC #plasma on Freenode if you have something you'd like discussed, asked, proposed.

Comment 5 sac 2018-05-26 23:43:05 UTC
Seen that the regular, manual rotation is possible now in the settings ;)

The solution on the plasma list from Martin relys on Wayland, will there also be an option for automatic screen rotation for xorg?
Comment 6 Nate Graham 2018-05-26 23:44:58 UTC
Martin has feature-frozen KWin for X11, so if it requires any X11-specific code, the answer is sadly no.
Comment 7 Nate Graham 2018-07-13 16:00:25 UTC
*** Bug 376349 has been marked as a duplicate of this bug. ***
Comment 8 Nate Graham 2018-07-13 16:00:29 UTC
*** Bug 396481 has been marked as a duplicate of this bug. ***
Comment 9 Marcin Migacz 2018-07-13 16:06:22 UTC
Hi guys,

The automated rotation of display dosen't work. On my laptop x360 hp. 
However i found this project for gnome:

And after compiling and installing and running:
they are recognized in terminal just fine.

1. where i can find configuration files of actual position of screen in my system? I asking because i want to change them using this driver.

2. It is possible to port that drivers to next release of kde ? :)
Comment 10 Marcin Migacz 2018-07-13 18:38:41 UTC
I fix it ! :D

here are the steps:

compile and install this drivers: https://github.com/hadess/iio-sensor-proxy

If they will be successfully installed then then command in terminal : 
should work, and show orientation of a screen in terminal.

and the last step is to make a script and execute it:


It should work :) 
Comment 11 Alexander Mentyu 2018-08-17 09:12:37 UTC
Autorotation works on Wayland with installed iio-sensor-proxy-git and kded-rotation-git packages from AUR for upside down position but not for 90 and 270 degrees position - related bug - https://bugs.kde.org/show_bug.cgi?id=389665

Distribution: Netrunner Rolling
Kernel: 4.17.12-1.1-MANJARO
Plasma: 5.13.4
Apps: 18.04.3
Qt: 5.11.1
Frameworks: 5.48.0
Wayland: 1.15.0
Graphics:  Card-1: Intel UHD Graphics 620 driver: i915 v: kernel bus ID: 00:02.0 
           chip ID: 8086:5917 
           Card-2: NVIDIA GM108M [GeForce 940MX] driver: nouveau v: kernel bus ID: 01:00.0 
           chip ID: 10de:134d 
           Display: wayland server: X.Org 1.19.6 driver: intel,nouveau unloaded: modesetting 
           alternate: fbdev,nv,vesa compositor: kwin wayland resolution: 1920x1080~57Hz 
           OpenGL: renderer: Mesa DRI Intel UHD Graphics 620 (Kabylake GT2) v: 4.5 Mesa 18.1.5 
           compat-v: 3.0 direct render: Yes
Comment 12 Nate Graham 2020-01-15 18:12:16 UTC
Support for this on Wayland just landed in Plama 5.18. Thanks Roman!
Comment 13 Parker Reed 2020-01-22 23:57:15 UTC
Since this didn't make it due to X11 freeze, will this be available for X11 in the hotfix after release?
Comment 14 Nate Graham 2020-01-23 02:06:00 UTC
There's effectively no longer an X11 feature freeze, so this could eventually make it to the X11 session too.
Comment 15 PGillespie 2021-06-13 20:36:41 UTC
Using Plasma 5.22 on a Surface GO and screen rotation isn't working.
Comment 16 PGillespie 2021-06-13 20:39:17 UTC
Also, screen rotation works fine on the Surface Go with Gnome. Not sure why this is marked "Resolved: Fixed" unless there's some setting I'm missing in Plasma?

System:    Host: NEON Kernel: 5.12.9-surface x86_64 bits: 64 Desktop: KDE Plasma 5.22.0 Distro: KDE neon 20.04 5.22 
Machine:   Type: Laptop System: Microsoft product: Surface Go v: 1 serial: <superuser/root required> 
           Mobo: Microsoft model: Surface Go serial: <superuser/root required> UEFI: Microsoft v: 1.1.20 date: 12/22/2020
Comment 17 sac 2021-06-13 21:37:36 UTC
You probably have to select table mode in the settings > monitor. Works great on my convertible ;)
Comment 18 PGillespie 2021-06-14 00:51:16 UTC
(In reply to sac from comment #17)
> You probably have to select table mode in the settings > monitor. Works
> great on my convertible ;)

Oh. That's weird. Just the opposite. If I deselect "tablet mode only", it works fine.

Obviously because I'm not "in tablet mode"? Where is "tablet mode"? Is that even a thing yet?

Curiously, if I search for "tablet" in settings, nothing comes up. Not even this "in tablet mode only" setting.

File another bug?
Comment 19 Nate Graham 2021-06-14 00:53:27 UTC
Tablet Mode is a thing that the Libinput driver detects based on sensors in your computer. I'm guessing that Libinput isn't detecting the condition properly.
Comment 20 PGillespie 2021-06-14 01:01:07 UTC
(In reply to Nate Graham from comment #19)
> Tablet Mode is a thing that the Libinput driver detects based on sensors in
> your computer. I'm guessing that Libinput isn't detecting the condition
> properly.

Okay. I get it. It's misleading if one comes from Windows because Windows has an actual "Tablet Mode". But the Plasma setting is referring to a hardware state, not a "software state".

I tested by re-activating the "tablet mode only" checkbox and removing the keyboard. Automatic rotation didn't work.

In my case, unchecking "tablet mode only" produces the desired results—the opposite of your advice, but it sent me in the right direction.
Comment 21 Nate Graham 2021-06-14 01:02:55 UTC
If auto-rotation doesn't work in "Tablet mode only", that means that Libinput is never detecting that your laptop is in tablet mode. If it actually is in tablet mode from your perspective, you should file a bug report on Libinput at https://gitlab.freedesktop.org/libinput/libinput/-/issues/.