-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor
executable file
·59 lines (47 loc) · 1.62 KB
/
monitor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python3
#########################################
# ONLY FOR DUAL MONITOR SETUPS #
# Set config directory for custom usage #
# Author: Elagoht #
#########################################
# requirements
from os import system,popen
# config directory
dir=popen("echo $HOME").read().strip()+"/.config/i3/"
# get monitors
monitors=[i.split()[0] for i in popen("xrandr | grep ' connected'").read().strip().split("\n")]
monitors.remove(popen("xrandr | grep 'primary'").read().split()[0])
monitors=[popen("xrandr | grep 'primary'").read().split()[0]]+monitors
# load settings
with open(dir+"monitor.conf","r") as conf: mode=conf.readline()
if mode=="": mode="0"
try: mode=int(mode)
except: mode=0
# change mode
mode+=1
if mode>4 or mode<0: mode=0
if len(monitors)<2: mode=3
# mirror
if mode==0:
system(f"xrandr --output {monitors[0]} --auto")
system(f"xrandr --output {monitors[1]} --auto --same-as {monitors[0]}")
# secondary<primary
if mode==1:
system(f"xrandr --output {monitors[0]} --auto")
system(f"xrandr --output {monitors[1]} --auto --left-of {monitors[0]}")
# primary>secondary
if mode==2:
system(f"xrandr --output {monitors[0]} --auto")
system(f"xrandr --output {monitors[1]} --auto --right-of {monitors[0]}")
# only primary
if mode==3:
system(f"xrandr --output {monitors[0]} --auto")
system(f"xrandr --output {monitors[1]} --off")
# only secondary
if mode==4:
system(f"xrandr --output {monitors[1]} --auto")
system(f"xrandr --output {monitors[0]} --off")
# save settings
with open(dir+"monitor.conf","w") as conf: conf.write(str(mode))
print(mode)
print(monitors)