✨ feat(ui): add new applet icons for better visual representation
This commit is contained in:
34 files changed
+122
-112
No files matched your search
+31
-25
@@ -1,8 +1,13 @@
|
||||
import re
|
||||
import subprocess
|
||||
import re
|
||||
import gi # type: ignore
|
||||
|
||||
from fabric.utils.helpers import get_relative_path
|
||||
from gi.repository import GdkPixbuf, Gtk # type: ignore
|
||||
from fabric.widgets.label import Label
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.box import Box
|
||||
from widgets.wayland import WaylandWindow as Window
|
||||
from fabric.utils.helpers import exec_shell_command_async, get_relative_path
|
||||
from gi.repository import Gtk, GdkPixbuf # type: ignore
|
||||
|
||||
|
||||
def read_dmi(field):
|
||||
@@ -14,31 +19,32 @@ def read_dmi(field):
|
||||
|
||||
|
||||
def get_gpu_name():
|
||||
output = subprocess.check_output("lspci", text=True)
|
||||
gpus = []
|
||||
try:
|
||||
output = (
|
||||
subprocess.check_output(
|
||||
"lspci -nn | grep -i 'VGA compatible controller'", shell=True, text=True
|
||||
)
|
||||
.strip()
|
||||
.split("\n")
|
||||
)
|
||||
|
||||
for line in output.splitlines():
|
||||
if "VGA compatible controller" in line or "3D controller" in line:
|
||||
parts = line.split(":", 2)
|
||||
if len(parts) < 3:
|
||||
continue
|
||||
desc = parts[2].strip()
|
||||
desc = re.sub(r"\(rev .*?\)", "", desc).strip()
|
||||
def clean(line):
|
||||
matches = re.findall(r"\[(.*?)\]", line)
|
||||
if len(matches) >= 2:
|
||||
return matches[1].strip()
|
||||
desc = line.split(":", 2)[-1]
|
||||
return desc.replace("Corporation", "").strip()
|
||||
|
||||
if "NVIDIA" in desc:
|
||||
match = re.search(r"\[(.*?)\]", desc)
|
||||
name = match.group(1) if match else desc
|
||||
elif "Intel" in desc:
|
||||
name = re.sub(r"Intel Corporation", "Intel", desc).strip()
|
||||
elif "AMD" in desc or "ATI" in desc:
|
||||
matches = re.findall(r"\[(.*?)\]", desc)
|
||||
name = matches[1] if len(matches) > 1 else desc
|
||||
else:
|
||||
name = desc
|
||||
for line in output:
|
||||
if any(vendor in line.lower() for vendor in ["nvidia", "amd", "radeon"]):
|
||||
return clean(line)
|
||||
|
||||
gpus.append((name))
|
||||
if output:
|
||||
return clean(output[0])
|
||||
|
||||
return gpus[-1]
|
||||
return "Unknown GPU"
|
||||
except Exception:
|
||||
return "Unknown GPU"
|
||||
|
||||
|
||||
class About(Gtk.Window):
|
||||
@@ -60,7 +66,7 @@ class About(Gtk.Window):
|
||||
# Logo
|
||||
logo_box = Gtk.Box(halign=Gtk.Align.CENTER, valign=Gtk.Align.CENTER)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
get_relative_path("../config/assets/icons/imac.svg"),
|
||||
get_relative_path("../config/assets/icons/misc/imac.svg"),
|
||||
158,
|
||||
108,
|
||||
preserve_aspect_ratio=True,
|
||||
|
||||
@@ -113,17 +113,23 @@ class ModusControlCenter(Window):
|
||||
self.has_bluetooth_open = False
|
||||
self.has_wifi_open = False
|
||||
|
||||
self.bluetooth_svg = Image(
|
||||
self.bluetooth_svg = Svg(
|
||||
name="bluetooth-icon",
|
||||
icon_name="bluetooth-symbolic",
|
||||
size=24,
|
||||
style_classes="connected" if bluetooth != "disabled" else "",
|
||||
svg_file=get_relative_path(
|
||||
"../../config/assets/icons/applets/bluetooth.svg"
|
||||
if bluetooth != "disabled"
|
||||
else "../../config/assets/icons/applets/bluetooth-off.svg"
|
||||
),
|
||||
size=42,
|
||||
)
|
||||
self.wifi_svg = Image(
|
||||
self.wifi_svg = Svg(
|
||||
name="wifi-icon",
|
||||
icon_name="network-wireless-symbolic",
|
||||
size=24,
|
||||
style_classes="connected" if wlan != "No Connection" else "",
|
||||
svg_file=get_relative_path(
|
||||
"../../config/assets/icons/applets/wifi.svg"
|
||||
if wlan != "No Connection"
|
||||
else "../../config/assets/icons/applets/wifi-off.svg"
|
||||
),
|
||||
size=46,
|
||||
)
|
||||
|
||||
self.bluetooth_widget = Button(
|
||||
@@ -171,8 +177,9 @@ class ModusControlCenter(Window):
|
||||
)
|
||||
|
||||
self.focus_icon = Svg(
|
||||
svg_file=get_relative_path("../../config/assets/icons/dnd-off.svg"),
|
||||
size=24,
|
||||
name="focus-icon",
|
||||
svg_file=get_relative_path("../../config/assets/icons/applets/dnd-off.svg"),
|
||||
size=46,
|
||||
)
|
||||
|
||||
self.focus_widget = Button(
|
||||
@@ -252,9 +259,9 @@ class ModusControlCenter(Window):
|
||||
modus_service.dont_disturb = self.focus_mode
|
||||
self.focus_icon.set_from_file(
|
||||
get_relative_path(
|
||||
"config/assets/icons/dnd.svg"
|
||||
"../../config/assets/icons/applets/dnd.svg"
|
||||
if self.focus_mode
|
||||
else "config/assets/icons/dnd-off.svg"
|
||||
else "../../config/assets/icons/applets/dnd-off.svg"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -345,8 +352,14 @@ class ModusControlCenter(Window):
|
||||
)
|
||||
|
||||
def wlan_changed(self, _, wlan):
|
||||
self.wifi_svg.set_from_file(
|
||||
get_relative_path(
|
||||
"../../config/assets/icons/applets/wifi.svg"
|
||||
if wlan != "No Connection"
|
||||
else "../../config/assets/icons/applets/wifi-off.svg"
|
||||
)
|
||||
)
|
||||
if wlan != "No Connection":
|
||||
self.wifi_svg.set_property("style-classes", "connected")
|
||||
if wlan.startswith("connected:"):
|
||||
parts = wlan.split(":")
|
||||
if len(parts) >= 2:
|
||||
@@ -357,16 +370,21 @@ class ModusControlCenter(Window):
|
||||
else:
|
||||
GLib.idle_add(lambda: self.wlan_label.set_property("label", wlan))
|
||||
else:
|
||||
self.wifi_svg.set_property("style-classes", "")
|
||||
GLib.idle_add(lambda: self.wlan_label.set_property("label", wlan))
|
||||
|
||||
def bluetooth_changed(self, _, bluetooth):
|
||||
self.bluetooth_svg.set_from_file(
|
||||
get_relative_path(
|
||||
"../../config/assets/icons/applets/bluetooth.svg"
|
||||
if bluetooth != "disabled"
|
||||
else "../../config/assets/icons/applets/bluetooth-off.svg"
|
||||
)
|
||||
)
|
||||
if bluetooth != "disabled":
|
||||
self.bluetooth_svg.set_property("style-classes", "connected")
|
||||
if bluetooth.startswith("connected:"):
|
||||
parts = bluetooth.split(":")
|
||||
if len(parts) >= 2:
|
||||
device_name = parts[1]
|
||||
device_name = parts[1]
|
||||
GLib.idle_add(lambda: self.bluetooth_label.set_property("label", device_name))
|
||||
else:
|
||||
GLib.idle_add(lambda: self.bluetooth_label.set_property("label", "Connected"))
|
||||
@@ -375,7 +393,6 @@ class ModusControlCenter(Window):
|
||||
else:
|
||||
GLib.idle_add(lambda: self.bluetooth_label.set_property("label", "On"))
|
||||
else:
|
||||
self.bluetooth_svg.set_property("style-classes", "")
|
||||
GLib.idle_add(lambda: self.bluetooth_label.set_property("label", "Off"))
|
||||
|
||||
def audio_changed(self, *_):
|
||||
|
||||
+3
-3
@@ -50,7 +50,7 @@ class BrightnessOSDContainer(Box):
|
||||
orientation="h",
|
||||
)
|
||||
self.osd_window_image = Svg(
|
||||
get_relative_path("../config/assets/icons/brightness.svg"),
|
||||
get_relative_path("../config/assets/icons/brightness/brightness.svg"),
|
||||
size=(84, 150),
|
||||
name="osd-image",
|
||||
h_align="center",
|
||||
@@ -112,7 +112,7 @@ class AudioOSDContainer(Box):
|
||||
orientation="h",
|
||||
)
|
||||
self.osd_window_image = Svg(
|
||||
get_relative_path("../config/assets/icons/audio-volume.svg"),
|
||||
get_relative_path("../config/assets/icons/volume/audio-volume.svg"),
|
||||
size=(64, 150),
|
||||
name="osd-image",
|
||||
h_align="center",
|
||||
@@ -253,7 +253,7 @@ class MicrophoneOSDContainer(Box):
|
||||
)
|
||||
|
||||
self.osd_window_image = Svg(
|
||||
get_relative_path("../config/assets/icons/microphone.svg"),
|
||||
get_relative_path("../config/assets/icons/mic/microphone.svg"),
|
||||
size=(64, 150),
|
||||
name="osd-image",
|
||||
h_align="center",
|
||||
|
||||
@@ -3,9 +3,8 @@ from fabric.utils import get_relative_path
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.svg import Svg
|
||||
|
||||
from services.battery import Battery
|
||||
from services.network import NetworkService
|
||||
from services.battery import Battery
|
||||
from utils.roam import modus_service
|
||||
|
||||
|
||||
@@ -17,7 +16,7 @@ class BluetoothIndicator(Box):
|
||||
self.bt_icon = Svg(
|
||||
name="bt-icon",
|
||||
size=20,
|
||||
svg_file=get_relative_path("../../../config/assets/icons/bluetooth.svg"),
|
||||
svg_file=get_relative_path("../../../config/assets/icons/applets/bluetooth-clear.svg"),
|
||||
)
|
||||
|
||||
self.bt_button = Button(name="bt-button", child=self.bt_icon)
|
||||
@@ -35,14 +34,14 @@ class BluetoothIndicator(Box):
|
||||
def update_state(self):
|
||||
if not self.bluetooth.enabled:
|
||||
self.bt_icon.set_from_file(
|
||||
get_relative_path("../../../config/assets/icons/bluetooth-off.svg")
|
||||
get_relative_path("../../../config/assets/icons/applets/bluetooth-off-clear.svg")
|
||||
)
|
||||
tooltip = "Bluetooth disabled"
|
||||
else:
|
||||
connected_devices = self.bluetooth.connected_devices
|
||||
if connected_devices:
|
||||
self.bt_icon.set_from_file(
|
||||
get_relative_path("../../../config/assets/icons/bluetooth.svg")
|
||||
get_relative_path("../../../config/assets/icons/applets/bluetooth-clear.svg")
|
||||
)
|
||||
if len(connected_devices) == 1:
|
||||
device = connected_devices[0]
|
||||
@@ -53,7 +52,7 @@ class BluetoothIndicator(Box):
|
||||
tooltip = f"Connected to {len(connected_devices)} devices"
|
||||
else:
|
||||
self.bt_icon.set_from_file(
|
||||
get_relative_path("../../../config/assets/icons/bluetooth.svg")
|
||||
get_relative_path("../../../config/assets/icons/applets/bluetooth-clear.svg")
|
||||
)
|
||||
tooltip = "No devices connected"
|
||||
|
||||
@@ -105,7 +104,7 @@ class NetworkIndicator(Box):
|
||||
self.network_icon = Svg(
|
||||
name="network-icon",
|
||||
size=22,
|
||||
svg_file=get_relative_path("../../../config/assets/icons/wifi.svg"),
|
||||
svg_file=get_relative_path("../../../config/assets/icons/applets/wifi-clear.svg"),
|
||||
)
|
||||
|
||||
self.network_button = Button(name="network-button", child=self.network_icon)
|
||||
@@ -177,26 +176,26 @@ class NetworkIndicator(Box):
|
||||
def update_state(self):
|
||||
primary_device = self.network_service.primary_device
|
||||
tooltip = "No network connection"
|
||||
icon_file = "wifi-off.svg"
|
||||
icon_file = "wifi-off-clear.svg"
|
||||
|
||||
if primary_device == "wifi" and self.network_service.wifi_device:
|
||||
wifi = self.network_service.wifi_device
|
||||
if not wifi.enabled:
|
||||
icon_file = "wifi-off.svg"
|
||||
icon_file = "wifi-off-clear.svg"
|
||||
tooltip = "WiFi disabled"
|
||||
elif wifi.internet == "activated":
|
||||
icon_file = "wifi.svg"
|
||||
icon_file = "wifi-clear.svg"
|
||||
tooltip = f"Connected to {wifi.ssid}"
|
||||
if wifi.strength >= 0:
|
||||
tooltip += f" ({wifi.strength}%)"
|
||||
elif wifi.internet == "activating":
|
||||
icon_file = "wifi.svg"
|
||||
icon_file = "wifi-clear.svg"
|
||||
tooltip = f"Connecting to {wifi.ssid}..."
|
||||
elif wifi.internet in ["deactivating", "deactivated", "disconnected"]:
|
||||
icon_file = "wifi-off.svg"
|
||||
icon_file = "wifi-off-clear.svg"
|
||||
tooltip = "WiFi disconnected"
|
||||
else:
|
||||
icon_file = "wifi-off.svg"
|
||||
icon_file = "wifi-off-clear.svg"
|
||||
tooltip = "WiFi disconnected"
|
||||
|
||||
elif primary_device == "wired" and self.network_service.ethernet_device:
|
||||
@@ -207,14 +206,14 @@ class NetworkIndicator(Box):
|
||||
if hasattr(ethernet, "speed") and ethernet.speed > 0:
|
||||
tooltip += f" ({ethernet.speed} Mbps)"
|
||||
elif ethernet.internet == "activating":
|
||||
icon_file = "wifi.svg"
|
||||
icon_file = "wifi-clear.svg"
|
||||
tooltip = "Ethernet connecting..."
|
||||
else:
|
||||
icon_file = "wifi-off.svg"
|
||||
icon_file = "wifi-off-clear.svg"
|
||||
tooltip = "Ethernet disconnected"
|
||||
|
||||
self.network_icon.set_from_file(
|
||||
get_relative_path(f"../../../config/assets/icons/{icon_file}")
|
||||
get_relative_path(f"../../../config/assets/icons/applets/{icon_file}")
|
||||
)
|
||||
self.network_button.set_tooltip_text(tooltip)
|
||||
|
||||
@@ -228,7 +227,7 @@ class BatteryIndicator(Box):
|
||||
self.battery_icon = Svg(
|
||||
name="battery-icon",
|
||||
size=22,
|
||||
svg_file=get_relative_path("../../../config/assets/icons/battery.svg"),
|
||||
svg_file=get_relative_path("../../../config/assets/icons/battery/battery-100.svg"),
|
||||
)
|
||||
|
||||
self.battery_button = Button(name="battery-button", child=self.battery_icon)
|
||||
|
||||
@@ -28,7 +28,7 @@ class RecordingIndicator(Button):
|
||||
self.recording_icon = Svg(
|
||||
name="indicators-icon",
|
||||
size=24,
|
||||
svg_file=get_relative_path("../../../config/assets/icons/media-record.svg"),
|
||||
svg_file=get_relative_path("../../../config/assets/icons/misc/media-record.svg"),
|
||||
)
|
||||
self.time_label = Label(
|
||||
name="recording-time-label",
|
||||
|
||||
@@ -43,7 +43,7 @@ class Panel(Window):
|
||||
name="panel-button",
|
||||
child=Svg(
|
||||
size=22,
|
||||
svg_file=get_relative_path("../../config/assets/icons/logo.svg"),
|
||||
svg_file=get_relative_path("../../config/assets/icons/misc/logo.svg"),
|
||||
),
|
||||
on_clicked=lambda *_: self.menubar.show_system_dropdown(self.imac),
|
||||
)
|
||||
@@ -63,7 +63,7 @@ class Panel(Window):
|
||||
child=Svg(
|
||||
size=16,
|
||||
svg_file=get_relative_path(
|
||||
"../../config/assets/icons/chevron-right.svg"
|
||||
"../../config/assets/icons/misc/chevron-right.svg"
|
||||
),
|
||||
),
|
||||
on_clicked=self.toggle_tray,
|
||||
@@ -85,7 +85,7 @@ class Panel(Window):
|
||||
on_clicked=lambda *_: self.search_apps(),
|
||||
child=Svg(
|
||||
size=20,
|
||||
svg_file=get_relative_path("../../config/assets/icons/search.svg"),
|
||||
svg_file=get_relative_path("../../config/assets/icons/misc/search.svg"),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -100,7 +100,7 @@ class Panel(Window):
|
||||
child=Svg(
|
||||
size=22,
|
||||
svg_file=get_relative_path(
|
||||
"../../config/assets/icons/control-center.svg"
|
||||
"../../config/assets/icons/misc/control-center.svg"
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -146,9 +146,9 @@ class Panel(Window):
|
||||
|
||||
if self.tray_revealer.child_revealed:
|
||||
self.chevron_button.get_child().set_from_file(
|
||||
get_relative_path("../../config/assets/icons/chevron-left.svg")
|
||||
get_relative_path("../../config/assets/icons/misc/chevron-left.svg")
|
||||
)
|
||||
else:
|
||||
self.chevron_button.get_child().set_from_file(
|
||||
get_relative_path("../../config/assets/icons/chevron-right.svg")
|
||||
get_relative_path("../../config/assets/icons/misc/chevron-right.svg")
|
||||
)
|
||||
Reference in new issue
Block a user