Skip to content

Instantly share code, notes, and snippets.

@kdarkhan
Created June 1, 2018 05:49
Embed
What would you like to do?
HiDPI display with not so HiDPI external monitor
export DISPLAY=:0
disp=eDP-1
disp2=HDMI-1
function connect(){
# echo 'connect'
# sleep 2
xrandr > /dev/null
# xrandr --output "$disp2" --right-of "$disp"
# xrandr --output "$disp" --mode 2048x1152 --dpi 151 --output "$disp2" --auto --right-of "$disp"
xrandr --output "$disp" --auto --dpi 283 --output "$disp2" --scale 2x2 --mode 1920x1080 --right-of "$disp"
cur=$(xrandr | pcregrep -o1 "current (\w+ x \w+)")
notify-send "Resolution with $disp2 is $cur"
}
function disconnect(){
# sleep 2
# echo 'disconnect'
xrandr > /dev/null
# xrandr --output "$disp2" --off --output "disp" --mode 2048x1152 --dpi 151
xrandr --output "$disp" --auto --dpi 283 --output "$disp2" --off
# xrandr --output "disp2" --off
cur=$(xrandr | pcregrep -o1 "current (\w+ x \w+)")
notify-send "Resolution without $disp2 is $cur"
}
xrandr | grep "$disp2 connected" &> /dev/null && connect || disconnect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment