Compare commits
2 Commits
326658ed26
...
9cfdebe553
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9cfdebe553 | ||
|
|
f773e1dac9 |
@@ -154,50 +154,11 @@ COLORS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ICON_SIZE = 64
|
ICON_SIZE = 64
|
||||||
ICON_FILE = os.path.join(HERE, "icon.ico")
|
|
||||||
|
|
||||||
# Load base icon once at startup; fall back to None if missing.
|
|
||||||
# When frozen, bundled data files live in sys._MEIPASS.
|
|
||||||
def _load_base_icon():
|
|
||||||
candidates = [ICON_FILE]
|
|
||||||
if getattr(sys, "frozen", False):
|
|
||||||
candidates.insert(0, os.path.join(sys._MEIPASS, "icon.ico"))
|
|
||||||
for path in candidates:
|
|
||||||
try:
|
|
||||||
img = Image.open(path)
|
|
||||||
img = img.convert("RGBA").resize((ICON_SIZE, ICON_SIZE), Image.LANCZOS)
|
|
||||||
return img
|
|
||||||
except Exception:
|
|
||||||
continue
|
|
||||||
return None
|
|
||||||
|
|
||||||
_BASE_ICON = _load_base_icon()
|
|
||||||
|
|
||||||
|
|
||||||
def make_icon(status):
|
def make_icon(status):
|
||||||
"""
|
"""Draw a plain colored circle for the system tray — clean and readable at 16px."""
|
||||||
Use icon.ico as the base and overlay a small status dot in the
|
|
||||||
bottom-right corner. Falls back to a plain colored circle if the
|
|
||||||
ico file is not available.
|
|
||||||
"""
|
|
||||||
color = COLORS.get(status, COLORS["starting"])
|
color = COLORS.get(status, COLORS["starting"])
|
||||||
|
|
||||||
if _BASE_ICON is not None:
|
|
||||||
img = _BASE_ICON.copy()
|
|
||||||
draw = ImageDraw.Draw(img)
|
|
||||||
# Dot size and position — bottom-right corner
|
|
||||||
dot_r = ICON_SIZE // 5 # radius ~12px on 64px icon
|
|
||||||
margin = 2
|
|
||||||
x0 = ICON_SIZE - dot_r * 2 - margin
|
|
||||||
y0 = ICON_SIZE - dot_r * 2 - margin
|
|
||||||
x1 = ICON_SIZE - margin
|
|
||||||
y1 = ICON_SIZE - margin
|
|
||||||
# White outline for contrast on dark/light backgrounds
|
|
||||||
draw.ellipse([x0 - 2, y0 - 2, x1 + 2, y1 + 2], fill=(255, 255, 255, 220))
|
|
||||||
draw.ellipse([x0, y0, x1, y1], fill=color + (255,))
|
|
||||||
return img
|
|
||||||
|
|
||||||
# Fallback: plain colored circle
|
|
||||||
img = Image.new("RGBA", (ICON_SIZE, ICON_SIZE), (0, 0, 0, 0))
|
img = Image.new("RGBA", (ICON_SIZE, ICON_SIZE), (0, 0, 0, 0))
|
||||||
draw = ImageDraw.Draw(img)
|
draw = ImageDraw.Draw(img)
|
||||||
margin = 6
|
margin = 6
|
||||||
|
|||||||
@@ -319,9 +319,12 @@ def run_watcher(state: Dict[str, Any], stop_event: threading.Event) -> None:
|
|||||||
"""
|
"""
|
||||||
if getattr(sys, "frozen", False):
|
if getattr(sys, "frozen", False):
|
||||||
here = os.path.dirname(os.path.abspath(sys.executable))
|
here = os.path.dirname(os.path.abspath(sys.executable))
|
||||||
|
_appdata = os.environ.get("LOCALAPPDATA") or os.environ.get("APPDATA") or here
|
||||||
|
config_dir = os.path.join(_appdata, "Series3Watcher")
|
||||||
else:
|
else:
|
||||||
here = os.path.dirname(os.path.abspath(__file__)) or "."
|
here = os.path.dirname(os.path.abspath(__file__)) or "."
|
||||||
config_path = os.path.join(here, "config.ini")
|
config_dir = here
|
||||||
|
config_path = os.path.join(config_dir, "config.ini")
|
||||||
|
|
||||||
state["status"] = "starting"
|
state["status"] = "starting"
|
||||||
state["units"] = []
|
state["units"] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user