Skip to content

Instantly share code, notes, and snippets.

@kdarkhan
Created June 1, 2018 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdarkhan/bc0e0a8d0002b2d6c86e6dee6cd9430b to your computer and use it in GitHub Desktop.
Save kdarkhan/bc0e0a8d0002b2d6c86e6dee6cd9430b to your computer and use it in GitHub Desktop.
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