Skip to content

Instantly share code, notes, and snippets.

@lanceliao
Created September 27, 2015 03:01
Show Gist options
  • Save lanceliao/c11a96eb9c24857d66bd to your computer and use it in GitHub Desktop.
Save lanceliao/c11a96eb9c24857d66bd to your computer and use it in GitHub Desktop.
set different scaling on an extend screen, this script is expected to solve the scaling problem on HiDPI screens of Linux
#!/bin/bash
#
# extend second screen with different scaling
#
# Copyright (C) 2015 http://www.shuyz.com
# REF: 1. http://blog.jamiek.it/2015/04/manually-fixing-multiple-screens-with.html
# 2. https://bbs.archlinux.org/viewtopic.php?id=118999
# 3. http://unix.stackexchange.com/questions/101809/how-can-i-automatically-update-my-monitor-layout-in-xfce
has_dp2=$(xrandr -q | grep "DP2 connected")
if [ -z "$has_dp2" ]; then
exit 0
fi
# scale:
# 1920/1440 = 1.33
# 1080/900 = 1.2
# mirror
#xrandr --output DP2 --scale 1.33x1.2 --mode 1440x900 --pos 0x0
#xrandr --output eDP1 --scale 1x1 --pos 0x0
# extend horizonly
#fb:
# x:1920 + 1440x1.33 +1 = 3836
# y:1080 = 900x1.2
#second screen on right
#bug: mouse is limitted by invisible border on second screen
#xrandr --output DP2 --scale 1.33x1.2 --mode 1440x900 --fb 3836x1080 --pos 1920x0
#xrandr --output eDP1 --scale 1x1 --pos 0x0
#second screen on left
#xrandr --output DP2 --scale 1.33x1.2 --mode 1440x900 --fb 3836x1080 --pos 0x0
#xrandr --output eDP1 --scale 1x1 --pos 1915x0
#extend veritically
#fb:
# x: MAX(1920, 1440x1.33) = 1920
# y: 900x1.2+1080 = 2160
# second screen at top
#xrandr --output DP2 --scale 1.33x1.2 --mode 1440x900 --fb 1920x2160 --pos 0x0
#xrandr --output eDP1 --scale 1x1 --pos 0x1080
#second screen at bottom
#bug: mouse is limitted by invisible border on second screen
xrandr --output DP2 --scale 1.33x1.2 --mode 1440x900 --fb 1920x2160 --pos 0x1080
xrandr --output eDP1 --scale 1x1 --pos 0x0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment