I've recently bought an HP Spectre x360 convertible laptop, and while everything worked perfectly out of the box in Linux (wifi, bluetooth, touchscreen...) there was just one thing that kept bugging me: the screen auto-rotation feature didn't work.
This meant that "tent mode" wasn't usable (not that I find it very useful, but still), but most importantly that when being held in "tablet mode" the screen remained in landscape view, even though portrait is usually a better fit for browsing the Internet or viewing documents in general (maybe even vertical videos?).
After searching for scripts to fix this on Internet and failing to get the few I found to work, I decided that writing my own would be the fastest solution. I used iio-sensor-proxy to get the inclination angles and xrandr to set the screen orientation.
The python script is actually very simple, it gets the screen's pitch and roll angles and compares them to see which orientation suits the current position better.
- If |y| < |x|-α :
- If x > 0 : Normal
- If x < 0 : Inverted
- If |y| > |x|+α :
- If y > 0 : Left
- If y < 0 : Right
There is a mode to make it run at startup, just like in Windows? In Windows, the login can rotate, also.
Hi, you can make it run at startup by adding it to the “Startup Applications” program or adding it to /etc/init.d.
I think doing the latter should allow you to rotate the login as well, although I have since reinstalled Ubuntu and autorotation now works out of the box, login included, so you could give that a try as well.
First, I want to say that I find this script simply Awesome! Thanks so much for writing it.
I have just received my x360 convertible so this is very cool.
Perhaps you can point me (and others) in the right direction for a few other items …
You mentioned that you reinstalled Ubuntu. What version and desktop did you install?
(I currently have Linux Mint 18.3 Cinnamon on mine and your script works nicely.)
Can you get a keyboard to pop up on the screen in order to type in a URL or do email in tablet mode?
My x360 came with a stylus from HP … have you used one (or heard about using one) in a linux environment?
One of the things I often find myself doing on my iPad is taking screen snapshots by pressing physical external buttons on the the tablet. Any ideas on how to do screen snapshots when the x360 is in tablet mode?
Thanks again!
Hi, thanks a lot! I really appreciate the feedback 🙂
As for the other questions:
– I installed Ubuntu 17.04 with the 4.12 kernel and Gnome 3.24. I chose Gnome because it offered the best touchscreen experience at the time, which I’m guessing it’s still the case.
-The keyboard pops up automatically when you click on a writable field on tablet mode, but you can make it appear at any time by swiping up from the bottom of the screen.
– I didn’t get the HP stylus but I have tried the Surface Pen (v3 I think) and it worked automatically without pairing. There is a test zone in Gnome’s settings specifically designed for styli where you can try yours. Moving the cursor on hover and pressing to change the thickness are also supported.
-In theory you should be able to detect a combination of button presses to trigger a screenshot, but it’s easier to just add the native screenshot app to the dock and click on it when needed. You can then capture the whole screen, just a window or a specific zone.
Hi, I am wondering which version of the 360 you are using? I am looking at buying the HP Pavilion x360 15.6 with i-5 8250U and having some confusion verifying that I can in fact install linux on it.
Hi, I have the HP Spectre x360 13t with an i7-7500U, but I don’t think that would matter very much, in my experience I’ve always been able to install linux in all the computers I’ve owned 🙂
Hi Thanks rotate works great, but need a bit of help please.
The screen rotate is great, but I can’t get the screen touch correct.
I tried removing the comment from the touch line. Not sure if I did the correct move.
# Enable touchpad rotation by uncommenting the following line.
touchpad = “SynPS/2 Synaptics TouchPad”he screen touch.
I was hoping thew above referred to the touch screen not the touch pad.
Below is the message I get in terminal.
oldkarew@oldkarew-HP-Spectre-x360-Convertible-13-ap0xxx:~/Downloads$ python ARS.py
unable to find device SynPS/2 Synaptics TouchPad
Traceback (most recent call last):
File “ARS.py”, line 46, in
‘Coordinate Transformation Matrix’] + transval.split())
File “/usr/lib/python2.7/subprocess.py”, line 190, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘xinput’, ‘set-prop’, ‘SynPS/2 Synaptics TouchPad’, ‘Coordinate Transformation Matrix’, ‘1’, ‘0’, ‘0’, ‘0’, ‘1’, ‘0’, ‘0’, ‘0’, ‘1’]’ returned non-zero exit status 1
oldkarew@oldkarew-HP-Spectre-x360-Convertible-13-ap0xxx:~/Downloads$
I’m running Dual Boot Ubuntu 18.04.2 with Win10 (Big problems with Win10 NOT shutting down correctly, Error 41)
If screen rotate with touch rotate can work for me, I’ll dump dual boot and just run Ubunto 18.04.2
Any help much appreciated.
Hi, I’m not sure I understand what you’re trying to do.
That line refers to the touchpad, so that the cursor moves with the same rotation as the screen (otherwise when the laptop is upside down the mouse goes up when you move your finger down, instead of up).
The problem is that the touchpad isn’t being found, please type “xinput list” to find the correct name for yours and replace it in the script. I also use Python3, I haven’t tested it with 2.7, just in case.
I’m just not sure what you mean with “can’t get the screen touch correct”
I make this script with work in HP-Spectre-x360-15-df0009nl on kubuntu 19.4
allows autorotation and OLED screen brightness change.
sounds amazing ! where can i download the script to try ?
thank you
Thanks! The code is in the GitHub repository, the link is just under the video