Gnome seems very suited for touch enabled devices, is there a way to auto rotate the screen when I flip the laptop/tablet?
Edit: I know this doesn't answer your question directly since we have different computers and you are interested in Gnome, but I wanted to post this somewhere to help others.
The following worked for me for Ubuntu 16.10 (Unity) on a Spectre x360 (Kaby Lake). I suspect a similar treatment should work for other laptops.
As in @Yalokly's answer, install
sudo apt-get install iio-sensor-proxy
This can be a can of worms to get working. You know it's working if when you run
monitor-sensor stuff happens when you rotate your device. Here is the repo where you might find some troubleshooting info. I had some trouble getting it going. Updating my kernel from 4.8 to 4.10 worked for me. Search for a tutorial online. Like many others, I have the bug where sensor monitoring only works after the computer has been suspended-resumed at least once.
- Screen rotates automatically
- Keyboard and trackpad only work when laptop is normally oriented; disabled in the other three orientations
- Unity launcher is placed at the bottom for portrait orientations, and left for landscape orientations
onboardprogram is started in the three 'tablet' orientations and killed for the 'laptop' orientation (extra: I found it helpful to enable auto-popup in text mode in the onboard preferences)
Here is the script:
#!/bin/sh # IH: this script is taken from a combo of: # https://linuxappfinder.com/blog/auto_screen_rotation_in_ubuntu # https://askubuntu.com/questions/757900/hp-spectre-x360-disable-touchpad-in-tablet-mode-ubuntu-15-10 # Auto rotate screen based on device orientation # Receives input from monitor-sensor (part of iio-sensor-proxy package) # Screen orientation and launcher location is set based upon accelerometer position # Launcher will be on the left in a landscape orientation and on the bottom in a portrait orientation # This script should be added to startup applications for the user # Clear sensor.log so it doesn't get too long over time > sensor.log # Launch monitor-sensor and store the output in a variable that can be parsed by the rest of the script monitor-sensor >> sensor.log 2>&1 & # Parse output or monitor sensor to get the new orientation whenever the log file is updated # Possibles are: normal, bottom-up, right-up, left-up # Light data will be ignored while inotifywait -e modify sensor.log; do # Read the last line that was added to the file and get the orientation ORIENTATION=$(tail -n 1 sensor.log | grep 'orientation' | grep -oE '[^ ]+$') # Set the actions to be taken for each possible orientation case "$ORIENTATION" in normal) xrandr --output eDP-1 --rotate normal gsettings set com.canonical.Unity.Launcher launcher-position Left xinput set-int-prop 12 "Device Enabled" 8 1 #Enable Keyboard xinput set-int-prop 13 "Device Enabled" 8 1 #Enable Pad killall onboard ;; bottom-up) xrandr --output eDP-1 --rotate inverted gsettings set com.canonical.Unity.Launcher launcher-position Left xinput set-int-prop 12 "Device Enabled" 8 0 #Disable Keyboard xinput set-int-prop 13 "Device Enabled" 8 0 #Disable Pad onboard & ;; right-up) xrandr --output eDP-1 --rotate right gsettings set com.canonical.Unity.Launcher launcher-position Bottom xinput set-int-prop 12 "Device Enabled" 8 0 #Disable Keyboard xinput set-int-prop 13 "Device Enabled" 8 0 #Disable Pad onboard & ;; left-up) xrandr --output eDP-1 --rotate left gsettings set com.canonical.Unity.Launcher launcher-position Bottom xinput set-int-prop 12 "Device Enabled" 8 0 #Disable Keyboard xinput set-int-prop 13 "Device Enabled" 8 0 #Disable Pad onboard & ;; esac done
Note: My screen is called
eDP-1, yours may be called something different. Run
xrandr to find out the name, and change the four instances in the above script.
Save this somewhere as
auto-rotate.sh, make it executable (
chmod a+x auto-rotate.sh), and add it to Startup Applications.
This software was reported to work on many 2-in-1 devices. But you have to run the latest kernel and gnome.
I have used @Ian Hincks code, but I have a little suggestion for do it useful. I have a Dell Inspiron 13 7000 series, and this machine has a Light sensor to balance the backlight bright. I had to modify the build of "orientation" line, because the light sensor changes are quicks and contaminates the orientation captured. Then I receive three light changes,by one line of orientation. If I capture only one line of the log, I loose the orientation line. This is why I have increased the log capture to 4 lines, and changed the grep regex to capture last orientation. Then, the new ORIENTATION line will be:
ORIENTATION=$(tail -n 4 sensor.log | grep 'orientation' | grep -oEm 1 '[^ ]+$')
Thank you @Ian Hincks for your code!