Как я могу повернуть свой дисплей самым простым способом?

Я счастливый обладатель поворотного монитора, экран которого можно поворачивать (физически). Каков самый простой способ заставить мой дисплей поворачиваться, когда я поворачиваю свой монитор?

На данный момент я сначала запускаю приложение "Дисплеи", а затем меняю настройки и подтверждаю. Но на самом деле это довольно трудоемкая процедура, так как я хочу переключать ориентацию до нескольких раз в минуту.

Итак, есть ли для этого индикатор или эквивалент? Могу ли я установить сочетание клавиш, которое запускало бы выделенную команду? На самом деле я думаю о чем-то похожем на программу Windows Иротат.

>Перейдите в раздел Сочетания клавиш, выберите "Пользовательские сочетания клавиш" и нажмите "+", чтобы добавить новый ярлык.

"Имя" - это описательное название действия (например, "Поворот монитора"). В поле "Команда" введите пользовательскую команду, которая будет выполняться при активации ярлыка.

Как только ярлык появится в списке, выберите его строку, нажмите ENTER, затем комбинацию клавиш, которую вы хотите активировать ярлык. Если возникнет конфликт, диспетчер ярлыков сообщит вам об этом, и вы сможете выбрать другую комбинацию.

У вас может быть ярлык, чтобы включить повернутый дисплей, а другой - чтобы вернуть его в вертикальное положение. Вы даже можете, если вы достаточно осведомлены, написать команду, которая поддерживает состояние и просто переключается между вертикальным / повернутым.

Теперь, что касается команды, которую вам нужно использовать, это, вероятно, xrandr:

xrandr --output HDMI1 --rotate leftxrandr --output HDMI1 --rotate normal

Выходной параметр зависит от того, к какому порту подключен ваш монитор. Чтобы увидеть, что у вас есть в данный момент, введите:

xrandr -q

Мой говорит:

Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192LVDS1 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 leftxrandr --output LVDS1 --rotate rightxrandr --output LVDS1 --rotate invertedxrandr --output LVDS1 --rotate normal

Вот хороший пример того, как это сделать на основе ввода датчика:https://linuxappfinder.com/blog/auto_screen_rotation_in_ubuntu

Итак, в основном попробуйте выполнить описанное выше, чтобы определить экран, который вы хотите видеть повернутым.В зависимости от модели монитора может быть датчик, который посылает сигнал?

Это хорошо работает для моего Lenovo Yoga 2 11 со встроенным датчиком поворота, и он также перемещает док-станцию unity.

Сценарий:

#!/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 scriptmonitor-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 ignoredwhile inotifywait -e modify sensor.log; do# Read the last line that was added to the file and get the orientationORIENTATION=$(tail -n 1 sensor.log | grep 'orientation' | grep -oE '[^ ]+$')# Set the actions to be taken for each possible orientationcase "$ORIENTATION" innormal)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 ;;esacdone

и предпосылка для датчиков:

sudo apt install iio-sensor-proxy inotify-tools

Я написал сценарий оболочки, чтобы сделать это. (Требуется xrandr grep awk)

#!/bin/sh# invert_screen copyright 20170516 alexx MIT Licence ver 1.0orientation=$(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 normalelse   xrandr --output $display --rotate invertedfi

Если вам нравятся однострочники:

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

Немного более простая вариация Ответ Винсента Герриса на основе входного сигнала датчика:

#!/bin/bash# Auto rotate screen based on device orientationmonitor-sensor | \while IFS= read -r str; do  if [[ $str =~ orientation\ changed:\ (.*)$ ]]; then    case "${BASH_REMATCH[1]}" in    normal)      xrandr --output eDP-1 --rotate normal ;;    bottom-up)      xrandr --output eDP-1 --rotate inverted ;;    right-up)      xrandr --output eDP-1 --rotate right ;;    left-up)      xrandr --output eDP-1 --rotate left ;;    esac  fidone

В дополнение к сценарию, размещенному в Ответ дерХуго, На Kubuntu 20.10, мне пришлось изменить его на {print $5} а также использовать bash вместо обычного sh. С этими незначительными изменениями мой сценарий гласит:

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