arnaucube
arnaucube/configsPublic Self-hosted repository
configs/bin/screens
bin/screensRaw
 1#!/usr/bin/env python3
 2
 3import os
 4import subprocess
 5import sys
 6
 7print(sys.argv[1])
 8
 9setup = sys.argv[1]
10
11subprocess.run(["xrandr", "--auto"])
12
13d = os.popen("xrandr --listmonitors | grep '+' | awk {'print $4'}").read().splitlines()
14print(d[1])
15
16pos = "--above"
17if setup == "h":
18    pos="--right-of"
19elif setup == "ih":
20    pos="--left-of"
21elif setup == "v":
22    pos="--above"
23elif setup=="mirror":
24    pos="--same-as"
25
26subprocess.run(["xrandr", "--output", d[1], pos, "eDP-1"])
27
28if len(sys.argv)>2:
29    if sys.argv[2] == "4k":
30        print("4k")
31        # xrandr --output HDMI-2 --mode 3840x2160
32        subprocess.run(["xrandr", "--output", d[1], "--mode", "3840x2160"])
33
34        # restart i3 status bar to avoid being frozen
35        subprocess.run(["i3-msg", "restart"])
36
37
38
39
40
41# for fixing touch screen
42# Check the input device ID with `xinput`.
43# Check the display device name with `xrandr`.
44#
45# `xinput map-to-output <ID> <NAME>`
46# eg. xinput map-to-output 12 eDP-1
47#
48# to rotate (90 degrees to right) the input of the touchscreen:
49# `xinput set-prop 'pointer:Goodix Capacitive TouchScreen' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1`