Screen rotates after closing HP laptop's lid with Ubuntu 18.04.2
I have checked other posts about randomly rotating screens, and screens that rotate after sleep. I have tried the following to no avail:
-
Lock screen rotation:
Problem persists.
-
Disable GNOME orientation plugin:
gsettings set org.gnome.settings-daemon.plugins.orientation active false
Problem persists.
-
Disable/Uninstall
iio-sensor-proxy
:sudo systemctl stop iio-sensor-proxy.service sudo systemctl disable iio-sensor-proxy.service sudo apt-get remove iio-sensor-proxy
Problem persists.
Every time I close the lid, the laptop wakes up sideways and I have to run:
xrandr -o normal
Is there a bug somewhere? Have I missed something?
How can I make xrandr -o normal
run every time the laptop wakes from suspend? Maybe a hackish solution, but it might work, right?
Solution 1:
I don't know if what you describe is a bug, but you can run xrandr -o normal
at wake-up from suspend by doing the following (based on this answer and the comment below it):
-
Create a shell script named
xrandr_normal.sh
(you can use another name if you wish) that runs yourxrandr
command:nano /path/to/script/xrandr_normal.sh
Put the following inside:
#!/bin/bash DISPLAY=:0.0 ; export DISPLAY xrandr -o normal
-
Give execution rights to your script:
chmod u+x /path/to/script/xrandr_normal.sh
-
Create a service file that will run your script after suspend (you can use whatever name you wish for the service file):
sudo nano /etc/systemd/system/xrandr_normal.service
Put the following inside:
[Unit] Description=Some description Before=sleep.target StopWhenUnneeded=yes [Service] User=YOUR_USERNAME Type=oneshot RemainAfterExit=yes ExecStop=/path/to/script/xrandr_normal.sh [Install] WantedBy=sleep.target
Make sure to replace
YOUR_USERNAME
in the first line below[Service]
with your actual username and put the correct path to your script inExecStop
. -
Enable the service you created:
sudo systemctl enable xrandr_normal
-
Start the service:
sudo systemctl start xrandr_normal
-
As the author of the answer that this one is based on suggests, you can check for errors if the service does not work after suspend with the following command:
journalctl -u xrandr_normal.service