Skip to content

Commit d2f3df8

Browse files
committed
todos
1 parent abf55cc commit d2f3df8

File tree

5 files changed

+91
-41
lines changed

5 files changed

+91
-41
lines changed

config.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[Settings]
22
monitor_name = DELL U2422H
33
multimonitortool_executable = C:\\App_Install\\multimonitortool-x64\\MultiMonitorTool.exe
4-
start_with_windows = no
4+
start_with_windows = yes
55
first_start = no
66

smct_pkg/multimonitortool.py

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,37 @@
44
from smct_pkg import config, paths
55

66

7-
def save_mmt_config():
7+
def _run_mmt_command(command, destination):
88
try:
99
subprocess.run(
1010
[
1111
config.MMT_PATH_VALUE,
12-
"/SaveConfig",
13-
paths.MMT_CONFIG_PATH,
12+
command,
13+
destination,
1414
],
1515
check=True,
1616
)
1717
except subprocess.CalledProcessError as error:
18-
print(f"MultiMonitorTool.exe /SaveConfig failed: {error}")
18+
print(f"MultiMonitorTool.exe {command} failed: {error}")
19+
20+
21+
def save_mmt_config():
22+
_run_mmt_command("/SaveConfig", paths.MMT_CONFIG_PATH)
1923

2024

2125
def update_mmt_csv():
22-
# Run MultiMonitorTool.exe with the /scomma option to save the monitors list into a CSV file
23-
try:
24-
subprocess.run(
25-
[
26-
config.MMT_PATH_VALUE,
27-
"/scomma",
28-
paths.MMT_CSV_PATH,
29-
],
30-
check=True,
31-
)
32-
except subprocess.CalledProcessError as error:
33-
print(f"MultiMonitorTool.exe /scomma failed: {error}")
26+
_run_mmt_command("/scomma", paths.MMT_CSV_PATH)
3427

3528

3629
def enable_monitor():
37-
try:
38-
subprocess.run(
39-
[
40-
config.MMT_PATH_VALUE,
41-
"/LoadConfig",
42-
paths.MMT_CONFIG_PATH,
43-
],
44-
check=True,
45-
)
46-
except subprocess.CalledProcessError as error:
47-
print(f"MultiMonitorTool.exe /LoadConfig failed: {error}")
30+
_run_mmt_command("/LoadConfig", paths.MMT_CONFIG_PATH)
4831

4932

5033
def disable_monitor():
51-
try:
52-
subprocess.run(
53-
[
54-
config.MMT_PATH_VALUE,
55-
"/disable",
56-
get_monitor_id(),
57-
],
58-
check=True,
59-
)
60-
except subprocess.CalledProcessError as error:
61-
print(f"MultiMonitorTool.exe /LoadConfig failed: {error}")
34+
_run_mmt_command("/disable", get_monitor_id())
35+
36+
37+
# TODO Encoding Issue?
6238

6339

6440
def get_monitor_id():
@@ -90,3 +66,35 @@ def is_monitor_enabled():
9066
except KeyError:
9167
pass
9268
return False
69+
70+
71+
"""
72+
def get_monitor_id():
73+
with open(paths.MMT_CSV_PATH, "r", encoding=config.ENCODING) as file:
74+
reader = csv.DictReader(file)
75+
for row in reader:
76+
try:
77+
if row["Monitor Name"] == config.MONITOR_NAME_VALUE:
78+
monitor_id = row["Name"]
79+
return monitor_id[-1]
80+
except KeyError:
81+
pass
82+
return 0
83+
84+
85+
def is_monitor_enabled():
86+
with open(paths.MMT_CSV_PATH, "r", encoding=config.ENCODING) as file:
87+
reader = csv.DictReader(file)
88+
89+
for row in reader:
90+
try:
91+
monitor_name = row["Monitor Name"]
92+
monitor_active = row["Active"]
93+
if (
94+
monitor_name == config.MONITOR_NAME_VALUE
95+
and monitor_active.upper() == "YES"
96+
):
97+
return True
98+
except KeyError:
99+
pass
100+
return False"""

smct_pkg/tray.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ def init_tray():
9191
else:
9292
first_image_icon = icon_disabled_image
9393

