Dell 13 7000上的自动旋转屏幕,带15.04(Gnome)

Gnome似乎非常适合支持触控的设备,当我翻转笔记本电脑/平板电脑时,有没有办法自动旋转屏幕?

据报道, 该软件适用于许多二合一设备。 但是你必须运行最新的内核和gnome。

编辑:我知道这不能直接回答你的问题,因为我们有不同的计算机而你对Gnome很感兴趣,但我想把它发布到某个地方来帮助别人。

以下是在Spectre x360(Kaby Lake)上为Ubuntu 16.10(Unity)工作的。 我怀疑类似的治疗应该适用于其他笔记本电脑。

在@ Yalokly的回答中,安装iio iio-sensor-proxy

 sudo apt-get install iio-sensor-proxy 

这可能是一群蠕虫可以开始工作。 你知道当你在旋转设备时运行monitor-sensor时会发生这种情况。 这是您可能会在其中找到一些故障排除信息的仓库。 我遇到了一些麻烦。 将我的内核从4.8更新到4.10对我有用。 在线搜索教程。 像许多其他人一样,我有一个错误,传感器监控仅在计算机暂停至少恢复一次后才能工作。

Unity不会自行执行自动旋转和平板电脑模式。 我从这里和这里组合了脚本,以便:

  1. 屏幕自动旋转
  2. 键盘和触控板仅在笔记本电脑正常导向时才起作用; 在其他三个方向禁用
  3. Unity启动器位于底部,用于纵向方向,并保留为横向方向
  4. onboard程序以三个“平板电脑”方向启动,并因“笔记本电脑”方向而被杀死(额外:我发现在板载首选项中启用文本模式下的自动弹出function有帮助)

这是脚本:

 #!/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 

注意:我的屏幕称为eDP-1 ,您的屏幕可能被称为不同的屏幕。 运行xrandr以查找名称,并更改上述脚本中的四个实例。

将其保存为auto-rotate.sh ,使其可执行( chmod a+x auto-rotate.sh ),并将其添加到Startup Applications

我使用过@Ian Hincks代码,但是我有一点建议让它有用。 我有戴尔Inspiron 13 7000系列,这台机器有一个光传感器来平衡背光亮。 我不得不修改“方向”线的构建,因为光传感器的变化是快速的并且污染了捕获的方向。 然后我通过一行方向接收三个光变化。 如果我只捕获一行日志,则会松开方向线。 这就是为什么我将日志捕获增加到4行,并将grep正则表达式更改为捕获最后一个方向。 然后,新的ORIENTATION行将是:

 ORIENTATION=$(tail -n 4 sensor.log | grep 'orientation' | grep -oEm 1 '[^ ]+$') 

谢谢@Ian Hincks的代码!