diff --git a/config/hypr/UserConfigs/Startup_Apps.conf b/config/hypr/UserConfigs/Startup_Apps.conf index 3c4ece84..3f248ec5 100644 --- a/config/hypr/UserConfigs/Startup_Apps.conf +++ b/config/hypr/UserConfigs/Startup_Apps.conf @@ -14,7 +14,7 @@ exec-once = $scriptsDir/Polkit.sh # startup apps -exec-once = cd ~/dotfiles/quickbar && python main.py +exec-once = cd ~/dotfiles/karya && python main.py exec-once = wl-gammarelay-rs & exec-once = blueman-applet & exec-once = nm-applet --indicator & diff --git a/config/hypr/UserConfigs/UserKeybinds.conf b/config/hypr/UserConfigs/UserKeybinds.conf index 1dab5707..dad7ef78 100644 --- a/config/hypr/UserConfigs/UserKeybinds.conf +++ b/config/hypr/UserConfigs/UserKeybinds.conf @@ -7,7 +7,7 @@ $mainMod = SUPER $scriptsDir = $HOME/dotfiles/hypr/scripts $RunCMD = $scriptsDir/RunCMD.sh -$fabric = python -m fabric execute quickbar +$fabric = fabric-cli exec karya # Testing bind = Alt, f12, exec, notify-send 'Test notification' "Here's a really long message to test truncation and wrapping\nYou can middle click or flick this notification to dismiss it!" -a 'terminal' -A "Test1=I got it!" -A "Test2=Another action" @@ -16,9 +16,9 @@ bind = Alt, Equal, exec, notify-send 'hmm' ${SLURP_ARGS} # Applications bind = ALT SHIFT,Return, exec, kitty --title Kitty --single-instance bind = $mainMod, Return, exec, kitty -bind = $mainMod, E, exec, thunar +bind = ALT, E, exec, thunar bind = $mainMod, B, exec, firefox -bind = $mainMod, T, exec, materialgram +bind = ALT, T, exec, materialgram # Actions bind = $mainMod SHIFT, G, exec, $RunCMD gamemode @@ -28,9 +28,9 @@ bind = SHIFT ALT,W, exec, python -O $scriptsDir/wallpaper.py -R bind = $mainMod CTRL, L, exec, pidof hyprlock || hyprlock -q bind = $mainMod CTRL, P, exec, systemctl poweroff bind = $mainMod CTRL, R, exec, systemctl reboot -bind = ALT, t, exec, killall quickbar || sleep 0.5 && python ~/dotfiles/quickbar/main.py & +bind = ALT_SHIFT, t, exec, killall karya || sleep 0.5 && python ~/karya/main.py & -bind = $mainMod, R, exec, $fabric 'sc.screencast_start(True)' +bind = $mainMod, R, exec, $fabric 'sc.screencast_start()' bind = $mainMod_SHIFT, R, exec, $fabric 'sc.screencast_stop()' bind=$mainMod,Z, exec, $fabric 'sc.screenshot()' @@ -42,9 +42,10 @@ bind = $mainMod, D, exec, $fabric 'launcher.open("launcher")' bind = $mainMod, W, exec, $fabric 'launcher.open("wallpapers")' bind = $mainMod, X, exec, $fabric 'launcher.open("power")' bind = $mainMod, V, exec, $fabric 'launcher.open("cliphist")' -bind = $mainMod, S, exec, $fabric 'launcher.open("todo")' -bind = ALT, E, exec, $fabric 'launcher.open("emoji")' -# bind = $mainMod, D, exec, walker - # bind = $mainMod, D, exec, fuzzel +bind = $mainMod, T, exec, $fabric 'launcher.open("todo")' +bind = $mainMod, E, exec, $fabric 'launcher.open("emoji")' +bind = ALT, B, exec, $fabric 'launcher.open("bluetooth")' +bind = ALT, S, exec, $fabric 'launcher.open("sh")' +bind = $mainMod, H, exec, $fabric 'bar.toggle_hidden()' diff --git a/config/quickbar/assets/config.json b/config/karya/assets/config.json similarity index 100% rename from config/quickbar/assets/config.json rename to config/karya/assets/config.json diff --git a/config/quickbar/assets/emoji.json b/config/karya/assets/emoji.json similarity index 100% rename from config/quickbar/assets/emoji.json rename to config/karya/assets/emoji.json diff --git a/config/quickbar/assets/scripts/dark-theme.sh b/config/karya/assets/scripts/dark-theme.sh similarity index 100% rename from config/quickbar/assets/scripts/dark-theme.sh rename to config/karya/assets/scripts/dark-theme.sh diff --git a/config/quickbar/assets/scripts/wayland-idle-inhibitor.py b/config/karya/assets/scripts/wayland-idle-inhibitor.py similarity index 100% rename from config/quickbar/assets/scripts/wayland-idle-inhibitor.py rename to config/karya/assets/scripts/wayland-idle-inhibitor.py diff --git a/config/quickbar/main.py b/config/karya/main.py similarity index 87% rename from config/quickbar/main.py rename to config/karya/main.py index 6237311c..1fd1e1ea 100644 --- a/config/quickbar/main.py +++ b/config/karya/main.py @@ -9,9 +9,14 @@ from modules.bar.bar import Bar from modules.launcher.launcher import Launcher from modules.notification_popup import NotificationPopup from modules.osd import OSDContainer -from services import ScreenRecorder +from services import sc -logger.disable("fabric.hyprland.widgets") +for log in [ + "fabric.hyprland.widgets", + "fabric.audio.service", + "fabric.bluetooth.service", +]: + logger.disable(log) def update_main_css(): @@ -19,7 +24,6 @@ def update_main_css(): main_css_path = get_relative_path("styles/main.css") if os.path.exists(colors_css_path): - logger.info(f"[Main] Updating colors.css path in {main_css_path}") with open(main_css_path, "r+") as css_file: content = css_file.read() updated_content = content.replace("@COLORS_CSS_PATH", colors_css_path) @@ -37,19 +41,19 @@ def apply_style(app: Application): if __name__ == "__main__": update_main_css() - sc = ScreenRecorder() + sc = sc bar = Bar() osd = OSDContainer() notif = NotificationPopup() launcher = Launcher() app = Application( - "quickbar", + "karya", bar, launcher, osd, ) - setproctitle.setproctitle("quickbar") + setproctitle.setproctitle("karya") # Monitor CSS files for changes css_file = monitor_file(get_relative_path("styles")) diff --git a/config/quickbar/modules/bar/bar.py b/config/karya/modules/bar/bar.py similarity index 78% rename from config/quickbar/modules/bar/bar.py rename to config/karya/modules/bar/bar.py index 12f7ab1f..d75e4ff1 100644 --- a/config/quickbar/modules/bar/bar.py +++ b/config/karya/modules/bar/bar.py @@ -6,7 +6,7 @@ from fabric.widgets.button import Button from fabric.widgets.centerbox import CenterBox from fabric.widgets.datetime import DateTime from fabric.widgets.wayland import WaylandWindow as Window -from modules.bar.widgets import ( +from modules.bar.components import ( BatteryLabel, BluetoothIndicator, IdleIndicator, @@ -17,22 +17,13 @@ from modules.bar.widgets import ( TaskBar, VolumeIndicator, workspace, - Recorder, ) -from services import ScreenRecorder from snippets import MaterialIcon +from services import sc class Bar(Window): def __init__(self): - super().__init__( - layer="top", - anchor="left bottom right", - exclusivity="auto", - visible=False, - all_visible=False, - ) - self.screen_recorder = ScreenRecorder() self.workspaces = Button(child=workspace, name="workspaces") self.language = Language( formatter=FormattedString( @@ -45,20 +36,20 @@ class Bar(Window): ), ), ) - self.date_time = DateTime(formatters=["%-I:%M 󰧞 %a %d %b"], name="datetime") self.recording_indicator = Button( - name="bar-button", - child=MaterialIcon("screen_record", size=16), + name="recording-indicator", + child=MaterialIcon("screen_record", 14), visible=False, - on_clicked=lambda *_: self.screen_recorder.screencast_stop(), + on_clicked=lambda *_: sc.screencast_stop(), ) - self.screen_recorder.connect( - "recording", - lambda _, status: self.recording_indicator.set_visible(status), + sc.connect( + "recording", lambda _, status: self.on_recording_status_change(status) ) + self.date_time = DateTime(formatters=["%-I:%M 󰧞 %a %d %b"], name="datetime") + self.battery = BatteryLabel(name="battery") self.volume = VolumeIndicator() self.bluetooth = BluetoothIndicator() @@ -69,7 +60,6 @@ class Bar(Window): self.info = SystemInfo() self.powerindicator = PowerProfileIndicator() self.tray = SystemTray(name="tray", icon_size=16, spacing=4) - self.recorder = Recorder() self.applets = Box( name="applets", @@ -86,7 +76,7 @@ class Bar(Window): ], ) - self.children = CenterBox( + self.bar = CenterBox( name="bar", start_children=Box( name="start-container", @@ -108,7 +98,7 @@ class Bar(Window): spacing=8, orientation="h", children=[ - self.recorder, + self.recording_indicator, self.tray, self.battery, self.applets, @@ -116,5 +106,23 @@ class Bar(Window): ], ), ) + super().__init__( + layer="top", + anchor="left bottom right", + exclusivity="auto", + visible=True, + child=self.bar, + ) - self.show_all() + self.hidden = False + + def on_recording_status_change(self, status): + print(f"Recording status changed: {status}") + self.recording_indicator.set_visible(status) + + def toggle_hidden(self): + self.hidden = not self.hidden + if self.hidden: + self.bar.add_style_class("hidden") + else: + self.bar.remove_style_class("hidden") diff --git a/config/quickbar/modules/bar/widgets/__init__.py b/config/karya/modules/bar/components/__init__.py similarity index 91% rename from config/quickbar/modules/bar/widgets/__init__.py rename to config/karya/modules/bar/components/__init__.py index 0c03b6da..278c35fd 100644 --- a/config/quickbar/modules/bar/widgets/__init__.py +++ b/config/karya/modules/bar/components/__init__.py @@ -1,7 +1,7 @@ from .battery import * from .bluetooth import * from .idle import * -from .info import * +from .stats import * from .microphone import * from .network import * from .powerprofile import * diff --git a/config/quickbar/modules/bar/widgets/battery.py b/config/karya/modules/bar/components/battery.py similarity index 100% rename from config/quickbar/modules/bar/widgets/battery.py rename to config/karya/modules/bar/components/battery.py diff --git a/config/quickbar/modules/bar/widgets/bluetooth.py b/config/karya/modules/bar/components/bluetooth.py similarity index 100% rename from config/quickbar/modules/bar/widgets/bluetooth.py rename to config/karya/modules/bar/components/bluetooth.py diff --git a/config/quickbar/modules/bar/widgets/idle.py b/config/karya/modules/bar/components/idle.py similarity index 94% rename from config/quickbar/modules/bar/widgets/idle.py rename to config/karya/modules/bar/components/idle.py index 6cfb1a0f..6ad444af 100644 --- a/config/quickbar/modules/bar/widgets/idle.py +++ b/config/karya/modules/bar/components/idle.py @@ -5,7 +5,6 @@ from snippets import MaterialIcon class IdleIndicator(Box): - def __init__(self, **kwargs): super().__init__(**kwargs) self.idle_icon = self.create_idle_icon() @@ -14,10 +13,9 @@ class IdleIndicator(Box): self.children = [self.idle_icon] def create_idle_icon(self): - return MaterialIcon("schedule", size=16) + return MaterialIcon("coffee", 16) def check_idle_status(self, *_): - output = exec_shell_command("pidof wayland-idle-inhibitor.py") is_idle = bool(str(output).strip()) self.update_idle_status(is_idle) diff --git a/config/quickbar/modules/bar/widgets/microphone.py b/config/karya/modules/bar/components/microphone.py similarity index 100% rename from config/quickbar/modules/bar/widgets/microphone.py rename to config/karya/modules/bar/components/microphone.py diff --git a/config/quickbar/modules/bar/widgets/network.py b/config/karya/modules/bar/components/network.py similarity index 100% rename from config/quickbar/modules/bar/widgets/network.py rename to config/karya/modules/bar/components/network.py diff --git a/config/quickbar/modules/bar/widgets/powerprofile.py b/config/karya/modules/bar/components/powerprofile.py similarity index 93% rename from config/quickbar/modules/bar/widgets/powerprofile.py rename to config/karya/modules/bar/components/powerprofile.py index 34884adf..a1817cc2 100644 --- a/config/quickbar/modules/bar/widgets/powerprofile.py +++ b/config/karya/modules/bar/components/powerprofile.py @@ -30,7 +30,7 @@ class PowerProfileIndicator(Box): def update_icon(self, profile): icon_name = PROFILE_ICONS.get(profile) - new_icon = MaterialIcon(icon_name, size=16) if icon_name else None + new_icon = MaterialIcon(icon_name, 16) if icon_name else None if self.profile_icon: self.remove(self.profile_icon) diff --git a/config/quickbar/modules/bar/widgets/info.py b/config/karya/modules/bar/components/stats.py similarity index 98% rename from config/quickbar/modules/bar/widgets/info.py rename to config/karya/modules/bar/components/stats.py index 18f095f8..063d318f 100644 --- a/config/quickbar/modules/bar/widgets/info.py +++ b/config/karya/modules/bar/components/stats.py @@ -21,7 +21,7 @@ class SystemInfo(Button): self.fabricator = Fabricator(poll_from=self._refresh_system_info, interval=1000) def _initialize_content(self): - self.box = Box(orientation="h", name="info") + self.box = Box(orientation="h", name="tray") self.progress_bars = {} self.labels = {} self.icons = {} diff --git a/config/karya/modules/bar/components/taskbar.py b/config/karya/modules/bar/components/taskbar.py new file mode 100644 index 00000000..09bb7bb6 --- /dev/null +++ b/config/karya/modules/bar/components/taskbar.py @@ -0,0 +1,154 @@ +import json +import os +from typing import TypedDict + +from fabric.hyprland.widgets import get_hyprland_connection +from fabric.utils import exec_shell_command_async +from fabric.widgets.box import Box +from fabric.widgets.button import Button +from fabric.widgets.image import Image +from gi.repository import GdkPixbuf, GLib, Gtk +from loguru import logger + + +class PagerClient(TypedDict): + title: str + initialClass: str + mapped: bool + hidden: bool + address: str + + +class TaskBar(Box): + def __init__(self, icon_size: int = 24, **kwargs): + super().__init__( + orientation="h", + spacing=7, + name="taskbar", + **kwargs, + ) + self.connection = get_hyprland_connection() + self.icon_size = icon_size + self.icon_theme = Gtk.IconTheme.get_default() + + self.set_visible(False) + + if self.connection.ready: + self.render_with_delay() + else: + self.connection.connect("event::ready", lambda *_: self.render_with_delay()) + + for event in ( + "activewindow", + "openwindow", + "closewindow", + "changefloatingmode", + ): + self.connection.connect("event::" + event, lambda *_: self.render(None)) + + def render_with_delay(self, *_): + GLib.timeout_add(101, self.render) + + def render(self, *_): + self.children = [] + + clients = self.fetch_clients() + active_window_address = self.get_active_window_address() + + visible_clients = [ + client for client in clients if client["mapped"] and not client["hidden"] + ] + + if visible_clients: + for client in visible_clients: + window_class = client["initialClass"].lower() + icon = self.bake_window_icon(window_class) + + button = Button(image=icon, tooltip_text=client["title"]) + if client["address"] == active_window_address: + button.add_style_class("activated") + button.connect( + "button-press-event", + self.on_icon_click, + client["address"], + ) + + self.add(button) + self.set_visible(True) + self.show_all() + else: + self.set_visible(False) + + self.set_visible(len(self.children) > 0) + if self.children: + self.show_all() + + def get_active_window_address(self) -> str: + active_window_info = json.loads( + self.connection.send_command("j/activewindow").reply.decode() + ) + return active_window_info.get("address", "") + + def on_icon_click(self, widget, event, address): + exec_shell_command_async( + f"hyprctl dispatch focuswindow address:{address}", lambda *_: None + ) + + def fetch_clients(self) -> list[PagerClient]: + return json.loads(self.connection.send_command("j/clients").reply.decode()) + + def bake_window_icon( + self, + window_class: str, + fallback_icon: str = "image-missing", + ) -> Image: + icon_name = self.get_icon_from_desktop_entry(window_class) + + if icon_name: + pixbuf = self.load_icon(icon_name) + else: + pixbuf = self.load_icon(window_class, fallback_icon) + + return Image(pixbuf=pixbuf, size=self.icon_size) + + def get_icon_from_desktop_entry(self, window_class: str) -> str: + for data_dir in GLib.get_system_data_dirs(): + applications_dir = os.path.join(data_dir, "applications") + + if os.path.isdir(applications_dir): + for desktop_file in os.listdir(applications_dir): + if desktop_file.endswith(".desktop"): + file_path = os.path.join(applications_dir, desktop_file) + try: + with open(file_path) as f: + app_name = None + icon_name = None + for line in f: + if line.startswith("Name="): + app_name = line.split("=", 2)[1].strip().lower() + elif line.startswith("Icon=") and app_name: + icon_name = line.split("=", 2)[1].strip() + if window_class in app_name: + return icon_name + except Exception as e: + logger.error(f"Error reading {file_path}: {e}") + return None + + def load_icon( + self, + icon_name: str, + fallback_icon: str = "image-missing", + ) -> GdkPixbuf.Pixbuf: + try: + pixbuf = self.icon_theme.load_icon( + icon_name, + self.icon_size, + Gtk.IconLookupFlags.FORCE_SIZE, + ) + except Exception: + pixbuf = self.icon_theme.load_icon( + fallback_icon, + self.icon_size, + Gtk.IconLookupFlags.FORCE_SIZE, + ) + return pixbuf diff --git a/config/quickbar/modules/bar/widgets/volume.py b/config/karya/modules/bar/components/volume.py similarity index 95% rename from config/quickbar/modules/bar/widgets/volume.py rename to config/karya/modules/bar/components/volume.py index b6577678..0fed57c9 100644 --- a/config/quickbar/modules/bar/widgets/volume.py +++ b/config/karya/modules/bar/components/volume.py @@ -1,9 +1,9 @@ from fabric import Fabricator -from fabric.audio.service import Audio from fabric.utils import exec_shell_command from fabric.widgets.box import Box from fabric.widgets.button import Button from snippets import MaterialIcon +from services import audio VOLUME_ICONS = { "muted": "volume_off", @@ -18,7 +18,7 @@ class VolumeIndicator(Box): def __init__(self, **kwargs): super().__init__(**kwargs) - self.audio_service = Audio() + self.audio_service = audio self.volume_icon_button = self.create_volume_icon() self.volume_icon_button.connect("button-press-event", self.on_button_press) @@ -43,7 +43,7 @@ class VolumeIndicator(Box): current_stream = self.audio_service.speaker if current_stream: current_stream.muted = not current_stream.muted - self.update_volume_status() + # self.update_volume_status() def open_audio_settings(self): exec_shell_command("pavucontrol") diff --git a/config/quickbar/modules/bar/widgets/workspace.py b/config/karya/modules/bar/components/workspace.py similarity index 100% rename from config/quickbar/modules/bar/widgets/workspace.py rename to config/karya/modules/bar/components/workspace.py diff --git a/config/quickbar/modules/launcher/widgets/__init__.py b/config/karya/modules/launcher/components/__init__.py similarity index 100% rename from config/quickbar/modules/launcher/widgets/__init__.py rename to config/karya/modules/launcher/components/__init__.py diff --git a/config/quickbar/modules/launcher/widgets/applauncher.py b/config/karya/modules/launcher/components/applauncher.py similarity index 61% rename from config/quickbar/modules/launcher/widgets/applauncher.py rename to config/karya/modules/launcher/components/applauncher.py index 1c70f3a4..0f684c78 100644 --- a/config/quickbar/modules/launcher/widgets/applauncher.py +++ b/config/karya/modules/launcher/components/applauncher.py @@ -1,14 +1,14 @@ -import operator from collections.abc import Iterator - +import operator from fabric.utils import DesktopApp, get_desktop_applications, idle_add, remove_handler from fabric.widgets.box import Box from fabric.widgets.button import Button from fabric.widgets.entry import Entry from fabric.widgets.label import Label from fabric.widgets.scrolledwindow import ScrolledWindow -from gi.repository import Gdk, GLib -from snippets import MaterialIcon +from gi.repository import GLib +from snippets import MaterialIcon, read_config +from fabric.widgets.image import Image class AppLauncher(Box): @@ -21,17 +21,16 @@ class AppLauncher(Box): ) self._arranger_handler: int = 0 self._all_apps = get_desktop_applications() + self.config = read_config() self.viewport = Box(name="viewport", spacing=4, orientation="v") self.search_entry = Entry( name="search-entry", - placeholder="Search Applications...", h_expand=True, - notify_text=lambda entry, *_: self.handle_search_input(entry.get_text()), + notify_text=self.handle_search_input, on_activate=lambda entry, *_: self.on_search_entry_activate( entry.get_text() ), - on_button_press_event=print, ) self.scrolled_window = ScrolledWindow( name="scrolled-window", @@ -43,22 +42,12 @@ class AppLauncher(Box): self.header_box = Box( name="header_box", - spacing=10, orientation="h", - children=[ - self.search_entry, - Button( - name="close-button", - child=MaterialIcon("close"), - tooltip_text="Exit", - on_clicked=lambda *_: self.close_launcher(), - ), - ], + children=[self.search_entry], ) self.launcher_box = Box( name="launcher-box", - spacing=10, h_expand=True, orientation="v", children=[ @@ -67,21 +56,37 @@ class AppLauncher(Box): ], ) + self.resize_viewport() self.add(self.launcher_box) - self.connect("key-press-event", self.on_key_press_event) self.show_all() - def close_launcher(self): - self.viewport.children = [] - GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") - def open_launcher(self): + self.viewport.children = [] self._all_apps = get_desktop_applications() self.arrange_viewport() + self.search_entry.grab_focus() - def on_key_press_event(self, widget, event): - if event.keyval == Gdk.KEY_Escape: - self.close_launcher() + def close_launcher(self, *_): + remove_handler(self._arranger_handler) if self._arranger_handler else None + self.viewport.children = [] + GLib.spawn_command_line_async("fabric-cli exec karya 'launcher.close()'") + + def handle_search_input(self, entry, *_): + text = entry.get_text().strip() + commands = self.config.get("commands", {}) + + if text in commands: + command = commands[text] + GLib.spawn_command_line_async(f"fabric-cli exec karya '{command}'") + self.search_entry.set_text("") + else: + self.arrange_viewport(text) + + def resize_viewport(self): + self.scrolled_window.set_min_content_width( + self.viewport.get_allocation().width # type: ignore + ) + return False def arrange_viewport(self, query: str = ""): remove_handler(self._arranger_handler) if self._arranger_handler else None @@ -90,7 +95,7 @@ class AppLauncher(Box): if not query.strip(): return False - filtered_apps = sorted( + filtered_apps = iter( [ app for app in self._all_apps @@ -100,15 +105,14 @@ class AppLauncher(Box): + (" " + app.name + " ") + (app.generic_name or "") ).casefold() - ], - key=lambda app: (app.display_name or "").casefold(), + ][:6] ) - - filtered_apps = filtered_apps[:6] + should_resize = operator.length_hint(filtered_apps) == len(self._all_apps) self._arranger_handler = idle_add( - lambda *args: self.add_next_application(*args), - iter(filtered_apps), + lambda *args: self.add_next_application(*args) + or (self.resize_viewport() if should_resize else False), + filtered_apps, pin=True, ) @@ -123,44 +127,24 @@ class AppLauncher(Box): def bake_application_slot(self, app: DesktopApp, **kwargs) -> Button: return Button( - name="app-slot-button", + name="launcher-app", child=Box( - name="app-slot-box", orientation="h", - spacing=10, children=[ + Image( + pixbuf=app.get_icon_pixbuf(size=32), + h_align="start", + name="launcher-app-icon", + ), Label( - name="app-label", label=app.display_name or "Unknown", - ellipsization="end", v_align="center", h_align="center", ), + Box(h_expand=True), ], ), tooltip_text=app.description, on_clicked=lambda *_: (app.launch(), self.close_launcher()), **kwargs, ) - - def handle_search_input(self, text: str): - if text.strip() == ":wp": - GLib.spawn_command_line_async( - "fabric-cli exec quickbar 'launcher.open(\"wallpapers\")'" - ) - self.search_entry.set_text("") - elif text.strip() == ":em": - GLib.spawn_command_line_async( - "fabric-cli exec quickbar 'launcher.open(\"emoji\")'" - ) - elif text.strip() == ":ch": - GLib.spawn_command_line_async( - "fabric-cli exec quickbar 'launcher.open(\"cliphist\")'" - ) - elif text.strip() == ":td": - GLib.spawn_command_line_async( - "fabric-cli exec quickbar 'launcher.open(\"todo\")'" - ) - - else: - self.arrange_viewport(text) diff --git a/config/quickbar/modules/launcher/widgets/bluetooth.py b/config/karya/modules/launcher/components/bluetooth.py similarity index 57% rename from config/quickbar/modules/launcher/widgets/bluetooth.py rename to config/karya/modules/launcher/components/bluetooth.py index 500c6d33..6578101f 100644 --- a/config/quickbar/modules/launcher/widgets/bluetooth.py +++ b/config/karya/modules/launcher/components/bluetooth.py @@ -5,9 +5,26 @@ from fabric.widgets.button import Button from fabric.widgets.entry import Entry from fabric.widgets.label import Label from fabric.widgets.scrolledwindow import ScrolledWindow -from gi.repository import Gdk, GLib +from gi.repository import GLib from snippets import MaterialIcon +DEVICE_TYPE_ICONS = { + "headset": "headphones", # Icon for headset devices + "headphones": "headphones", # Icon for audio devices + "computer": "computer", # Icon for computer devices + "phone": "smartphone", # Icon for phone devices + "tablet": "tablet", # Icon for tablet devices + "keyboard": "keyboard", # Icon for keyboard devices + "mouse": "mouse", # Icon for mouse devices + "other": "devices", # Default icon +} + +DEVICE_BATTERY_ICONS = { + "full": "battery_full", # Full battery + "medium": "battery_half", # Medium battery + "low": "battery_alert", # Low battery +} + class BluetoothManager(Box): def __init__(self, **kwargs): @@ -24,35 +41,29 @@ class BluetoothManager(Box): self.search_entry = Entry( name="search-entry", - placeholder="Search Devices...", h_expand=True, notify_text=self.handle_search_input, on_activate=self.handle_search_input, ) + self.toggle_button = Button( + on_clicked=lambda *_: self.device_manager.bluetooth_client.toggle_power() + ) + + self.device_manager.bluetooth_client.connect( + "notify::enabled", self.update_toggle_button + ) + self.header_box = Box( name="header-box", spacing=10, orientation="h", children=[ self.search_entry, + self.toggle_button, Button( - name="power-button", - child=MaterialIcon("bluetooth"), - tooltip_text="Toggle Bluetooth", - on_clicked=self.device_manager.toggle_bluetooth, - ), - Button( - name="scan-button", child=MaterialIcon("sync"), - tooltip_text="Scan for Devices", - on_clicked=self.device_manager.toggle_scan, - ), - Button( - name="close-button", - child=MaterialIcon("close"), - tooltip_text="Exit", - on_clicked=self.close_launcher, + on_clicked=lambda *_: self.device_manager.bluetooth_client.toggle_scan(), ), ], ) @@ -70,6 +81,16 @@ class BluetoothManager(Box): self.is_active = False self.polling_handler = None + def update_toggle_button(self, *_): + icon_name = ( + "bluetooth" + if self.device_manager.bluetooth_client.enabled + else "bluetooth_disabled" + ) + self.toggle_button.children = [] + self.toggle_button.add(MaterialIcon(icon_name)) + self.toggle_button.show_all() + def open_launcher(self): if not self.is_active: self.is_active = True @@ -94,20 +115,9 @@ class BluetoothManager(Box): else: self.device_manager.arrange_viewport() - def close_launcher(self): - self.is_active = False - if self.viewport: - self.viewport.children = [] - - self.stop_device_polling() - GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") - def handle_search_input(self, entry, text: str): if isinstance(text, str): - if text.lower() == ":bt": - self.open_launcher() - else: - self.device_manager.arrange_viewport(text) + self.device_manager.arrange_viewport(text) def start_device_polling(self): if not self.polling_handler and self.is_active: @@ -130,19 +140,15 @@ class DeviceManager: ) self._cached_devices = [] - def refresh_devices(self): + def refresh_devices(self, *_): if self.launcher.is_active: # Only refresh devices if Bluetooth section is open self.arrange_viewport() return True - def toggle_bluetooth(self): + def toggle_bluetooth(self, *_): self.bluetooth_client.toggle_power() self.arrange_viewport() - def toggle_scan(self): - self.bluetooth_client.toggle_scan() - self.arrange_viewport() - def on_device_added(self, client: BluetoothClient, address: str): if device := client.get_device(address): self._cached_devices.append(device) @@ -166,39 +172,95 @@ class DeviceManager: if query in name.lower(): devices.append(device) + # Sort connected devices first, then unconnected ones based on signal strength return sorted( - devices, key=lambda d: (not d.paired, d.name or "Unknown Device") + devices, + key=lambda d: ( + not d.connected, + not d.paired, + d.rssi if hasattr(d, "rssi") else 0, + ), )[:48] + def get_battery_status(self, device: BluetoothDevice) -> str: + if not device.connected: + return "not-connected" + + battery_level = device.battery_level if device.battery_level > 0 else None + battery_percentage = ( + device.battery_percentage if device.battery_percentage > 0 else None + ) + + if battery_level is None and battery_percentage is None: + return "low" # Show low if no battery info is available + + if battery_percentage is not None: + if battery_percentage >= 75: + return "full" + elif battery_percentage >= 30: + return "medium" + else: + return "low" + + # Fallback to battery level if percentage is unavailable + if battery_level is not None: + if battery_level >= 75: + return "full" + elif battery_level >= 30: + return "medium" + else: + return "low" + + return "low" + def connect_device(self, device: BluetoothDevice): device.set_connecting(not device.connected) def bake_device_slot(self, device: BluetoothDevice, **kwargs) -> Box: + device_type = device.type.lower() # Ensure device type is in lowercase + icon_name = DEVICE_TYPE_ICONS.get( + device_type, "devices" + ) # Default to 'bluetooth' + status_icon = MaterialIcon("link" if device.connected else "link_off") + # Only show battery icon for connected devices + if device.connected: + battery_status = self.get_battery_status(device) + battery_icon = MaterialIcon( + DEVICE_BATTERY_ICONS.get(battery_status, "battery_alert") + ) + else: + battery_icon = None # No battery icon for non-connected devices + + device_slot_children = [ + MaterialIcon(icon_name), + Label( + label=device.name or "Unknown Device", + h_align="start", + h_expand=True, + ), + battery_icon, + status_icon, + Button( + name="connect-button", + child=MaterialIcon( + "bluetooth_connected" if device.connected else "bluetooth_searching" + ), + tooltip_text="Disconnect" if device.connected else "Connect", + on_clicked=lambda *_: self.connect_device(device), + ), + ] + + device_slot_children = [ + child for child in device_slot_children if child is not None + ] + return Box( name="device-slot", spacing=10, orientation="h", - children=[ - Label( - label=device.name or "Unknown Device", - h_align="start", - h_expand=True, - ), - status_icon, - Button( - name="connect-button", - child=MaterialIcon( - "bluetooth_connected" - if device.connected - else "bluetooth_searching" - ), - tooltip_text="Disconnect" if device.connected else "Connect", - on_clicked=lambda *_: self.connect_device(device), - ), - ], - **kwargs, + children=device_slot_children, ) def arrange_viewport(self, query: str = ""): @@ -214,6 +276,7 @@ class DeviceManager: filtered_devices = self.query_devices(query) + # Show available (unpaired) devices first, followed by paired devices if available_devices := [d for d in filtered_devices if not d.paired]: for device in available_devices: self.launcher.viewport.add(self.bake_device_slot(device)) diff --git a/config/quickbar/modules/launcher/widgets/cliphist.py b/config/karya/modules/launcher/components/cliphist.py similarity index 73% rename from config/quickbar/modules/launcher/widgets/cliphist.py rename to config/karya/modules/launcher/components/cliphist.py index 2bcbc85f..a0579295 100644 --- a/config/quickbar/modules/launcher/widgets/cliphist.py +++ b/config/karya/modules/launcher/components/cliphist.py @@ -7,7 +7,6 @@ from fabric.utils import remove_handler from fabric.widgets.box import Box from fabric.widgets.button import Button from fabric.widgets.entry import Entry -from fabric.widgets.image import Image from fabric.widgets.label import Label from fabric.widgets.scrolledwindow import ScrolledWindow from gi.repository import GLib @@ -29,25 +28,22 @@ class Cliphist(Box): self.search_entry = Entry( name="search-entry", - placeholder="Search cliphist...", h_expand=True, notify_text=lambda entry, *_: self.handle_search_input(entry.get_text()), on_activate=lambda entry, *_: self.handle_search_input(entry.get_text()), ) + self.toggle_button = Button( + child=MaterialIcon("delete_forever"), + name="clear-launcher-button", + on_clicked=self.on_button_clicked, + ) + self.header_box = Box( name="header-box", spacing=10, orientation="h", - children=[ - self.search_entry, - Button( - name="close-button", - child=MaterialIcon("close"), - tooltip_text="Exit", - on_clicked=lambda *_: self.close_launcher(), - ), - ], + children=[self.search_entry, self.toggle_button], ) self.launcher_box = Box( @@ -60,7 +56,11 @@ class Cliphist(Box): self.add(self.launcher_box) + def on_button_clicked(self, *_): + GLib.spawn_command_line_async("cliphist wipe") + def open_launcher(self): + """Opens the clipboard history launcher.""" if not self.viewport: self.viewport = Box(name="viewport", spacing=4, orientation="v") self.scrolled_window = ScrolledWindow( @@ -79,9 +79,12 @@ class Cliphist(Box): self.search_entry.grab_focus() def close_launcher(self): - GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") + """Closes the clipboard history launcher and clears viewport.""" + self.viewport.children = [] + GLib.spawn_command_line_async("fabric-cli exec karya 'launcher.close()'") def handle_search_input(self, text: str): + """Handles search input to filter clipboard history.""" self.cliphist_manager.arrange_viewport(text) @@ -89,7 +92,6 @@ class CliphistManager: def __init__(self, launcher): self.launcher = launcher self.cliphist_history = [] - self.wl_paste_watcher = Fabricator( poll_from="wl-paste --watch echo", stream=True, interval=-1 ) @@ -98,6 +100,7 @@ class CliphistManager: ) def get_clip_history(self) -> List[dict]: + """Fetches the entire clipboard history from cliphist.""" try: result = subprocess.run( ["cliphist", "list"], capture_output=True, text=True, check=True @@ -108,15 +111,17 @@ class CliphistManager: return [] def _parse_clip_history(self, output: str) -> List[dict]: + """Parses the clipboard history output from cliphist.""" items = [] for line in output.splitlines(): if line.strip(): parts = line.strip().split(maxsplit=1) if len(parts) == 2: items.append({"id": parts[0], "content": parts[1]}) - return items[:16] + return items def copy_clip(self, clip_id: str): + """Copies a clipboard item using cliphist and closes the launcher.""" try: decode_result = subprocess.run( ["cliphist", "decode", clip_id], capture_output=True, check=True @@ -126,9 +131,10 @@ class CliphistManager: except subprocess.CalledProcessError as e: print(f"Error copying clip {clip_id}: {e}") - def save_cache_file(self, clip_id: str) -> str: - output_file = f"/tmp/cliphist/{clip_id}.png" - os.makedirs("/tmp/cliphist/", exist_ok=True) + def save_image_file(self, clip_id: str) -> str: + """Saves image clips as files in /tmp and returns the file path.""" + output_file = f"/tmp/cliphist-{clip_id}.png" + os.makedirs("/tmp", exist_ok=True) try: decode_result = subprocess.run( @@ -140,39 +146,45 @@ class CliphistManager: return output_file except (subprocess.CalledProcessError, IOError) as e: - print(f"Error saving cache file for clip {clip_id}: {e}") - return None + print(f"Error saving image file for clip {clip_id}: {e}") + return "" def query_clips(self, query: str = "") -> List[dict]: - if not query.strip(): - return self.get_clip_history() + """Filters clipboard history based on the search query.""" + history = self.get_clip_history() - filtered_clips = [ - item - for item in self.get_clip_history() - if query.lower() in item["content"].lower() + if not query.strip(): + return history[:16] + + return [item for item in history if query.lower() in item["content"].lower()][ + :16 ] - return filtered_clips def bake_clip_slot(self, item: dict) -> Button: - if "png" in item["content"].lower(): + """Creates a button slot for each clipboard entry.""" + if "[[ binary data" in item["content"].lower(): return self._create_image_button(item) return self._create_text_button(item) def _create_image_button(self, item: dict) -> Button: - output_file = self.save_cache_file(item["id"]) + """Creates a button for image clips with a background image.""" + output_file = self.save_image_file(item["id"]) if output_file and os.path.exists(output_file): button = Button( h_align="start", - child=Image(file=output_file), - on_clicked=lambda _, clip_id=item["id"]: self.copy_clip(clip_id), name="clip-img-item", + on_clicked=lambda _, clip_id=item["id"]: self.copy_clip(clip_id), + ) + + button.set_style( + f"background-image: url('{output_file}'); background-size: cover; background-position: center;" ) - button.set_style(f"background-image: url('{output_file}');") return button + return None def _create_text_button(self, item: dict) -> Button: + """Creates a button for text clips.""" return Button( child=Label( label=item["content"][:55] @@ -186,11 +198,13 @@ class CliphistManager: ) def update_cliphist_history(self): + """Updates the clipboard history when a new item is copied.""" self.cliphist_history = self.get_clip_history() if self.launcher.viewport: - self.arrange_viewport() + GLib.idle_add(self.arrange_viewport) def arrange_viewport(self, query: str = ""): + """Arranges the viewport based on the search query.""" if not self.launcher.viewport: return diff --git a/config/quickbar/modules/launcher/widgets/dashboard.py b/config/karya/modules/launcher/components/dashboard.py similarity index 100% rename from config/quickbar/modules/launcher/widgets/dashboard.py rename to config/karya/modules/launcher/components/dashboard.py diff --git a/config/quickbar/modules/launcher/widgets/emoji.py b/config/karya/modules/launcher/components/emoji.py similarity index 91% rename from config/quickbar/modules/launcher/widgets/emoji.py rename to config/karya/modules/launcher/components/emoji.py index b8149020..a4b78271 100644 --- a/config/quickbar/modules/launcher/widgets/emoji.py +++ b/config/karya/modules/launcher/components/emoji.py @@ -28,7 +28,6 @@ class Emoji(Box): self.search_entry = Entry( name="search-entry", - placeholder="Search Emojis...", h_expand=True, notify_text=lambda entry, *_: self.handle_search_input(entry.get_text()), on_activate=lambda entry, *_: self.handle_search_input(entry.get_text()), @@ -40,17 +39,10 @@ class Emoji(Box): orientation="h", children=[ self.search_entry, - Button( - name="close-button", - child=MaterialIcon("close"), - tooltip_text="Exit", - on_clicked=lambda *_: self.close_launcher(), - ), ], ) self.launcher_box = Box( - name="emoji-launcher-box", spacing=10, orientation="v", h_expand=True, @@ -78,7 +70,7 @@ class Emoji(Box): self.search_entry.grab_focus() def close_launcher(self): - GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") + GLib.spawn_command_line_async("fabric-cli exec karya'launcher.close()'") def handle_search_input(self, text: str): self.emoji_manager.arrange_viewport(text) diff --git a/config/quickbar/modules/launcher/widgets/power.py b/config/karya/modules/launcher/components/power.py similarity index 75% rename from config/quickbar/modules/launcher/widgets/power.py rename to config/karya/modules/launcher/components/power.py index 0150e1e8..81a9f7da 100644 --- a/config/quickbar/modules/launcher/widgets/power.py +++ b/config/karya/modules/launcher/components/power.py @@ -8,7 +8,7 @@ from snippets import MaterialIcon class PowerMenu(Box): def __init__(self, **kwargs): super().__init__( - name="power-menu", + name="powermenu", orientation="h", spacing=10, v_align="center", @@ -20,32 +20,32 @@ class PowerMenu(Box): ) self.btn_lock = Button( - name="power-menu-button", - child=MaterialIcon("lock", 50), + name="powermenu-button", + child=MaterialIcon("lock", 45), on_clicked=self.lock, ) self.btn_suspend = Button( - name="power-menu-button", - child=MaterialIcon("sleep", 50), + name="powermenu-button", + child=MaterialIcon("sleep", 45), on_clicked=self.suspend, ) self.btn_logout = Button( - name="power-menu-button", - child=MaterialIcon("logout", 50), + name="powermenu-button", + child=MaterialIcon("logout", 45), on_clicked=self.logout, ) self.btn_reboot = Button( - name="power-menu-button", - child=MaterialIcon("restart_alt", 50), + name="powermenu-button", + child=MaterialIcon("restart_alt", 45), on_clicked=self.reboot, ) self.btn_shutdown = Button( - name="power-menu-button", - child=MaterialIcon("power_settings_new", 50), + name="powermenu-button", + child=MaterialIcon("power_settings_new", 45), on_clicked=self.poweroff, ) @@ -63,7 +63,7 @@ class PowerMenu(Box): self.show_all() def close_menu(self): - GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") + GLib.spawn_command_line_async("fabric-cli exec karya 'launcher.close()'") def lock(self, *_): GLib.spawn_command_line_async("hyprlock --immediate") diff --git a/config/quickbar/modules/launcher/widgets/sh.py b/config/karya/modules/launcher/components/sh.py similarity index 86% rename from config/quickbar/modules/launcher/widgets/sh.py rename to config/karya/modules/launcher/components/sh.py index 4ef96f84..b03de3d9 100644 --- a/config/quickbar/modules/launcher/widgets/sh.py +++ b/config/karya/modules/launcher/components/sh.py @@ -1,13 +1,12 @@ import os import subprocess from typing import List - +from gi.repository import GLib from fabric.widgets.box import Box from fabric.widgets.button import Button from fabric.widgets.entry import Entry from fabric.widgets.label import Label from fabric.widgets.scrolledwindow import ScrolledWindow -from gi.repository import GLib from snippets import MaterialIcon CACHE_DIR = os.getenv( @@ -19,7 +18,6 @@ BINS = os.path.join(CACHE_DIR, "binaries") class Sh(Box): def __init__(self, **kwargs): super().__init__( - name="shell-command-launcher", all_visible=False, visible=False, **kwargs, @@ -31,29 +29,18 @@ class Sh(Box): self.search_entry = Entry( name="search-entry", - placeholder="Search Commands...", h_expand=True, notify_text=lambda entry, *_: self.handle_search_input(entry.get_text()), on_activate=lambda entry, *_: self.handle_search_input(entry.get_text()), ) self.header_box = Box( - name="header-box", spacing=10, orientation="h", - children=[ - self.search_entry, - Button( - name="close-button", - child=MaterialIcon("close"), - tooltip_text="Exit", - on_clicked=lambda *_: self.close_launcher(), - ), - ], + children=[self.search_entry, MaterialIcon("terminal")], ) self.launcher_box = Box( - name="shell-command-launcher-box", spacing=10, orientation="v", h_expand=True, @@ -80,9 +67,6 @@ class Sh(Box): self.viewport.show() self.search_entry.grab_focus() - def close_launcher(self): - GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") - def handle_search_input(self, text: str): self.shell_command_manager.show_shell_commands(self.viewport, text) @@ -142,6 +126,9 @@ class ShellCommandManager: ) viewport.add(button) + def close_menu(self): + GLib.spawn_command_line_async("fabric-cli exec karya 'launcher.close()'") + def execute_command(self, cmd: str): try: output = subprocess.check_output(cmd, shell=True, text=True) @@ -149,4 +136,4 @@ class ShellCommandManager: except subprocess.CalledProcessError as e: print(e.output) finally: - self.launcher.set_visible(False) + self.close_menu() diff --git a/config/quickbar/modules/launcher/widgets/todo.py b/config/karya/modules/launcher/components/todo.py similarity index 91% rename from config/quickbar/modules/launcher/widgets/todo.py rename to config/karya/modules/launcher/components/todo.py index 0c25b5b4..d6e5ec74 100644 --- a/config/quickbar/modules/launcher/widgets/todo.py +++ b/config/karya/modules/launcher/components/todo.py @@ -1,8 +1,6 @@ import json import os -from typing import List -from fabric import Fabricator from fabric.widgets.box import Box from fabric.widgets.button import Button from fabric.widgets.entry import Entry @@ -27,7 +25,6 @@ class TodoManager(Box): self.todo_entry = Entry( name="todo-entry", - placeholder="Add new todo...", h_expand=True, on_activate=lambda entry, *_: self.handle_add_todo(entry.get_text()), ) @@ -46,12 +43,6 @@ class TodoManager(Box): self.todo_entry.get_text() ), ), - Button( - name="close-button", - child=MaterialIcon("close"), - tooltip_text="Exit", - on_clicked=lambda *_: self.close_launcher(), - ), ], ) @@ -83,9 +74,6 @@ class TodoManager(Box): self.viewport.show() self.todo_entry.grab_focus() - def close_launcher(self): - GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") - def handle_add_todo(self, text: str): if text.strip(): self.todo_manager.add_todo(text) diff --git a/config/quickbar/modules/launcher/widgets/wallpapers.py b/config/karya/modules/launcher/components/wallpapers.py similarity index 83% rename from config/quickbar/modules/launcher/widgets/wallpapers.py rename to config/karya/modules/launcher/components/wallpapers.py index d09babe0..bf245cce 100644 --- a/config/quickbar/modules/launcher/widgets/wallpapers.py +++ b/config/karya/modules/launcher/components/wallpapers.py @@ -8,6 +8,7 @@ from fabric.widgets.entry import Entry from fabric.widgets.scrolledwindow import ScrolledWindow from gi.repository import GdkPixbuf, GLib, Gtk from snippets import MaterialIcon +from fabric.utils import exec_shell_command, get_relative_path class WallpaperSelector(Box): @@ -26,13 +27,13 @@ class WallpaperSelector(Box): "Content": "content", } - def __init__(self, wallpapers_dir: str, **kwargs): + def __init__(self, **kwargs): super().__init__(name="wallpapers", spacing=4, orientation="v", **kwargs) - self.wallpapers_dir = wallpapers_dir + self.wallpapers_dir = os.path.expanduser("~/Pictures/wallpapers") os.makedirs(self.CACHE_DIR, exist_ok=True) - self.files = [f for f in os.listdir(wallpapers_dir) if self._is_image(f)] + self.files = [f for f in os.listdir(self.wallpapers_dir) if self._is_image(f)] self.thumbnails = [] self._init_viewport() @@ -62,7 +63,6 @@ class WallpaperSelector(Box): def _init_search_entry(self): self.search_entry = Entry( name="search-entry", - placeholder="Search Wallpapers...", h_expand=True, notify_text=lambda entry, *_: self.arrange_viewport(entry.get_text()), ) @@ -78,9 +78,15 @@ class WallpaperSelector(Box): self.scheme_dropdown.set_active_id("tonalSpot") self.scheme_dropdown.connect("changed", self.on_scheme_changed) + initial_icon = "light_mode" if not self.check_dark_mode_state() else "dark_mode" + self.toggle_button = Button( + child=MaterialIcon(initial_icon), + name="toggle-launcher-button", + on_clicked=self.toggle_dark_mode, + ) + self.dropdown_box = Box( name="dropdown-box", - spacing=10, orientation="h", children=[ self.scheme_dropdown, @@ -93,24 +99,12 @@ class WallpaperSelector(Box): name="header-box", spacing=10, orientation="h", - children=[ - self.search_entry, - self.dropdown_box, - Button( - name="close-button", - child=MaterialIcon("close"), - tooltip_text="Close Selector", - on_clicked=lambda *_: self.close_selector(), - ), - ], + children=[self.search_entry, self.dropdown_box, self.toggle_button], ) self.add(self.header_box) self.add(self.scrolled_window) - def close_selector(self): - GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") - def arrange_viewport(self, query: str = ""): self.viewport.get_model().clear() filtered_thumbnails = [ @@ -124,6 +118,22 @@ class WallpaperSelector(Box): for pixbuf, file_name in filtered_thumbnails: self.viewport.get_model().append([pixbuf, file_name]) + def toggle_dark_mode(self, *_): + GLib.spawn_command_line_async( + f"bash {get_relative_path('../../../assets/scripts/dark-theme.sh --toggle')}" + ) + icon_name = "dark_mode" if not self.check_dark_mode_state() else "light_mode" + if self.toggle_button.get_child(): + self.toggle_button.remove(self.toggle_button.get_child()) + self.toggle_button.add(MaterialIcon(icon_name)) + self.toggle_button.show_all() + + def check_dark_mode_state(self): + result = exec_shell_command( + "gsettings get org.gnome.desktop.interface color-scheme" + ) + return result.strip().replace("'", "") == "prefer-dark" + def on_wallpaper_selected(self, iconview, path): model = iconview.get_model() file_name = model[path][1] @@ -142,9 +152,8 @@ class WallpaperSelector(Box): name for name, id in self.SCHEMES.items() if id == scheme_id ) print(f"Color scheme selected: {display_name} ({scheme_id})") - self.update_scheme(scheme_id) # Update the settings file + self.update_scheme(scheme_id) - # Apply the selected scheme immediately home_dir = GLib.get_home_dir() color_generator = os.path.join(home_dir, "dotfiles/material-colors/generate.py") try: diff --git a/config/quickbar/modules/launcher/widgets/wifi.py b/config/karya/modules/launcher/components/wifi.py similarity index 100% rename from config/quickbar/modules/launcher/widgets/wifi.py rename to config/karya/modules/launcher/components/wifi.py diff --git a/config/quickbar/modules/launcher/launcher.py b/config/karya/modules/launcher/launcher.py similarity index 79% rename from config/quickbar/modules/launcher/launcher.py rename to config/karya/modules/launcher/launcher.py index 5feb0fdc..010986ed 100644 --- a/config/quickbar/modules/launcher/launcher.py +++ b/config/karya/modules/launcher/launcher.py @@ -1,10 +1,7 @@ -import os - from fabric.widgets.centerbox import CenterBox from fabric.widgets.stack import Stack from fabric.widgets.wayland import WaylandWindow as Window -from gi.repository import Gdk, GLib -from modules.launcher.widgets import ( +from modules.launcher.components import ( AppLauncher, BluetoothManager, Cliphist, @@ -23,10 +20,11 @@ class Launcher(Window): anchor="center", visible=False, all_visible=False, + **kwargs, ) self.launcher = AppLauncher() - self.wallpapers = WallpaperSelector(os.path.expanduser("~/Pictures/wallpapers")) + self.wallpapers = WallpaperSelector() self.power = PowerMenu() self.emoji = Emoji() self.cliphist = Cliphist() @@ -34,7 +32,6 @@ class Launcher(Window): self.bluetooth = BluetoothManager() self.sh = Sh() - # Initialize viewports as None self._emoji_viewport = None self._cliphist_viewport = None self._todo_viewport = None @@ -61,38 +58,15 @@ class Launcher(Window): self.launcher_box = CenterBox( name="launcher", - orientation="h", - h_align="center", - v_align="center", + orientation="v", start_children=self.stack, ) self.add(self.launcher_box) - self.setup_widgets() - - self.connect("key-press-event", self.on_key_press) - self.connect("delete-event", lambda w, e: self.close()) - - def setup_widgets(self): self.show_all() self.hide() self.wallpapers.viewport.hide() - - def on_key_press(self, widget, event): - if event.keyval == Gdk.KEY_Escape: - self.close() - return True - return False - - def on_button_enter(self, widget, event): - window = widget.get_window() - if window: - window.set_cursor(Gdk.Cursor(Gdk.CursorType.HAND2)) - - def on_button_leave(self, widget, event): - window = widget.get_window() - if window: - window.set_cursor(None) + self.add_keybinding("Escape", lambda *_: self.close()) def close(self): self.set_keyboard_mode("none") @@ -110,8 +84,6 @@ class Launcher(Window): self.bluetooth, self.sh, ]: - widget.remove_style_class("open") - if widget == self.wallpapers: self.wallpapers.viewport.hide() self.wallpapers.viewport.set_property("name", None) @@ -151,6 +123,8 @@ class Launcher(Window): if self.stack.get_style_context().has_class(style_class): self.stack.get_style_context().remove_class(style_class) + self.stack.set_visible_child(self.launcher) + return True def open(self, widget): @@ -168,18 +142,17 @@ class Launcher(Window): "sh": self.sh, } + if widget is None: + widget = "launcher" + style_classes = list(widgets.keys()) for style_class in style_classes: if self.stack.get_style_context().has_class(style_class): self.stack.get_style_context().remove_class(style_class) - for w in widgets.values(): - w.remove_style_class("open") - if widget in widgets: self.stack.get_style_context().add_class(widget) self.stack.set_visible_child(widgets[widget]) - widgets[widget].add_style_class("open") if widget == "launcher": self.launcher.open_launcher() @@ -189,15 +162,8 @@ class Launcher(Window): elif widget == "wallpapers": self.wallpapers.search_entry.set_text("") self.wallpapers.search_entry.grab_focus() - GLib.timeout_add( - 500, - lambda: ( - self.wallpapers.viewport.show(), - self.wallpapers.viewport.set_property( - "name", "wallpaper-icons" - ), - ), - ) + self.wallpapers.viewport.show() + self.wallpapers.viewport.set_property("name", "wallpaper-icons") elif widget == "emoji": self.emoji.open_launcher() diff --git a/config/quickbar/modules/notification_popup.py b/config/karya/modules/notification_popup.py similarity index 97% rename from config/quickbar/modules/notification_popup.py rename to config/karya/modules/notification_popup.py index ff60e3a9..8835778c 100644 --- a/config/quickbar/modules/notification_popup.py +++ b/config/karya/modules/notification_popup.py @@ -24,7 +24,6 @@ from snippets import Animator, CustomImage class AnimatedCircularProgressBar(CircularProgressBar): - def __init__(self, duration=0.6, bezier_curve=(0.34, 1.56, 0.64, 1.0), **kwargs): super().__init__(**kwargs) @@ -139,7 +138,6 @@ class NotificationWidget(Box): body_container = Box(spacing=4, orientation="h") - # Use provided image if available, otherwise use "notification-symbolic" icon if image_pixbuf := self._notification.image_pixbuf: body_container.add( Box( @@ -214,13 +212,11 @@ class NotificationWidget(Box): self._timer = None def get_icon(self, app_icon, app_name, size) -> Image: - # Normalize app_name app_name = ( app_name.lower().replace(" ", "-") if isinstance(app_name, str) else app_name ) - # Attempt to load file-based icons if isinstance(app_icon, str) and app_icon.strip(): if app_icon.startswith("file://") or app_icon.startswith("/"): file_path = app_icon[7:] if app_icon.startswith("file://") else app_icon @@ -240,7 +236,6 @@ class NotificationWidget(Box): else: icon_name = "dialog-information-symbolic" - # Return a symbolic icon as fallback return Image(name="notification-icon", icon_name=icon_name, icon_size=size) def on_button_press(self, _, event): diff --git a/config/quickbar/modules/osd.py b/config/karya/modules/osd.py similarity index 95% rename from config/quickbar/modules/osd.py rename to config/karya/modules/osd.py index 47e82493..bdd2ef9d 100644 --- a/config/quickbar/modules/osd.py +++ b/config/karya/modules/osd.py @@ -1,14 +1,13 @@ import time from typing import ClassVar, Literal - -from fabric.audio import Audio +from fabric.utils import invoke_repeater from fabric.widgets.box import Box from fabric.widgets.revealer import Revealer from fabric.widgets.scale import Scale, ScaleMark from fabric.widgets.wayland import WaylandWindow as Window -from gi.repository import GLib, GObject -from services.brightness import Brightness +from gi.repository import GObject from snippets import Animator, MaterialIcon +from services import brightness, audio class AnimatedScale(Scale): @@ -35,7 +34,7 @@ class AnimatedScale(Scale): class BrightnessOSDContainer(Box): def __init__(self, **kwargs): super().__init__(**kwargs, orientation="h", spacing=12, name="osd") - self.brightness_service = Brightness() + self.brightness_service = brightness self.icon = MaterialIcon(icon_name="brightness_7", size=28) self.scale = AnimatedScale( marks=(ScaleMark(value=i) for i in range(0, 101, 10)), @@ -101,7 +100,7 @@ class AudioOSDContainer(Box): def __init__(self, **kwargs): super().__init__(**kwargs, orientation="h", spacing=13, name="osd") - self.audio = Audio() + self.audio = audio self.icon = MaterialIcon(icon_name="volume_up", size=28) self.scale = AnimatedScale( marks=(ScaleMark(value=i) for i in range(1, 100, 10)), @@ -169,8 +168,8 @@ class OSDContainer(Window): self.timeout = 1000 self.revealer = Revealer( - transition_type="slide-up", - transition_duration=100, + transition_type="slide-right", + transition_duration=200, child_revealed=False, ) @@ -198,7 +197,7 @@ class OSDContainer(Window): ) self.audio_container.connect("volume-changed", self.show_audio) - GLib.timeout_add(100, self.check_inactivity) + invoke_repeater(100, self.check_inactivity, initial_call=True) def show_audio(self, *_): self.show_box(box_to_show="audio") diff --git a/config/karya/services/__init__.py b/config/karya/services/__init__.py new file mode 100644 index 00000000..b464ce63 --- /dev/null +++ b/config/karya/services/__init__.py @@ -0,0 +1,9 @@ +from fabric.audio import Audio +from .brightness import Brightness +from .screen_record import ScreenRecorder +from .wifi import * + + +brightness = Brightness() +audio = Audio() +sc = ScreenRecorder() diff --git a/config/quickbar/services/brightness.py b/config/karya/services/brightness.py similarity index 100% rename from config/quickbar/services/brightness.py rename to config/karya/services/brightness.py diff --git a/config/quickbar/services/screen_record.py b/config/karya/services/screen_record.py similarity index 92% rename from config/quickbar/services/screen_record.py rename to config/karya/services/screen_record.py index 5f2f12c1..7fbf6d5b 100644 --- a/config/quickbar/services/screen_record.py +++ b/config/karya/services/screen_record.py @@ -7,14 +7,13 @@ from gi.repository import Gio, GLib from loguru import logger - class ScreenRecorder(Service): @Signal def recording(self, value: bool) -> None: ... - def __init__(self, **kwargs): + def __init__(self, **kwargs): self.screenshot_path = GLib.get_home_dir() + "/Pictures/Screenshots/" - self.screenrecord_path = GLib.get_home_dir() + "/Videos/Screenrecords/" + self.screenrecord_path = GLib.get_home_dir() + "/Videos/Screencasting/" super().__init__(**kwargs) @@ -24,16 +23,16 @@ class ScreenRecorder(Service): command = ( ["grimblast", "copysave", "screen", file_path] if save_copy - else ["grimblast", "copy" "screen"] + else ["grimblast", "copyscreen"] ) if not fullscreen: - command[3] = "area" + command[2] = "area" try: subprocess.run(command, check=True) self.send_screenshot_notification( file_path=file_path if file_path else None, ) - except Exception: + except Exception as e: logger.error(f"[SCREENSHOT] Failed to run command: {command}") def screencast_start(self, fullscreen=False): @@ -44,7 +43,6 @@ class ScreenRecorder(Service): return time = datetime.datetime.today().strftime("%Y-%m-%d_%H-%M-%S") file_path = self.screenrecord_path + str(time) + ".mp4" - self._current_screencast_path = file_path area = "" if fullscreen else f"-g '{exec_shell_command('slurp')}'" command = f"wf-recorder --file={file_path} --pixel-format yuv420p {area}" @@ -57,6 +55,9 @@ class ScreenRecorder(Service): self.send_screencast_notification(self._current_screencast_path) def send_screencast_notification(self, file_path): + # TODO: Generate a thumbnail + # exec_shell_command_async(f"totem-video-thumbnailer {file_path} {FABRIC_CACHE}") + cmd = ["notify-send"] cmd.extend( [ @@ -138,5 +139,4 @@ class ScreenRecorder(Service): @Property(bool, "readable", default_value=False) def is_recording(self): - return len(exec_shell_command("pidof wf-recorder")) != 0 - + return False if len(exec_shell_command("pidof wf-recorder")) == 0 else True diff --git a/config/quickbar/services/wifi.py b/config/karya/services/wifi.py similarity index 70% rename from config/quickbar/services/wifi.py rename to config/karya/services/wifi.py index b7ec7b27..b048f230 100644 --- a/config/quickbar/services/wifi.py +++ b/config/karya/services/wifi.py @@ -1,11 +1,14 @@ -from typing import List, Literal - +from typing import Any, List, Literal import gi from fabric.core.service import Property, Service, Signal -from fabric.utils import bulk_connect, exec_shell_command_async +from fabric.utils import bulk_connect from gi.repository import Gio from loguru import logger +from fabric.utils import exec_shell_command_async + +from gi.repository.NM import DeviceEthernet, DeviceWifi + try: gi.require_version("NM", "1.0") from gi.repository import NM @@ -146,11 +149,9 @@ class Wifi(Service): "bssid": ap.get_bssid(), # "address": ap.get_ "last_seen": ap.get_last_seen(), - "ssid": ( - NM.utils_ssid_to_utf8(ap.get_ssid().get_data()) - if ap.get_ssid() - else "Unknown" - ), + "ssid": NM.utils_ssid_to_utf8(ap.get_ssid().get_data()) + if ap.get_ssid() + else "Unknown", "active-ap": self._ap, "strength": ap.get_strength(), "frequency": ap.get_frequency(), @@ -193,6 +194,64 @@ class Wifi(Service): }.get(self._device.get_state(), "unknown") +class Ethernet(Service): + @Signal + def changed(self) -> None: ... + + @Signal + def enabled(self) -> bool: ... + + @Property(int, "readable") + def speed(self) -> int: + return self._device.get_speed() + + @Property(str, "readable") + def internet(self) -> str: + return { + NM.ActiveConnectionState.ACTIVATED: "activated", + NM.ActiveConnectionState.ACTIVATING: "activating", + NM.ActiveConnectionState.DEACTIVATING: "deactivating", + NM.ActiveConnectionState.DEACTIVATED: "deactivated", + }.get( + self._device.get_active_connection().get_state(), + "disconnected", + ) + + @Property(str, "readable") + def icon_name(self) -> str: + network = self.internet + if network == "activated": + return "network-wired-symbolic" + + elif network == "activating": + return "network-wired-acquiring-symbolic" + + elif self._device.get_connectivity != NM.ConnectivityState.FULL: + return "network-wired-no-route-symbolic" + + return "network-wired-disconnected-symbolic" + + def __init__(self, client: NM.Client, device: NM.DeviceEthernet, **kwargs) -> None: + super().__init__(**kwargs) + self._client: NM.Client = client + self._device: NM.DeviceEthernet = device + + for pn in ( + "active-connection", + "icon-name", + "internet", + "speed", + "state", + ): + self._device.connect(f"notify::{pn}", lambda *_: self.notifier(pn)) + + self._device.connect("notify::speed", lambda *_: print(_)) + + def notifier(self, pn): + self.notify(pn) + self.emit("changed") + + class NetworkClient(Service): @Signal def device_ready(self) -> None: ... @@ -200,6 +259,7 @@ class NetworkClient(Service): def __init__(self, **kwargs): self._client: NM.Client | None = None self.wifi_device: Wifi | None = None + self.ethernet_device: Ethernet | None = None super().__init__(**kwargs) NM.Client.new_async( cancellable=None, @@ -209,33 +269,44 @@ class NetworkClient(Service): def _init_network_client(self, client: NM.Client, task: Gio.Task, **kwargs): self._client = client - wifi_device: NM.DeviceWifi = self._get_device(NM.DeviceType.WIFI) # type: ignore - # eth_device: NM.DeviceEthernet = self._get_device(NM.DeviceType.ETHERNET) # type: ignore + wifi_device: NM.DeviceWifi | None = self._get_device(NM.DeviceType.WIFI) # type: ignore + ethernet_device: NM.DeviceEthernet | None = self._get_device( + NM.DeviceType.ETHERNET + ) if wifi_device: self.wifi_device = Wifi(self._client, wifi_device) self.emit("device-ready") - # if eth_device: - # self.eth_device = Ethernet(self._client, eth_device) + if ethernet_device: + self.ethernet_device = Ethernet(client=self._client, device=ethernet_device) + self.emit("device-ready") - def _get_device(self, device_type) -> NM.Device | None: + self.notify("primary-device") + + def _get_device(self, device_type) -> Any: devices: List[NM.Device] = self._client.get_devices() # type: ignore - return next((x for x in devices if x.get_device_type() == device_type), None) + return next( + ( + x + for x in devices + if x.get_device_type() == device_type + and x.get_active_connection() != None + ), + None, + ) - def get_primary_device(self) -> Literal["wifi", "wired"] | None: + def _get_primary_device(self) -> Literal["wifi", "wired"] | None: if not self._client: return None return ( "wifi" if "wireless" in str(self._client.get_primary_connection().get_connection_type()) - else ( - "wired" - if "ethernet" - in str(self._client.get_primary_connection().get_connection_type()) - else None - ) + else "wired" + if "ethernet" + in str(self._client.get_primary_connection().get_connection_type()) + else None ) def connect_wifi_bssid(self, bssid): @@ -246,4 +317,5 @@ class NetworkClient(Service): @Property(str, "readable") def primary_device(self) -> Literal["wifi", "wired"] | None: - return self.get_primary_device() + return self._get_primary_device() + diff --git a/config/quickbar/snippets/__init__.py b/config/karya/snippets/__init__.py similarity index 57% rename from config/quickbar/snippets/__init__.py rename to config/karya/snippets/__init__.py index add4b114..e95877aa 100644 --- a/config/quickbar/snippets/__init__.py +++ b/config/karya/snippets/__init__.py @@ -1,5 +1,4 @@ from .animator import * from .custom_image import * -from .functions import * +from .config import * from .icon import * -from .icon_resolver import * diff --git a/config/quickbar/snippets/animator.py b/config/karya/snippets/animator.py similarity index 100% rename from config/quickbar/snippets/animator.py rename to config/karya/snippets/animator.py diff --git a/config/quickbar/snippets/functions.py b/config/karya/snippets/config.py similarity index 95% rename from config/quickbar/snippets/functions.py rename to config/karya/snippets/config.py index f9606e31..7780604e 100644 --- a/config/quickbar/snippets/functions.py +++ b/config/karya/snippets/config.py @@ -9,7 +9,7 @@ from loguru import logger def read_config(): home_dir = GLib.get_home_dir() - config_path = f"{home_dir}/fabric/assets/config.json" + config_path = f"{home_dir}/karya/assets/config.json" with open(config_path, "r") as file: # Load JSON data into a Python dictionary diff --git a/config/quickbar/snippets/custom_image.py b/config/karya/snippets/custom_image.py similarity index 100% rename from config/quickbar/snippets/custom_image.py rename to config/karya/snippets/custom_image.py diff --git a/config/quickbar/snippets/icon.py b/config/karya/snippets/icon.py similarity index 100% rename from config/quickbar/snippets/icon.py rename to config/karya/snippets/icon.py diff --git a/config/quickbar/styles/launcher/applauncher.css b/config/karya/styles/applauncher.css similarity index 60% rename from config/quickbar/styles/launcher/applauncher.css rename to config/karya/styles/applauncher.css index 87b7f793..30a37c4e 100644 --- a/config/quickbar/styles/launcher/applauncher.css +++ b/config/karya/styles/applauncher.css @@ -1,4 +1,4 @@ -#app-slot-button { +#launcher-app { border-radius: 16px; padding: 16px; transition: padding 0.25s cubic-bezier(0.5, 0.25, 0, 1); @@ -9,23 +9,24 @@ 0% { opacity: 0; } + 100% { opacity: 1; } } -#app-slot-button:hover, -#app-slot-button:focus { - background-color: mix(@onSurface, @surface, 0.92); - padding-left: 24px; +#launcher-app:hover image, +#launcher-app:focus imgae { + -gtk-icon-shadow: 2px 2px @primary; } -#app-slot-button:active { - background-color: @primaryContainer; +#launcher-app:hover, +#launcher-app:focus { + text-shadow: 2pt 2pt 2pt @primary; } -#app-label { - color: @onSurface; +#launcher-app-icon { + margin-right: 8px; } #wallpaper-icons { @@ -36,6 +37,7 @@ from { opacity: 0; } + to { opacity: 1; } diff --git a/config/quickbar/styles/bar.css b/config/karya/styles/bar.css similarity index 92% rename from config/quickbar/styles/bar.css rename to config/karya/styles/bar.css index d1edd9b0..04f3be6e 100644 --- a/config/quickbar/styles/bar.css +++ b/config/karya/styles/bar.css @@ -1,14 +1,36 @@ +#recording-indicator { + animation: error 0.8s linear infinite alternate; +} + +@keyframes error { + to { + background-color: @onError; + } +} + +#recording-indicator { + padding: 6px 12px 6px 12px; + border-radius: 99px; +} + #bar { background-color: @surface; padding: 3px; + opacity: 1; } #bar label { font-weight: bold; } +#bar.hidden { + opacity: 0; + padding: 3px; + margin-bottom: -52px; +} + /* - * ── bar moudles ─────────────────────────────────────────────────────── + * ── bar modules ─────────────────────────────────────────────────────── */ #start-container, @@ -152,6 +174,7 @@ menu > menuitem:hover > label { border-radius: 100px; border: 0px; } + #taskbar > button:last-child { margin-right: 0px; } diff --git a/config/quickbar/styles/launcher/bluetooth.css b/config/karya/styles/bluetooth.css similarity index 100% rename from config/quickbar/styles/launcher/bluetooth.css rename to config/karya/styles/bluetooth.css diff --git a/config/quickbar/styles/launcher/cliphist.css b/config/karya/styles/cliphist.css similarity index 97% rename from config/quickbar/styles/launcher/cliphist.css rename to config/karya/styles/cliphist.css index 52afcb1a..fffb40bc 100644 --- a/config/quickbar/styles/launcher/cliphist.css +++ b/config/karya/styles/cliphist.css @@ -17,8 +17,9 @@ background-color: transparent; background-image: none; box-shadow: none; - padding: 7px; + padding: 3px; } + #cliphist-launcher-box button#clip-item { font-size: 24px; } diff --git a/config/quickbar/styles/launcher/dashboard.css b/config/karya/styles/dashboard.css similarity index 100% rename from config/quickbar/styles/launcher/dashboard.css rename to config/karya/styles/dashboard.css diff --git a/config/quickbar/styles/launcher/emoji.css b/config/karya/styles/emoji.css similarity index 100% rename from config/quickbar/styles/launcher/emoji.css rename to config/karya/styles/emoji.css diff --git a/config/karya/styles/launcher.css b/config/karya/styles/launcher.css new file mode 100644 index 00000000..8b2115af --- /dev/null +++ b/config/karya/styles/launcher.css @@ -0,0 +1,241 @@ +#launcher { + margin: 18px; + border: 1px solid @outlineVariant; + background-color: @surface; + border-radius: 24px; + padding: 18px; + transition: all 0.5s cubic-bezier(0.5, 0.25, 0, 1); +} + +#launcher entry { + transition: all 0.1s ease; + border-radius: 11px; + padding: 10px; + margin: 12px; + box-shadow: inset 0 0 0 1px @outlineVariant; +} + +#launcher-content.wallpapers { + padding: 16px; + min-height: 420px; + min-width: 620px; +} + +#app-launcher, +#wallpapers, +#todo, +#bluetooth, +#sh, +#cliphist, +#emoji, +#powermenu { + transition: all 0.25s cubic-bezier(0.5, 0.25, 0, 1); +} + +#toggle-launcher-button { + background-color: @secondaryContainer; + color: @onSecondaryContainer; + margin: 11px; + margin-left: 0px; + min-width: 54px; + min-height: 44px; + border-radius: 100%; +} + +#clear-launcher-button { + background-color: @secondaryContainer; + color: @onSecondaryContainer; + margin: 11px; + margin-left: 0px; + min-width: 44px; + min-height: 44px; + border-radius: 100%; +} + +/* + * ── applauncher ─────────────────────────────────────────────────────── +*/ + +#launcher-app { + border-radius: 16px; + padding: 16px; + transition: padding 0.25s cubic-bezier(0.5, 0.25, 0, 1); +} + +#launcher-app:hover image, +#launcher-app:focus image { + -gtk-icon-shadow: 2px 2px @primary; +} + +#launcher-app:hover, +#launcher-app:focus { + text-shadow: 2pt 2pt 2pt @primary; +} + +#launcher-app-icon { + margin-right: 8px; +} + +/* + * ── wallpaper ───────────────────────────────────────────────────────── +*/ + +#wallpaper-icons:hover { + background-color: @surfaceBright; + border-radius: 8px; +} + +#wallpaper-icons:selected { + background-color: @surfaceBright; + border-radius: 8px; +} + +#dropdown-box { + background-color: @surface; + box-shadow: inset 0 0 0 1px @outlineVariant; + border-radius: 11px; + padding: 10px; + margin: 12px; +} + +#scheme-dropdown { + font-weight: bold; +} + +/* + * ── emoji ───────────────────────────────────────────────────────────── +*/ + +#launcher button#emoji-item { + border-radius: 11px; + background-color: transparent; + background-image: none; + box-shadow: none; + padding: 0px; +} + +#launcher button#emoji-item label { + font-size: 24px; +} + +#launcher button#emoji-item:hover, +#launcher button#emoji-item:focus { + text-shadow: 2px 2px 2px @primary; +} + +/* + * ── powermenu ───────────────────────────────────────────────────────── +*/ + +#powermenu-button { + border-radius: 20px; + padding: 20px; +} + +#powermenu-button:hover, +#powermenu-button:focus { + background-color: mix(@onSurface, @surface, 0.8); +} + +#powermenu-button:active { + background-image: radial-gradient( + circle, + mix(@onSurfaceVariant, transparent, 0.7) 10%, + transparent 0% + ); +} + +/* + * ── cliphist ────────────────────────────────────────────────────────── +*/ + +#launcher button#clip-img-item { + background-size: cover; + background-position: center; + background-repeat: no-repeat; + border-radius: 8px; + min-width: 70px; + min-height: 70px; +} + +#launcher button#clip-img-item:hover, +#launcher button#clip-img-item:focus { + box-shadow: 2px 2px 2px @primary; +} + +#launcher button#clip-item { + border-radius: 11px; + background-color: transparent; + background-image: none; + box-shadow: none; + padding: 0px; +} + +#launcher button#clip-item { + font-size: 24px; +} + +#launcher button#clip-item:hover, +#launcher button#clip-item:focus { + text-shadow: 2px 2px 2px @primary; +} + +/* + * ── todo ────────────────────────────────────────────────────────────── +*/ + +#todo-launcher { + background-color: @surface; + padding: 10px; + border-radius: 8px; +} + +#todo-item { + padding: 8px; + border-radius: 4px; + background-color: alpha(@surface, 0.8); +} + +#todo-label { + color: @primary; +} + +#todo-label-completed { + color: alpha(@outlineVariant, 0.5); + text-decoration: line-through; +} + +#delete-button { + color: @error; +} + +/* + * ── sh runner ───────────────────────────────────────────────────────── +*/ + +#launcher button#sh-item { + border-radius: 11px; + background-color: transparent; + background-image: none; + box-shadow: none; + padding: 0px; +} + +#launcher button#sh-item { + font-size: 24px; +} + +#launcher button#sh-item:hover, +#launcher button#sh-item:focus { + text-shadow: 2px 2px 2px @primary; +} + +/* + * ── bluetooth ───────────────────────────────────────────────────────── +*/ + +#device-slot { + background-color: @suraceVariant; + border-radius: 5px; + padding: 8px; +} diff --git a/config/quickbar/styles/main.css b/config/karya/styles/main.css similarity index 79% rename from config/quickbar/styles/main.css rename to config/karya/styles/main.css index 6fea8f75..06b8be9a 100644 --- a/config/quickbar/styles/main.css +++ b/config/karya/styles/main.css @@ -3,14 +3,6 @@ @import "./notification.css"; @import "./osd.css"; @import "./launcher.css"; -@import "./launcher/applauncher.css"; -@import "./launcher/wallpapers.css"; -@import "./launcher/powermenu.css"; -@import "./launcher/todo.css"; -@import "./launcher/emoji.css"; -@import "./launcher/cliphist.css"; -@import "./launcher/bluetooth.css"; -@import "./launcher/sh.css"; * { all: unset; diff --git a/config/quickbar/styles/notification.css b/config/karya/styles/notification.css similarity index 100% rename from config/quickbar/styles/notification.css rename to config/karya/styles/notification.css diff --git a/config/quickbar/styles/osd.css b/config/karya/styles/osd.css similarity index 100% rename from config/quickbar/styles/osd.css rename to config/karya/styles/osd.css diff --git a/config/quickbar/styles/launcher/powermenu.css b/config/karya/styles/powermenu.css similarity index 56% rename from config/quickbar/styles/launcher/powermenu.css rename to config/karya/styles/powermenu.css index fbbbb471..ff981805 100644 --- a/config/quickbar/styles/launcher/powermenu.css +++ b/config/karya/styles/powermenu.css @@ -1,19 +1,19 @@ -#power-menu-button { +#powermenu-button { border-radius: 20px; padding: 20px; } -#power-menu-button:hover, -#power-menu-button:focus { +#powermenu-button:hover, +#powermenu-button:focus { background-color: mix(@onSurface, @surface, 0.8); } -#power-menu-button:hover label, -#power-menu-button:focus label { +#powermenu-button:hover label, +#powermenu-button:focus label { color: @primary; } -#power-menu-button:active { +#powermenu-button:active { background-image: radial-gradient( circle, mix(@onSurfaceVariant, transparent, 0.7) 10%, @@ -21,6 +21,6 @@ ); } -#power-menu-button:active label { +#powermenu-button:active label { color: @shadow; } diff --git a/config/quickbar/styles/launcher/sh.css b/config/karya/styles/sh.css similarity index 100% rename from config/quickbar/styles/launcher/sh.css rename to config/karya/styles/sh.css diff --git a/config/quickbar/styles/launcher/todo.css b/config/karya/styles/todo.css similarity index 100% rename from config/quickbar/styles/launcher/todo.css rename to config/karya/styles/todo.css diff --git a/config/quickbar/styles/launcher/wallpapers.css b/config/karya/styles/wallpapers.css similarity index 57% rename from config/quickbar/styles/launcher/wallpapers.css rename to config/karya/styles/wallpapers.css index d981758e..90caf42b 100644 --- a/config/quickbar/styles/launcher/wallpapers.css +++ b/config/karya/styles/wallpapers.css @@ -6,22 +6,35 @@ from { opacity: 0; } + to { opacity: 1; } } #wallpaper-icons:selected { - background-color: @primary; - color: @background; + background-color: @surfaceBright; border-radius: 8px; } #dropdown-box { background-color: @surface; padding: 8px; + border-radius: 16px; } #scheme-dropdown { font-weight: bold; } + +#scheme-dropdown > * > * { + font-weight: bold; +} + +#scheme-dropdown.box button.box.cellview { + background-color: @primary; +} + +#scheme-dropdown.box button.box.cellview:selected { + background-color: @surfaceBright; +} diff --git a/config/quickbar/styles/launcher/wifi.css b/config/karya/styles/wifi.css similarity index 100% rename from config/quickbar/styles/launcher/wifi.css rename to config/karya/styles/wifi.css diff --git a/config/quickbar/assets/scripts/cliphist.sh b/config/quickbar/assets/scripts/cliphist.sh deleted file mode 100755 index 3c6ae6ca..00000000 --- a/config/quickbar/assets/scripts/cliphist.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -get() { - cliphist list | iconv -f $(locale charmap) -t UTF-8 -c -} - -copy_by_id() { - id=$1 - cliphist decode $id | wl-copy -} - -clear() { - cliphist wipe -} - -save_cache_file() { - id=$1 - - output_file="/tmp/ags/cliphist/$id.png" - - if [[ ! -f "$output_file" ]]; then - mkdir -p "/tmp/ags/cliphist/" - cliphist decode "$id" >"$output_file" - fi - - echo $output_file -} - -clear_tmp() { - rm "/tmp/ags/cliphist/*" -} - -if [[ "$1" == "--get" ]]; then - get -elif [[ "$1" == "--copy-by-id" ]]; then - { copy_by_id "$2"; } -elif [[ "$1" == "--save-by-id" ]]; then - { save_cache_file "$2"; } -elif [[ "$1" == "--clear-cache" ]]; then - clear_tmp -elif [[ "$1" == "--clear" ]]; then - clear -fi - diff --git a/config/quickbar/modules/bar/widgets/taskbar.py b/config/quickbar/modules/bar/widgets/taskbar.py deleted file mode 100644 index 298fde29..00000000 --- a/config/quickbar/modules/bar/widgets/taskbar.py +++ /dev/null @@ -1,113 +0,0 @@ -import json -from typing import TypedDict - -from fabric.hyprland.widgets import get_hyprland_connection -from fabric.utils import exec_shell_command -from fabric.widgets.box import Box -from fabric.widgets.button import Button -from fabric.widgets.image import Image -from gi.repository import GdkPixbuf, GLib, Gtk -from snippets import IconResolver - - -class PagerClient(TypedDict): - title: str - initialClass: str - mapped: bool - hidden: bool - address: str - - -class TaskBar(Box): - def __init__(self, icon_size: int = 24, **kwargs): - super().__init__( - orientation="h", - spacing=7, - name="taskbar", - **kwargs, - ) - self.connection = get_hyprland_connection() - self.icon_size = icon_size - self.icon_theme = Gtk.IconTheme.get_default() - self.icon_resolver = IconResolver() - - self.set_visible(False) - self._icon_cache = {} - - if self.connection.ready: - self.render_with_delay() - else: - self.connection.connect("event::ready", lambda *_: self.render_with_delay()) - - for event in ( - "activewindow", - "openwindow", - "closewindow", - "changefloatingmode", - ): - self.connection.connect(f"event::{event}", lambda *_: self.render()) - - def render_with_delay(self, *_): - GLib.timeout_add(101, self.render) - - def render(self, *_): - self.children = [] - active_window_address = self.get_active_window_address() - - for client in self.fetch_clients(): - if client["mapped"] and not client["hidden"]: - window_class = client["initialClass"].lower() - icon = self.bake_window_icon(window_class) - - button = Button(image=icon, tooltip_text=client["title"]) - if client["address"] == active_window_address: - button.add_style_class("activated") - button.connect( - "button-press-event", self.on_icon_click, client["address"] - ) - - self.add(button) - - self.set_visible(len(self.children) > 0) - if self.children: - self.show_all() - - def get_active_window_address(self) -> str: - active_window_info = json.loads( - self.connection.send_command("j/activewindow").reply.decode() - ) - return active_window_info.get("address", "") - - def on_icon_click(self, widget, event, address): - command = ( - "focuswindow" - if event.button == 1 - else "closewindow" if event.button == 3 else None - ) - if command: - exec_shell_command(f"hyprctl dispatch {command} address:{address}") - - def fetch_clients(self) -> list[PagerClient]: - return json.loads(self.connection.send_command("j/clients").reply.decode()) - - def bake_window_icon( - self, window_class: str, fallback_icon: str = "image-missing" - ) -> Image: - icon_name = self.icon_resolver.get_icon_name(window_class) or fallback_icon - if icon_name not in self._icon_cache: - pixbuf = self.load_icon(icon_name) - self._icon_cache[icon_name] = pixbuf - return Image(pixbuf=self._icon_cache[icon_name], size=self.icon_size) - - def load_icon( - self, icon_name: str, fallback_icon: str = "image-missing" - ) -> GdkPixbuf.Pixbuf: - try: - pixbuf = self.icon_theme.load_icon( - icon_name, self.icon_size, Gtk.IconLookupFlags.FORCE_SIZE - ) - except Exception: - pixbuf = self.icon_theme.load_icon( - fallback_icon, self.icon_size, Gtk.IconLookupFlags.FORCE_SIZE - ) - return pixbuf diff --git a/config/quickbar/ruff.toml b/config/quickbar/ruff.toml deleted file mode 100644 index 2e2889de..00000000 --- a/config/quickbar/ruff.toml +++ /dev/null @@ -1,10 +0,0 @@ -line-length = 88 -indent-width = 4 - -[lint] -# ignore gi imports not begin at the top of the file -ignore = ["E402"] - -[format] -quote-style = "double" -indent-style = "space" \ No newline at end of file diff --git a/config/quickbar/services/__init__.py b/config/quickbar/services/__init__.py deleted file mode 100644 index 7373da1a..00000000 --- a/config/quickbar/services/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .brightness import * -from .screen_record import * -from .wifi import * diff --git a/config/quickbar/snippets/icon_resolver.py b/config/quickbar/snippets/icon_resolver.py deleted file mode 100644 index 6c1fc9c6..00000000 --- a/config/quickbar/snippets/icon_resolver.py +++ /dev/null @@ -1,100 +0,0 @@ -import json -import os -import re - -import gi - -gi.require_version("Gtk", "3.0") -from gi.repository import GLib, Gtk -from loguru import logger - -# TODO WIP -# Idea: nearest string matching algorithm -# if already exists: retrieve from json -# if found: stor in json: app_id -> icon_name -# if not found: store in json -> misisng-icon - - -CACHE_DIR = str(GLib.get_user_cache_dir()) + "/fabric" -ICON_CACHE_FILE = CACHE_DIR + "/icons.json" -if not os.path.exists(CACHE_DIR): - os.makedirs(CACHE_DIR) - - -class IconResolver: - def __init__(self, default_applicaiton_icon: str = "image-missing"): - if os.path.exists(ICON_CACHE_FILE): - f = open(ICON_CACHE_FILE) - try: - self._icon_dict = json.load(f) - except json.JSONDecodeError: - logger.info("[ICONS] Cache file does not exist or is corrupted") - f.close() - else: - self._icon_dict = {} - - self.default_applicaiton_icon = default_applicaiton_icon - - def get_icon_name(self, app_id: str): - if app_id in self._icon_dict: - return self._icon_dict[app_id] - new_icon = self._compositor_find_icon(app_id) - logger.info( - f"[ICONS] found new icon: '{new_icon}' for app id: '{app_id}', storing..." - ) - self._store_new_icon(app_id, new_icon) - return new_icon - - def get_icon_pixbuf(self, app_id: str, size: int = 16): - return Gtk.IconTheme.get_default().load_icon( - self.get_icon_name(app_id), - size, - Gtk.IconLookupFlags.FORCE_SIZE, - ) - - def _store_new_icon(self, app_id: str, icon: str): - self._icon_dict[app_id] = icon - with open(ICON_CACHE_FILE, "w") as f: - json.dump(self._icon_dict, f) - f.close() - - def _get_icon_from_desktop_file(self, desktop_file_path: str): - # TODO: get icon in the [Desktop Entry] section only - with open(desktop_file_path) as f: - for line in f.readlines(): - if "Icon=" in line: - return "".join(line[5:].split()) - return self.default_applicaiton_icon - - def _get_desktop_file(self, app_id: str) -> str | None: - data_dirs = GLib.get_system_data_dirs() - for data_dir in data_dirs: - data_dir = data_dir + "/applications/" - if os.path.exists(data_dir): - # Do name resolving here - - files = os.listdir(data_dir) - matching = [ - s for s in files if "".join(app_id.lower().split()) in s.lower() - ] - if matching: - return data_dir + matching[0] - - for word in list(filter(None, re.split(r"-|\.|_|\s", app_id))): - matching = [s for s in files if word.lower() in s.lower()] - if matching: - return data_dir + matching[0] - - return None - - def _compositor_find_icon(self, app_id: str): - if Gtk.IconTheme.get_default().has_icon(app_id): - return app_id - if Gtk.IconTheme.get_default().has_icon(app_id + "-desktop"): - return app_id + "-desktop" - desktop_file = self._get_desktop_file(app_id) - return ( - self._get_icon_from_desktop_file(desktop_file) - if desktop_file - else self.default_applicaiton_icon - ) diff --git a/config/quickbar/styles/launcher.css b/config/quickbar/styles/launcher.css deleted file mode 100644 index 32a88b69..00000000 --- a/config/quickbar/styles/launcher.css +++ /dev/null @@ -1,53 +0,0 @@ -#launcher { - margin: 18px; - border: 1px solid @outlineVariant; - background-color: @surface; - border-radius: 24px; - padding: 18px; - transition: all 0.5s cubic-bezier(0.5, 0.25, 0, 1); -} - -#launcher entry { - transition: all 0.1s ease; - border-radius: 11px; - padding: 10px; - margin: 12px; - box-shadow: inset 0 0 0 1px @outlineVariant; -} - -#launcher entry:focus { - background-color: @background; -} - -#launcher entry:hover { - background-color: @background; -} - -#launcher entry selection { - color: @outline; - background-color: transparent; -} - -#launcher-content.wallpapers { - padding: 16px; - min-height: 420px; - min-width: 620px; -} - -#app-launcher, -#wallpapers, -#power-menu { - transition: all 0.25s cubic-bezier(0.5, 0.25, 0, 1); -} - -#close-button { - background-color: @surface; - border-radius: 100px; - padding: 10px; -} - -#close-button:hover, -#close-button:focus { - border-radius: 100px; - background-color: @errorContainer; -}