-
-
Save Legogris/f99c3728143bb0b164f7c8eee1f3f3e7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env runhaskell | |
| import System.Process (callCommand) | |
| runcmd args = | |
| putStrLn ("+ " ++ cmd) >> callCommand cmd | |
| where cmd = unwords args | |
| -- (Name of your laptop's internal display, x res, y res) | |
| (internalOutput, intX, intY) = ("eDP1", 3840, 2160) | |
| -- (Name of your external display, x res, y res) | |
| (externalOutput, extX, extY) = ("DP2", 3840, 2160) | |
| -- Coefficient to use when computing resolution for the virtual screen | |
| -- to scale down for your external display: | |
| scaleFactor = 1.75 | |
| (scaledExtX, scaledExtY) = (extX * scaleFactor, extY * scaleFactor) | |
| extScaleFrom = show (round scaledExtX) ++ "x" ++ show (round scaledExtY) | |
| internalPos = show (round scaledExtX) ++ "x" ++ show (round (scaledExtY - intY)) | |
| -- If your laptop has a touchscreen, put its xinput name here (from `xinput list`) | |
| touchXinputId = "ELAN\\ Touchscreen" | |
| main = do | |
| runcmd [ "xrandr", "--auto" ] | |
| runcmd [ "xrandr" | |
| , "--output", externalOutput | |
| , "--scale-from", extScaleFrom | |
| , "--pos", "0x0" | |
| , "--primary" | |
| , "--output", internalOutput | |
| , "--pos", internalPos | |
| ] | |
| runcmd [ "xinput", "map-to-output", touchXinputId, internalOutput ] | |
| -- Any other extra commands to run can go here, e.g. | |
| -- runcmd [ "feh", "~/.background-image", "--bg-scale" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment