- OS name comes from /etc/os-release (e.g. 'CachyOS Linux'), mirroring the original app's os_utils; macOS/Windows get proper names too - Status pill shows the name as-is instead of uppercasing it - Removed the watched-folder path next to the logo; it now appears only in the footer strip (spec updated to match)
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import platform
|
|
from functools import lru_cache
|
|
|
|
|
|
@lru_cache(maxsize=1)
|
|
def _os_release_values():
|
|
values = {}
|
|
try:
|
|
with open("/etc/os-release", encoding="utf-8") as handle:
|
|
for line in handle:
|
|
line = line.strip()
|
|
if not line or "=" not in line:
|
|
continue
|
|
key, value = line.split("=", 1)
|
|
values[key] = value.strip().strip('"')
|
|
except OSError:
|
|
pass
|
|
return values
|
|
|
|
|
|
@lru_cache(maxsize=1)
|
|
def get_os_info():
|
|
"""OS display name and icon key, mirroring the original app's os_utils."""
|
|
system = platform.system()
|
|
release = platform.release()
|
|
if system == "Linux":
|
|
name = _os_release_values().get("NAME") or "Linux"
|
|
return {"name": name, "release": release, "icon": "linux"}
|
|
if system == "Darwin":
|
|
return {"name": "macOS", "release": release, "icon": "apple"}
|
|
if system == "Windows":
|
|
return {"name": "Windows", "release": release, "icon": "windows"}
|
|
return {"name": system, "release": release, "icon": "unknown"}
|