Created
April 27, 2018 12:22
-
-
Save wzin/6d52adf6d80f5fcb7d62e72b6ba5488b to your computer and use it in GitHub Desktop.
Automatic-scaling setup for Ubuntu with dual monitor setup (hidpi + nonhidpi) : QHD+ 3200x1800 and a FullHD 1920x1080
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The script: | |
#!/bin/bash | |
# eDP-1 connected primary 3200x1800+320+2160 (normal left inverted right x axis y axis) 294mm x 165mm | |
# DP-1 connected 3840x2160+0+0 (normal left inverted right x axis y axis) 521mm x 293mm | |
xhost + | |
export DISPLAY=:1 | |
export XAUTHORITY=$(ps -C Xorg -f --no-header | sed -n 's/.*-auth //; s/ -[^ ].*//; p' | tail -1) | |
function dp_connected() { | |
if xrandr | grep -w connected | awk {'print $1'} | grep -w "$1" >/dev/null ; then | |
echo "true" | |
else | |
echo "false" | |
fi | |
} | |
edp1_connected=$(dp_connected eDP1) | |
dp1_connected=$(dp_connected DP1) | |
echo "eDP1 connected $edp1_connected" | |
echo "DP1 connected $dp1_connected" | |
xrandr_command="xrandr --output 'eDP1' --auto --pos 320x2160 --panning 3200x1800+320+2160 --scale 1x1" | |
if [[ "$dp1_connected" == "true" ]];then | |
echo "DP1 connected" | |
xrandr_command="$xrandr_command --output 'DP1' --auto --scale 2x2 --pos 0x0 --panning 3840x2160+0+0" | |
fi | |
echo "Xrandr command: $xrandr_command" | |
eval $xrandr_command | |
#ALTERNATIVE CRTC (changed in kernel 4.15 or so) xrandr --output "eDP-1" --auto --pos 320x2160 --panning 3200x1800+320+2160 --scale 1x1 --output "DP-1" --auto --scale 2x2 --pos 0x0 --panning 3840x2160+0+0 | |
Plug the script into udev so everytime you connect/disconnect USBc-hdmi converter, the script will rearrange the screens so you get proper font sizes et al: | |
ACTION=="change", SUBSYSTEM=="drm", RUN+="/home/wojtek/bin/xrandr.bash" | |
Drop the script into /etc/udev/rules.d/fullhd-hidpi-monitor.rules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment