如何以最简单的方式旋转显示屏?

我是枢轴监视器的幸运拥有者,可以旋转(物理)屏幕。 当我转动显示器时,最简单的显示方式是什么?

目前我首先启动“显示”应用程序,然后更改设置并确认。 但实际上这是一个非常费力的程序,因为我希望每分钟将我的方向切换到几次。

那么有这个或同等的指标吗? 我可以设置一个可以启动专用命令的键盘快捷键吗? 事实上,我正在考虑类似于Windows程序iRotate的东西。

进入键盘 – >快捷方式,选择“自定义快捷方式”,然后按“+”添加新快捷方式。

“名称”是动作的描述性名称(即“旋转监视器”)。 在“命令”中,键入要在激活快捷方式时运行的自定义命令。

快捷方式在列表中后,选择其行,按ENTER,然后选择要激活快捷方式的组合键。 如果存在冲突,快捷方式管理器会告诉您,您可以选择其他组合。

您可以使用快捷方式启用旋转显示,使用另一个快捷方式将其恢复到垂直位置。 如果你足够了解,你甚至可以编写一个维持状态的命令,只需在直立/旋转之间切换。

现在,至于你需要使用的命令,它可能是xrandr:

xrandr --output HDMI1 --rotate left xrandr --output HDMI1 --rotate normal 

输出参数取决于显示器插入的端口。 要查看您当前拥有的内容,请键入:

 xrandr -q 

我说:

 Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192 LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 309mm x 174mm 1366x768 60.0*+ 1360x768 59.8 60.0 1024x768 60.0 800x600 60.3 56.2 640x480 59.9 VGA2 disconnected (normal left inverted right x axis y axis) HDMI1 disconnected (normal left inverted right x axis y axis) DP1 disconnected (normal left inverted right x axis y axis) 

在这种情况下,我的–output将是LVDS1,因为所有其他都断开连接。

非常适合

 xrandr --output LVDS1 --rotate left xrandr --output LVDS1 --rotate right xrandr --output LVDS1 --rotate inverted xrandr --output LVDS1 --rotate normal 

以下是基于传感器输入如何执行此操作的一个很好的示例: https : //linuxappfinder.com/blog/auto_screen_rotation_in_ubuntu

所以基本上尝试上面的方法来识别你想看到旋转的屏幕。 根据型号监视器,可能有传感器发送信号?

这对于带有内置旋转传感器的联想Yoga 2 11非常有效,它也会移动统一底座。

剧本:

 #!/bin/sh # 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 eDP1 --rotate normal && gsettings set com.canonical.Unity.Launcher launcher-position Left ;; bottom-up) xrandr --output eDP1 --rotate inverted && gsettings set com.canonical.Unity.Launcher launcher-position Left ;; right-up) xrandr --output eDP1 --rotate right && gsettings set com.canonical.Unity.Launcher launcher-position Bottom ;; left-up) xrandr --output eDP1 --rotate left && gsettings set com.canonical.Unity.Launcher launcher-position Bottom ;; esac done 

和传感器的先决条件:

 sudo apt install iio-sensor-proxy inotify-tools 

我写了一个shell脚本来做这件事。 (需要xrandr grep awk)

 #!/bin/sh # invert_screen copyright 20170516 alexx MIT Licence ver 1.0 orientation=$(xrandr -q|grep -v dis|grep connected|awk '{print $4}') display=$(xrandr -q|grep -v dis|grep connected|awk '{print $1}') if [ "$orientation" == "inverted" ]; then xrandr --output $display --rotate normal else xrandr --output $display --rotate inverted fi 

如果你喜欢单行:

 [ "$(xrandr -q|grep -v dis|grep con|awk '{print $4}')" == 'inverted' ] && xrandr -o normal || xrandr -o inverted