Skip to content

Commit 181ddfc

Browse files
committed
chore(build): update versioning and refactor bar manager
This commit modifies the build process to use a dynamic version number sourced from the settings module instead of a hardcoded value. It also refactors the BarManager class to improve its configuration handling by replacing the previous close and initialize methods with a more efficient process that restarts the application when configuration changes are detected. Additionally, updates to the tray icon include new links for GitHub themes and adjustments to the styling in the CSS files for better visual consistency.
1 parent 24eeb23 commit 181ddfc

File tree

4 files changed

+35
-54
lines changed

4 files changed

+35
-54
lines changed

src/build.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from cx_Freeze import setup, Executable
3-
4-
version = "1.0.2"
3+
from settings import BUILD_VERSION
4+
55
#base = "console"
66
base = "gui"
77
build_options = {
@@ -123,7 +123,7 @@
123123
]
124124
setup(
125125
name="yasb",
126-
version=version,
126+
version=BUILD_VERSION,
127127
author="AmN",
128128
description="Yet Another Status Bar",
129129
executables=executables,

src/core/bar_manager.py

+9-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import asyncio
21
import logging
2+
import os
3+
import sys
34
import uuid
45
from contextlib import suppress
56
from PyQt6.QtWidgets import QApplication
@@ -11,14 +12,12 @@
1112
from core.event_service import EventService
1213
from core.config import get_stylesheet, get_config
1314
from copy import deepcopy
14-
15-
from core.utils.win32.media import WindowsMedia
16-
15+
from settings import DEBUG
1716

1817
class BarManager(QObject):
1918
styles_modified = pyqtSignal()
2019
config_modified = pyqtSignal()
21-
tray_reload = pyqtSignal()
20+
2221

2322
def __init__(self, config: dict, stylesheet: str):
2423
super().__init__()
@@ -58,10 +57,7 @@ def on_config_modified(self):
5857
if config and (config != self.config):
5958

6059
if config['bars'] != self.config['bars'] or config['widgets'] != self.config['widgets'] or config['komorebi'] != self.config['komorebi']:
61-
self.config = config
62-
self.close_bars()
63-
self.initialize_bars()
64-
self.tray_reload.emit()
60+
os.execl(sys.executable, sys.executable, *sys.argv)
6561
else:
6662
self.config = config
6763

@@ -70,12 +66,12 @@ def on_config_modified(self):
7066
@pyqtSlot(QScreen)
7167
def on_screens_update(self, _screen: QScreen) -> None:
7268
logging.info("Screens updated. Re-initialising all bars.")
73-
self.close_bars()
74-
self.initialize_bars()
69+
os.execl(sys.executable, sys.executable, *sys.argv)
7570

7671
def run_listeners_in_threads(self):
7772
for listener in self.widget_event_listeners:
78-
logging.info(f"Starting {listener.__name__}...")
73+
if DEBUG:
74+
logging.info(f"Starting {listener.__name__}...")
7975
thread = listener()
8076
thread.start()
8177
self._threads[listener] = thread
@@ -89,21 +85,7 @@ def stop_listener_threads(self):
8985
self._threads[listener].wait(500)
9086
self._threads.clear()
9187
self.widget_event_listeners.clear()
92-
93-
def close_bars(self):
94-
self.stop_listener_threads()
95-
tasks = asyncio.all_tasks()
96-
for t in tasks:
97-
t.cancel()
98-
99-
if WindowsMedia.has_instance():
100-
WindowsMedia().stop()
101-
102-
for bar in self.bars:
103-
bar.close()
104-
105-
self.event_service.clear()
106-
self.bars.clear()
88+
10789

10890
def initialize_bars(self, init=False) -> None:
10991
self._widget_builder = WidgetBuilder(self.config['widgets'])

src/core/tray.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from PyQt6.QtGui import QIcon
1111
from PyQt6.QtCore import QCoreApplication, QSize, Qt
1212
from core.bar_manager import BarManager
13-
from settings import GITHUB_URL, SCRIPT_PATH, APP_NAME, APP_NAME_FULL, DEFAULT_CONFIG_DIRECTORY, VERSION
13+
from settings import GITHUB_URL, SCRIPT_PATH, APP_NAME, APP_NAME_FULL, DEFAULT_CONFIG_DIRECTORY, GITHUB_THEME_URL, BUILD_VERSION
1414
from core.config import get_config
1515

1616
OS_STARTUP_FOLDER = os.path.join(os.environ['APPDATA'], r'Microsoft\Windows\Start Menu\Programs\Startup')
@@ -33,7 +33,7 @@ def __init__(self, bar_manager: BarManager):
3333
self._load_context_menu()
3434
self.setToolTip(f"{APP_NAME}")
3535
self._load_config()
36-
self._bar_manager.tray_reload.connect(self._reload_tray)
36+
3737

3838
def _load_config(self):
3939
try:
@@ -52,9 +52,7 @@ def _load_favicon(self):
5252
self._icon.addFile(os.path.join(parent_directory, 'assets', 'images', 'app_icon.png'), QSize(48, 48))
5353
self.setIcon(self._icon)
5454

55-
def _reload_tray(self):
56-
self._load_config()
57-
self._load_context_menu()
55+
5856

5957
def _load_context_menu(self):
6058
menu = QMenu()
@@ -87,7 +85,7 @@ def _load_context_menu(self):
8785
QMenu::right-arrow {
8886
width: 8px;
8987
height: 8px;
90-
padding-right: 18px;
88+
padding-right:16px;
9189
}
9290
"""
9391
menu.setStyleSheet(style_sheet)
@@ -196,22 +194,20 @@ def _reload_application(self):
196194
os.execl(sys.executable, sys.executable, *sys.argv)
197195

198196
def _exit_application(self):
199-
self._bar_manager.close_bars()
200-
logging.info("Exiting Application...")
197+
logging.info("Exiting Application from tray...")
201198
QCoreApplication.exit(0)
202199

203200
def _open_docs_in_browser(self):
204201
webbrowser.open(self._docs_url)
205202

206-
207-
208203
def _show_about_dialog(self):
209204
about_text = f"""
210-
<div style="font-family:'Segoe UI',sans-serif;">
211-
<div style="font-size:24px;font-weight:700;">{APP_NAME} REBORN</div>
205+
<div style="font-family:'Segoe UI',sans-serif;">
206+
<div style="font-size:20px;font-weight:700;">{APP_NAME} REBORN</div><br/>
212207
<div style="font-size:14px;font-weight:500">{APP_NAME_FULL}</div>
213-
<div style="font-size:12px;">Version: {VERSION}</div><br>
214-
<div><a href="{GITHUB_URL}" style="margin:0;padding:0;">{GITHUB_URL}</a></div>
208+
<div style="font-size:12px;">Version: {BUILD_VERSION}</div><br>
209+
<div><a href="{GITHUB_URL}">{GITHUB_URL}</a></div>
210+
<div><a href="{GITHUB_THEME_URL}">{GITHUB_THEME_URL}</a></div>
215211
</div>
216212
"""
217213
# Create a QMessageBox instance

src/styles.css

+13-10
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
padding: 1px 8px 1px 8px;
4242
}
4343
.active-window-widget {
44-
border-radius: 16px;
44+
border-radius: 18px;
4545
margin-left: 8px
4646
}
4747
.container-left,
@@ -52,18 +52,18 @@
5252
}
5353

5454
.clock-widget {
55-
border-top-left-radius: 16px;
56-
border-bottom-left-radius: 16px;
55+
border-top-left-radius: 18px;
56+
border-bottom-left-radius: 18px;
5757
}
5858

5959
.apps-widget {
6060
padding: 0 2px;
61-
border-top-right-radius: 16px;
62-
border-bottom-right-radius: 16px;
61+
border-top-right-radius: 18px;
62+
border-bottom-right-radius: 18px;
6363
}
6464
.komorebi-active-layout {
65-
border-top-right-radius: 16px;
66-
border-bottom-right-radius: 16px;
65+
border-top-right-radius: 18px;
66+
border-bottom-right-radius: 18px;
6767
padding: 0 4px 0 0;
6868
}
6969

@@ -73,18 +73,21 @@
7373
}
7474
.wifi-widget {
7575
padding: 0 4px 0 4px;
76-
border-top-left-radius: 16px;
77-
border-bottom-left-radius: 16px;
76+
border-top-left-radius: 18px;
77+
border-bottom-left-radius: 18px;
7878
}
7979

8080
.apps-widget .widget-container,
8181
.komorebi-workspaces .widget-container,
8282
.wifi-widget .widget-container,
8383
.komorebi-active-layout .widget-container {
8484
background-color: #313244;
85-
margin: 4px 0 4px 0;
85+
margin: 4px 0px 4px 0;
8686
border-radius: 14px;
8787
}
88+
.apps-widget .widget-container {
89+
margin-right: 2px;
90+
}
8891
.komorebi-workspaces .ws-btn {
8992
font-size: 16px;
9093
background-color: transparent;

0 commit comments

Comments
 (0)