command line - Script / Shortcut to switch display priority? - Ask Ubuntu
i wish have shortcut switches priority (i.e. primary, secondary) of displays (laptop + external).
ps: aware there's dedicated button/shortcut but, @ least mine, cycles through configurations (i.e. different resolutions). want cycle between 2 configurations only.
it turned out wrote it, part of this question. since another question, below outtake of one:
#!/usr/bin/env python3 import subprocess # set primary screen, set other 1 scr_data = subprocess.check_output(["xrandr"]).decode("utf-8").splitlines() scrs = [[l.split()[0], "primary" in l] l in scr_data if " connected" in l] screen in scrs: if not screen[1]: subprocess.popen(["xrandr", "--output", screen[0], "--primary"])
it toggles (switches between two) primary screen.
to use:
- copy script empty file, save
toggle_primary.py
add shortcut key: choose: system settings > "keyboard" > "shortcuts" > "custom shortcuts". click "+" , add command:
python3 /path/to/toggle_primary.py
Comments
Post a Comment