-
-
Save oswaldo/cd4d83905d846322f317e2de91342bda to your computer and use it in GitHub Desktop.
Automatically setup external monitors
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
""" | |
Automatically setup external monitors so that it's to the right of the | |
internal screen | |
Prerequisite: [displayplacer](https://github.com/jakehilborn/displayplacer) | |
```bash | |
brew tap jakehilborn/jakehilborn && brew install displayplacer | |
``` | |
""" | |
import subprocess | |
if __name__ == '__main__': | |
internal_screen = subprocess.run("""displayplacer list | grep -B 2 "MacBook built in screen" | grep "Persistent screen id" | awk -F": " '{print $NF}'""", shell=True, capture_output=True, text=True).stdout.strip() | |
external_screen = subprocess.run("""displayplacer list | grep -B 2 "27 inch external" | grep "Persistent screen id" | awk -F": " '{print $NF}'""", shell=True, capture_output=True, text=True).stdout.strip() | |
displayplacer_command = f"""displayplacer "id:{internal_screen} res:1728x1117 scaling:on origin:(0,0) degree:0" "id:{external_screen} res:2560x1440 scaling:on origin:(1729,0) degree:0" """ | |
subprocess.run(displayplacer_command, shell=True, capture_output=True, text=True, check=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment