Skip to content

Commit dcd4046

Browse files
committed
Correction tray_icon sur kubuntu
1 parent a3a375d commit dcd4046

3 files changed

Lines changed: 47 additions & 48 deletions

File tree

config.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
1-
---
21
config:
32
# Configuration values to set up basic communication
43
# Set your COM port e.g. COM3 for Windows, /dev/ttyACM0 for Linux...
54
# Use AUTO for COM port auto-discovery (may not work on every setup) or if device is not detected as a COM port
65
# COM_PORT: "/dev/ttyACM0"
76
# COM_PORT: "COM3"
8-
COM_PORT: "AUTO"
7+
COM_PORT: AUTO
98

109
# Theme to use (located in res/themes)
1110
# Use the name of the folder as value
1211
# Choose a theme made for your screen size (see DISPLAY_SIZE inside theme.yaml)
13-
THEME: 3.5inchTheme2
12+
THEME: Cyberpunk-net
1413

1514
# Hardware sensors reading
1615
# Choose the appropriate method for reading your hardware sensors:
1716
# - PYTHON use Python libraries (psutils, GPUtil...) to read hardware sensors (supports all OS but not all HW)
1817
# - LHM use LibreHardwareMonitor library to read hardware sensors (Windows only - NEEDS ADMIN RIGHTS)
1918
# - STUB / STATIC use random/static data instead of real hardware sensors
2019
# - AUTO use the best method based on your OS: Windows OS will use LHM, other OS will use Python libraries
21-
HW_SENSORS: AUTO
20+
HW_SENSORS: PYTHON
2221

2322
# Network interfaces
2423
# Linux/MacOS interfaces are named "eth0", "wlan0", "wlp1s0", "enp2s0"...
2524
# For Windows use the interfaces pretty name: "Ethernet 2", "Wi-Fi", ...
2625
# Leave the fields empty if the card does not exist on your setup
27-
ETH: "" # Ethernet Card
28-
WLO: "" # Wi-Fi Card
26+
ETH: '' # Ethernet Card
27+
WLO: wlp4s0 # Wi-Fi Card
2928

3029
# CPU fan
3130
# For Linux/MacOS platforms, the CPU fan is amongst all fan sensors gathered from the motherboard chipset
3231
# If value is AUTO the system monitor will try to auto-select the CPU fan
3332
# If auto-detection fails, it might be necessary to manually indicate which fan is the CPU fan
3433
# Value must be 'controller/fan' e.g. 'nct6798/fan2'. Use configuration wizard for help in selection
35-
CPU_FAN: AUTO
34+
CPU_FAN: amdgpu/fan1
3635

3736
# Address used for ping sensor. Can be internal/external IP (e.g. 8.8.8.8 or 192.168.0.1) or hostname (google.com)
3837
PING: 8.8.8.8
@@ -41,7 +40,7 @@ config:
4140

4241
# OpenWeatherMap API KEY. Can be obtained by creating a free account on https://home.openweathermap.org/users/sign_up.
4342
# You need to subscribe to the 3.0 OneCallAPI that has 1000 free daily calls
44-
WEATHER_API_KEY: ""
43+
WEATHER_API_KEY: ''
4544
# Location from which to display the weather. Use for example https://www.latlong.net/ to get latitude/longitude
4645
WEATHER_LATITUDE: 45.75
4746
WEATHER_LONGITUDE: 4.85
@@ -66,7 +65,7 @@ display:
6665
# Display Brightness
6766
# Set this as the desired %, 0 being completely dark and 100 being max brightness
6867
# Warning: revision A display can get hot at high brightness!
69-
BRIGHTNESS: 20
68+
BRIGHTNESS: 40
7069

7170
# Display reverse: true/false
7271
# Set to true to reverse display orientation (landscape <-> reverse landscape, portrait <-> reverse portrait)

configure.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
size_list = (
8484
SIZE_0_96_INCH,
8585
SIZE_2_x_INCH,
86-
SIZE_2_8_ROUND_USB,
86+
SIZE_2_8_INCH_NEWREV,
8787
SIZE_3_5_INCH,
8888
SIZE_4_6_INCH,
8989
SIZE_5_INCH,
@@ -110,7 +110,7 @@
110110
('TUR_USB', SIZE_8_8_INCH): TURING_MODEL,
111111
('TUR_USB', SIZE_8_8_INCH_NEWREV): TURING_MODEL,
112112
('TUR_USB', SIZE_12_3_INCH): TURING_MODEL,
113-
('TUR_USB', SIZE_2_8_ROUND_USB): TURING_MODEL,
113+
('TUR_USB', SIZE_2_8_INCH_NEWREV): TURING_MODEL,
114114
('WEACT_A', SIZE_3_5_INCH): WEACT_MODEL,
115115
('WEACT_B', SIZE_0_96_INCH): WEACT_MODEL,
116116

@@ -135,7 +135,7 @@
135135
(TURING_MODEL, SIZE_8_8_INCH): 'C',
136136
(TURING_MODEL, SIZE_8_8_INCH_NEWREV): 'TUR_USB',
137137
(TURING_MODEL, SIZE_12_3_INCH): 'TUR_USB',
138-
(TURING_MODEL, SIZE_2_8_ROUND_USB): 'TUR_USB',
138+
(TURING_MODEL, SIZE_2_8_INCH_NEWREV): 'TUR_USB',
139139
(USBPCMONITOR_MODEL, SIZE_3_5_INCH): 'A',
140140
(USBPCMONITOR_MODEL, SIZE_5_INCH): 'A',
141141
(WEACT_MODEL, SIZE_0_96_INCH): 'WEACT_B',
@@ -474,7 +474,7 @@ def load_config_values(self):
474474
if size == SIZE_8_8_INCH and self.config['display']['REVISION'] == 'TUR_USB':
475475
size = SIZE_8_8_INCH_NEWREV
476476
if size == SIZE_2_x_INCH and self.config['display']['REVISION'] == 'TUR_USB':
477-
size = SIZE_2_8_ROUND_USB
477+
size = SIZE_2_8_INCH_NEWREV
478478
self.size_cb.set(size)
479479
except:
480480
self.size_cb.current(0)
@@ -622,7 +622,7 @@ def on_size_change(self, e=None):
622622
size = self.size_cb.get()
623623

624624
# For '2.1" / 2.8"' size, search for themes of both sizes
625-
if size == SIZE_2_x_INCH or size == SIZE_2_8_ROUND_USB:
625+
if size == SIZE_2_x_INCH or size == SIZE_2_8_INCH_NEWREV:
626626
themes = get_themes(_SIZE_2_1_INCH)
627627
themes += get_themes(_SIZE_2_8_INCH)
628628
# For 8.8" & 9.2" sizes, search for themes of both sizes

main.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,15 @@ def clean_stop(tray_icon=None):
101101

102102
# Remove tray icon just before exit
103103
if tray_icon:
104-
tray_icon.visible = False
104+
tray_icon.stop()
105+
time.sleep(0.5)
105106

106107
# We force the exit to avoid waiting for other scheduled tasks: they may have a long delay!
107108
try:
108109
sys.exit(0)
109110
except:
110111
os._exit(0)
111112

112-
def on_signal_caught(signum, frame=None):
113-
logger.info("Caught signal %d, exiting" % signum)
114-
clean_stop()
115-
116113
def on_configure_tray(tray_icon, item):
117114
logger.info("Configure from tray icon")
118115

@@ -135,17 +132,46 @@ def on_exit_tray(tray_icon, item):
135132
clean_stop(tray_icon)
136133

137134

135+
# Create a tray icon for the program, with an Exit entry in menu
136+
try:
137+
tray_icon = pystray.Icon(
138+
name='Turing System Monitor',
139+
title='Turing System Monitor',
140+
icon=Image.open(MAIN_DIRECTORY / "res/icons/monitor-icon-17865/64.png"),
141+
menu=pystray.Menu(
142+
pystray.MenuItem(
143+
text='Configure',
144+
action=on_configure_tray),
145+
pystray.Menu.SEPARATOR,
146+
pystray.MenuItem(
147+
text='Exit',
148+
action=on_exit_tray)
149+
)
150+
)
151+
152+
# For platforms != macOS, display the tray icon now with non-blocking function
153+
if platform.system() != "Darwin":
154+
tray_icon.run_detached()
155+
logger.info("Tray icon has been displayed")
156+
except:
157+
tray_icon = None
158+
logger.warning("Tray icon is not supported on your platform")
159+
160+
# Set the different stopping event handlers, to send a complete frame to the LCD before exit
138161
def on_clean_exit(*args):
139162
logger.info("Program will now exit")
140-
clean_stop()
163+
clean_stop(tray_icon)
141164

165+
def on_signal_caught(signum, frame=None):
166+
logger.info("Caught signal %d, exiting" % signum)
167+
clean_stop(tray_icon)
142168

143169
if platform.system() == "Windows":
144170
def on_win32_ctrl_event(event):
145171
"""Handle Windows console control events (like Ctrl-C)."""
146172
if event in (win32con.CTRL_C_EVENT, win32con.CTRL_BREAK_EVENT, win32con.CTRL_CLOSE_EVENT):
147173
logger.debug("Caught Windows control event %s, exiting" % event)
148-
clean_stop()
174+
clean_stop(tray_icon)
149175
return 0
150176

151177

@@ -166,34 +192,8 @@ def on_win32_wm_event(hWnd, msg, wParam, lParam):
166192
else:
167193
# For any other events, the program will stop
168194
logger.info("Program will now exit")
169-
clean_stop()
195+
clean_stop(tray_icon)
170196

171-
# Create a tray icon for the program, with an Exit entry in menu
172-
try:
173-
tray_icon = pystray.Icon(
174-
name='Turing System Monitor',
175-
title='Turing System Monitor',
176-
icon=Image.open(MAIN_DIRECTORY / "res/icons/monitor-icon-17865/64.png"),
177-
menu=pystray.Menu(
178-
pystray.MenuItem(
179-
text='Configure',
180-
action=on_configure_tray),
181-
pystray.Menu.SEPARATOR,
182-
pystray.MenuItem(
183-
text='Exit',
184-
action=on_exit_tray)
185-
)
186-
)
187-
188-
# For platforms != macOS, display the tray icon now with non-blocking function
189-
if platform.system() != "Darwin":
190-
tray_icon.run_detached()
191-
logger.info("Tray icon has been displayed")
192-
except:
193-
tray_icon = None
194-
logger.warning("Tray icon is not supported on your platform")
195-
196-
# Set the different stopping event handlers, to send a complete frame to the LCD before exit
197197
atexit.register(on_clean_exit)
198198
signal.signal(signal.SIGINT, on_signal_caught)
199199
signal.signal(signal.SIGTERM, on_signal_caught)

0 commit comments

Comments
 (0)