У меня действительно раздражающая проблема с Ubuntu 18.04. Мой ноутбук оснащен 4-дюймовым 15-дюймовым дисплеем. Поскольку это делает все очень маленьким, я предпочитаю уменьшать его до 1080x1920 при использовании. На работе у меня есть настройка с двумя мониторами, оба подключены к небольшой док-станции / адаптеру, который я подключаю к своей машине с помощью thunderbolt 3. В настройках своего сервера Nvidia X я настроил двойные экраны так, чтобы они были рядом друг с другом, а экран ноутбука отключился. Теперь проблема.
Всякий раз, когда я отключаю эти дисплеи, экран моего ноутбука переворачивается. обратно с полным разрешением 4K. Если я захожу на Nvidia X Server, я могу снова изменить его на 1080. Но потом, когда я снова подключусь к своим двойным мониторам, настройка будет неправильной, и мне придется потратить 5 минут на перезагрузку и перенастроить все заново правильно.
Есть ли правильный способ исправить это? Есть ли способ автоматически изменять конфигурации дисплея или, возможно, с помощью горячей клавиши или чего-то еще?
Я использую все последние Обновления и драйвер Nvidia 430.
Вот вывод работающего xrandr
//Only on laptop screen(no external screen connected)
Screen 0: minimum 8 x 8, current 3840 x 2160, maximum 16384 x 16384
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 346mm x 194mm
3840x2160 60.00*+ 50.00 48.02
DP-4 disconnected (normal left inverted right x axis y axis)
DP-4.1 disconnected (normal left inverted right x axis y axis)
DP-4.2 disconnected (normal left inverted right x axis y axis)
//When Its connected to my dock, laptop screen disabled and two 1080 monitors.
Screen 0: minimum 8 x 8, current 3840 x 1080, maximum 16384 x 16384
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 connected (normal left inverted right x axis y axis)
3840x2160 60.00 + 50.00 48.02
DP-4 disconnected (normal left inverted right x axis y axis)
DP-4.1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm
1920x1080 60.00*+ 75.00 59.94 50.00
1680x1050 59.95
1600x1200 60.00
1600x900 60.00
1440x900 59.89
1280x1024 75.02 60.02
1280x800 59.81
1280x720 60.00 59.94 50.00
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x480 59.94
640x480 75.00 59.94 59.93
DP-4.2 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 527mm x 296mm
1920x1080 60.00*+ 75.00 59.94 50.00
1680x1050 59.95
1600x1200 60.00
1600x900 60.00
1440x900 59.89
1280x1024 75.02 60.02
1280x800 59.81
1280x720 60.00 59.94 50.00
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x480 59.94
640x480 75.00 59.94 59.93
Это кажется на необходимость в сценарии, который называет xrandr с режимом отображения, который Вы предпочитаете. Можно затем отобразить тот сценарий на горячую клавишу.
У меня была очень похожая проблема и после долгого исследования, я нашел этот ответ MestreLion. В нем они ссылаются на самодельный сценарий, который может быть найден на GitHub. Это копируется ниже по причине архива.
Можно просто скопировать вставку, что сценарий в файле назвал "монитор переключателя" с исполняемым разрешением активированным.
Принятие файла расположено в /home/<username>
можно запустить скрипт путем ввода:
/home/<username>/switch-monitor --list
Это даст Вам список подключенных мониторов и создаст файл конфигурации /home/.config/switch-monitor.conf
.
#!/bin/bash
#
# monitor-switch - switch outputs using xrand
#
# Copyright (C) 2012 Rodrigo Silva (MestreLion) <linux@rodrigosilva.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. See <http://www.gnu.org/licenses/gpl.html>
declare -A monitor_opts
declare -a monitors
myname="${0##*/}"
verbose=0
# Read settings from config file
config=${XDG_CONFIG_HOME:-"$HOME"/.config}/"$myname".conf
if [[ -f "$config" ]]; then
source "$config"
fi
print_monitors() {
while read -r output conn hex; do
echo "# $output $conn $(xxd -r -p <<<"$hex")"
done < <(xrandr --prop | awk '
!/^[ \t]/ {
if (output && hex) print output, conn, hex
output=$1
hex=""
}
/ConnectorType:/ {conn=$2}
/[:.]/ && h {
sub(/.*000000fc00/, "", hex)
hex = substr(hex, 0, 26) "0a"
sub(/0a.*/, "", hex)
h=0
}
h {sub(/[ \t]+/, ""); hex = hex $0}
/EDID.*:/ {h=1}')
}
# if there's no pre-defined monitors list, read from xrandr
# and save them to config file
if [[ -z "$monitors" ]]; then
while read -r output ; do
monitors+=("$output")
done < <(xrandr | awk '$2 ~/^c/{print $1}' | sort)
cat > "$config" <<-EOF
# $myname config file
# List of monitors, from left to right. Edit to your actual layout
monitors=(${monitors[@]})
# Extra xrandr options for each monitor.
# Useful when EDID data does not reflect actual preferred mode
# Options for non-existing outputs (such as the examples below) are ignored
# Examples:
monitor_opts[DFPx]="--mode 1920x1080 --rate 60"
monitor_opts[DFPy]="--mode 1280x720"
# As a reference, these were the connected monitors when this config file was created
# use it as a guide when editing the above monitors list and extra options
$(print_monitors)
# For an updated list, run $myname --list
EOF
fi
message() { printf "%s\n" "$1" >&2 ; }
fatal() { [[ "$1" ]] && message "$myname: error: $1" ; exit ${2:-1} ; }
argerr() { printf "%s: %s\n" "$myname" "${1:-error}" >&2 ; usage 1 ; }
invalid() { argerr "invalid argument: $1" ; }
missing() { argerr "missing ${2:+$2 }operand${1:+ from $1}." ; }
usage() {
cat <<-USAGE
Usage: $myname [options]
USAGE
if [[ "$1" ]] ; then
cat >&2 <<- USAGE
Try '$myname --help' for more information.
USAGE
exit 1
fi
cat <<-USAGE
Switch monitors using xrandr.
Options:
-h|--help - show this page.
-v|--verbose - print in terminal the full xrandr command executed.
-l|--list - list connector and monitor names of connected outputs
-a|--all - enable all monitors.
-s|--select OUTPUT - enable monitor OUTPUT, disable all others.
-l|--left - enable leftmost monitor. Alias for --select ${monitors[0]}
-r|--right - enable rightmost monitor. Alias for --select ${monitors[${#monitors[@]}-1]}
Copyright (C) 2012 Rodrigo Silva (MestreLion) <linux@rodrigosilva.com>
License: GPLv3 or later. See <http://www.gnu.org/licenses/gpl.html>
USAGE
exit 0
}
# Option handling
for arg in "$@"; do [[ "$arg" == "-h" || "$arg" == "--help" ]] && usage ; done
while (( $# )); do
case "$1" in
-v|--verbose) verbose=1 ;;
-q|--no-notify) notify=0 ;;
-l|--list) list=1 ;;
-a|--all) all=1 ;;
-s|--select) shift ; monitor="$1" ;;
-l|--left ) monitor="${monitors[0]}" ;;
-r|--right) monitor="${monitors[${#monitors[@]}-1]}" ;;
*) invalid "$1" ;;
esac
shift
done
if ((list)); then
echo "Connected monitors:"
print_monitors
exit
fi
if [[ -z "$monitor" && -z "$all" ]]; then
usage
fi
# Loop outputs (monitors)
for output in "${monitors[@]}"; do
if ((all)) || [[ "$output" = "$monitor" ]]; then
xrandropts+=(--output "$output" --auto ${monitor_opts["$output"]})
if ((all)); then
if [[ "$output" = "${monitors[0]}" ]]; then
xrandropts+=(--pos 0x0 --primary)
else
xrandropts+=(--right-of "$previous")
fi
previous="$output"
else
xrandropts+=(--primary)
fi
else
xrandropts+=(--output "$output" --off)
fi
done
((verbose)) && message "$myname: executing xrandr ${xrandropts[*]}"
xrandr "${xrandropts[@]}"
Откройте файл конфигурации, созданный выше /home/.config/switch-monitor.conf
.
# List of monitors, from left to right. Edit to your actual layout
monitors=(<list of monitors>)
# Extra xrandr options for each monitor.
# Useful when EDID data does not reflect actual preferred mode
# Options for non-existing outputs (such as the examples below) are ignored
# Examples:
monitor_opts[DFPx]="--mode 1920x1080 --rate 60"
monitor_opts[DFPy]="--mode 1280x720"
В нем можно изменить физическое расположение дисплеев для отражения установки, и можно определить режимы, которые Вы хотите. Таким образом в Вашем случае необходимо изменить его как так:
# List of monitors, from left to right. Edit to your actual layout
monitors=(DP-4.1 DP-4.2 DP-3)
# Extra xrandr options for each monitor.
# Useful when EDID data does not reflect actual preferred mode
# Options for non-existing outputs (such as the examples below) are ignored
# Examples:
monitor_opts[DP-4.1]="--primary --mode 1920x1080 --rate 60"
monitor_opts[DP-4.2]="--mode 1280x720 --rate 60"
monitor_opts[DP-3]="--mode 1920x1080 --rate 60"
Просто выполните эту процедуру для добавления ярлыка. В command
поле необходимо зарегистрироваться:
/home/<username>/switch-monitor --all
Это присоединится ко всем Вашим мониторам с данными опциями, которые были зарегистрированы в файле конфигурации.
Надежда это помогает :)