94-
icon = pystray.Icon(
94+
# pylint: disable=global-statement
95+
global ICON
96+
ICON = pystray.Icon(
9597
ui_strings.APP_NAME, first_image_icon, ui_strings.APP_NAME, menu
9698
)
97-
icon.run()
99+
ICON.run()

temp/MultiMonitorToolConfig

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[Monitor0]
2+
Name=\\.\DISPLAY1
3+
MonitorID=MONITOR\LEN66FB\{4d36e96e-e325-11ce-bfc1-08002be10318}\0008
4+
SerialNumber=URHK6FCP
5+
BitsPerPixel=32
6+
Width=2560
7+
Height=1440
8+
DisplayFlags=0
9+
DisplayFrequency=60
10+
DisplayOrientation=0
11+
PositionX=2560
12+
PositionY=0
13+
[Monitor1]
14+
Name=\\.\DISPLAY2
15+
MonitorID=MONITOR\ACI27EC\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009
16+
SerialNumber=#ASNImfyQBwHd
17+
BitsPerPixel=32
18+
Width=2560
19+
Height=1440
20+
DisplayFlags=0
21+
DisplayFrequency=144
22+
DisplayOrientation=0
23+
PositionX=0
24+
PositionY=0
25+
[Monitor2]
26+
Name=\\.\DISPLAY3
27+
MonitorID=MONITOR\GSM0001\{4d36e96e-e325-11ce-bfc1-08002be10318}\0010
28+
SerialNumber=
29+
BitsPerPixel=32
30+
Width=1920
31+
Height=1080
32+
DisplayFlags=0
33+
DisplayFrequency=60
34+
DisplayOrientation=0
35+
PositionX=1635
36+
PositionY=-1080

temp/MultiMonitorToolOutput.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Resolution,Left-Top,Right-Bottom,Active,Disconnected,Primary,Colors,Frequency,Orientation,Maximum Resolution,Name,Adapter,Device ID,Device Key,Monitor ID,Short Monitor ID,Monitor Key,Monitor String,Monitor Name,Monitor Serial Number
2+
1920 X 1080,"1635, -1080","3555, 0",Yes,No,No,32,60,Default,1920 X 1080,\\.\DISPLAY3,NVIDIA GeForce RTX 2080 Ti,PCI\VEN_10DE&DEV_1E07&SUBSYS_866A1043&REV_A1,\Registry\Machine\System\CurrentControlSet\Control\Video\{3AB1B141-D3F6-11EE-A460-106FD93C4F11}\0002,MONITOR\GSM0001\{4d36e96e-e325-11ce-bfc1-08002be10318}\0010,GSM0001,\Registry\Machine\System\CurrentControlSet\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0010,Generic PnP Monitor,LG TV,
3+
2560 X 1440,"0, 0","2560, 1440",Yes,No,Yes,32,144,Default,2560 X 1440,\\.\DISPLAY2,NVIDIA GeForce RTX 2080 Ti,PCI\VEN_10DE&DEV_1E07&SUBSYS_866A1043&REV_A1,\Registry\Machine\System\CurrentControlSet\Control\Video\{3AB1B141-D3F6-11EE-A460-106FD93C4F11}\0001,MONITOR\ACI27EC\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009,ACI27EC,\Registry\Machine\System\CurrentControlSet\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009,ROG PG279Q,ROG PG279Q,#ASNImfyQBwHd
4+
2560 X 1440,"2560, 0","5120, 1440",Yes,No,No,32,60,Default,2560 X 1440,\\.\DISPLAY1,NVIDIA GeForce RTX 2080 Ti,PCI\VEN_10DE&DEV_1E07&SUBSYS_866A1043&REV_A1,\Registry\Machine\System\CurrentControlSet\Control\Video\{3AB1B141-D3F6-11EE-A460-106FD93C4F11}\0000,MONITOR\LEN66FB\{4d36e96e-e325-11ce-bfc1-08002be10318}\0008,LEN66FB,\Registry\Machine\System\CurrentControlSet\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0008,Generic PnP Monitor,C27q-35,URHK6FCP

0 commit comments

Comments
 (0)