搭载 15.04 (Gnome) 的 Dell 13 7000 自动旋转屏幕

搭载 15.04 (Gnome) 的 Dell 13 7000 自动旋转屏幕

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

答案1

编辑:我知道这并不能直接回答你的问题,因为我们有不同的电脑并且你对 Gnome 感兴趣,但我想将其发布到某处以帮助其他人。

以下内容适用于 Spectre x360 (Kaby Lake) 上的 Ubuntu 16.10 (Unity)。我怀疑类似的处理方法也适用于其他笔记本电脑。

按照@Yalokly的回答,安装iio-sensor-proxy

sudo apt-get install iio-sensor-proxy

这可能很难启动。如果在运行时monitor-sensor旋转设备时出现问题,则表明它正在运行。这里是您可以找到一些故障排除信息的存储库。我遇到了一些麻烦。将我的内核从 4.8 更新到 4.10 对我来说是有效的。在线搜索教程。像许多其他人一样,我遇到了一个错误,即传感器监控仅在计算机至少挂起一次后才起作用。

Unity 本身不具备自动旋转和平板模式的功能。我结合了以下脚本:这里这里以便:

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

脚本如下:

#!/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),然后将其添加到启动应用程序

答案2

这个软件据报道,它可以在许多二合一设备上使用。但您必须运行最新的内核和 gnome。

答案3

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

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

感谢@Ian Hincks 提供的代码!

答案4

我在用着自动旋转

它可以手动或自动旋转屏幕和数字化仪。有一个选项可以让 systemd 守护进程在后台运行它。

相关内容