From 4b9876819a2f190b8e8729e3aeef5b245de5f2b8 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 07:58:05 +0545 Subject: [PATCH 01/38] new widget for launcher --- .../modules/launcher/widgets/__init__.py | 14 +- config/fabric/modules/launcher/widgets/app.py | 68 ----- .../modules/launcher/widgets/applauncher.py | 166 ++++++++++++ .../modules/launcher/widgets/bluetooth.py | 91 ------- .../modules/launcher/widgets/calendar.py | 26 -- .../modules/launcher/widgets/clipboard.py | 140 ---------- .../modules/launcher/widgets/cliphist.py | 206 +++++++++++++++ .../modules/launcher/widgets/dashboard.py | 242 ++++++++++++++++++ .../fabric/modules/launcher/widgets/emoji.py | 133 ++++++++-- .../fabric/modules/launcher/widgets/power.py | 86 +++++++ .../modules/launcher/widgets/power_menu.py | 102 -------- .../fabric/modules/launcher/widgets/shell.py | 78 ------ .../fabric/modules/launcher/widgets/todo.py | 182 +++++++++++++ .../modules/launcher/widgets/wallpaper.py | 167 ------------ .../modules/launcher/widgets/wallpapers.py | 217 ++++++++++++++++ .../fabric/modules/launcher/widgets/wifi.py | 99 ------- 16 files changed, 1212 insertions(+), 805 deletions(-) delete mode 100644 config/fabric/modules/launcher/widgets/app.py create mode 100644 config/fabric/modules/launcher/widgets/applauncher.py delete mode 100644 config/fabric/modules/launcher/widgets/calendar.py delete mode 100644 config/fabric/modules/launcher/widgets/clipboard.py create mode 100644 config/fabric/modules/launcher/widgets/cliphist.py create mode 100644 config/fabric/modules/launcher/widgets/dashboard.py create mode 100644 config/fabric/modules/launcher/widgets/power.py delete mode 100644 config/fabric/modules/launcher/widgets/power_menu.py create mode 100644 config/fabric/modules/launcher/widgets/todo.py delete mode 100644 config/fabric/modules/launcher/widgets/wallpaper.py create mode 100644 config/fabric/modules/launcher/widgets/wallpapers.py diff --git a/config/fabric/modules/launcher/widgets/__init__.py b/config/fabric/modules/launcher/widgets/__init__.py index c99174db..39ae1b09 100644 --- a/config/fabric/modules/launcher/widgets/__init__.py +++ b/config/fabric/modules/launcher/widgets/__init__.py @@ -1,9 +1,7 @@ -from .app import * -from .bluetooth import * -from .calendar import * -from .clipboard import * +from .applauncher import * +from .cliphist import * +from .dashboard import * from .emoji import * -from .power_menu import * -from .shell import * -from .wallpaper import * -from .wifi import * +from .power import * +from .todo import * +from .wallpapers import * diff --git a/config/fabric/modules/launcher/widgets/app.py b/config/fabric/modules/launcher/widgets/app.py deleted file mode 100644 index 32d8aaca..00000000 --- a/config/fabric/modules/launcher/widgets/app.py +++ /dev/null @@ -1,68 +0,0 @@ -from fabric.widgets.box import Box -from fabric.widgets.button import Button -from fabric.widgets.image import Image -from fabric.widgets.label import Label - - -def handle_application_search(launcher, query: str): - if not query.strip(): - launcher.additional_box.set_visible(True) - return - - launcher.additional_box.set_visible(False) - filtered_apps = [ - app - for app in launcher.all_apps - if query.casefold() - in ( - (app.display_name or "") - + " " - + (app.name or "") - + " " - + (app.generic_name or "") - ).casefold() - ] - - if filtered_apps: - launcher.viewport.children = [ - bake_application_slot(launcher, app) for app in filtered_apps[:6] - ] - launcher.scrolled_revealer.reveal() - else: - launcher.scrolled_revealer.unreveal() - - -def bake_application_slot(launcher, app, **kwargs) -> Button: - return Button( - child=Box( - orientation="h", - spacing=10, - children=[ - Image(pixbuf=app.get_icon_pixbuf(), h_align="start", size=62), - Box( - orientation="v", - spacing=10, - children=[ - Label( - label=app.display_name or "Unknown", - h_expand=True, - name="title", - v_align="center", - h_align="start", - ), - Label( - label=app.description or "", - name="description", - h_expand=True, - v_align="center", - justification="left", - line_wrap="char", - ), - ], - ), - ], - ), - name="app-item", - on_clicked=lambda *_: (app.launch(), launcher.set_visible(False)), - **kwargs, - ) diff --git a/config/fabric/modules/launcher/widgets/applauncher.py b/config/fabric/modules/launcher/widgets/applauncher.py new file mode 100644 index 00000000..1c70f3a4 --- /dev/null +++ b/config/fabric/modules/launcher/widgets/applauncher.py @@ -0,0 +1,166 @@ +import operator +from collections.abc import Iterator + +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 + + +class AppLauncher(Box): + def __init__(self, **kwargs): + super().__init__( + name="app-launcher", + visible=False, + all_visible=False, + **kwargs, + ) + self._arranger_handler: int = 0 + self._all_apps = get_desktop_applications() + + 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()), + on_activate=lambda entry, *_: self.on_search_entry_activate( + entry.get_text() + ), + on_button_press_event=print, + ) + self.scrolled_window = ScrolledWindow( + name="scrolled-window", + spacing=10, + h_scrollbar_policy="never", + v_scrollbar_policy="never", + child=self.viewport, + ) + + 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(), + ), + ], + ) + + self.launcher_box = Box( + name="launcher-box", + spacing=10, + h_expand=True, + orientation="v", + children=[ + self.header_box, + self.scrolled_window, + ], + ) + + 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._all_apps = get_desktop_applications() + self.arrange_viewport() + + def on_key_press_event(self, widget, event): + if event.keyval == Gdk.KEY_Escape: + self.close_launcher() + + def arrange_viewport(self, query: str = ""): + remove_handler(self._arranger_handler) if self._arranger_handler else None + self.viewport.children = [] + + if not query.strip(): + return False + + filtered_apps = sorted( + [ + app + for app in self._all_apps + if query.casefold() + in ( + (app.display_name or "") + + (" " + app.name + " ") + + (app.generic_name or "") + ).casefold() + ], + key=lambda app: (app.display_name or "").casefold(), + ) + + filtered_apps = filtered_apps[:6] + + self._arranger_handler = idle_add( + lambda *args: self.add_next_application(*args), + iter(filtered_apps), + pin=True, + ) + + return False + + def add_next_application(self, apps_iter: Iterator[DesktopApp]): + if not (app := next(apps_iter, None)): + return False + + self.viewport.add(self.bake_application_slot(app)) + return True + + def bake_application_slot(self, app: DesktopApp, **kwargs) -> Button: + return Button( + name="app-slot-button", + child=Box( + name="app-slot-box", + orientation="h", + spacing=10, + children=[ + Label( + name="app-label", + label=app.display_name or "Unknown", + ellipsization="end", + v_align="center", + h_align="center", + ), + ], + ), + 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/fabric/modules/launcher/widgets/bluetooth.py b/config/fabric/modules/launcher/widgets/bluetooth.py index 56f54099..e69de29b 100644 --- a/config/fabric/modules/launcher/widgets/bluetooth.py +++ b/config/fabric/modules/launcher/widgets/bluetooth.py @@ -1,91 +0,0 @@ -from fabric.bluetooth import BluetoothClient -from fabric.widgets.box import Box -from fabric.widgets.button import Button -from fabric.widgets.image import Image -from fabric.widgets.label import Label -from snippets import MaterialIcon - - -class BluetoothMenu: - def __init__(self, launcher): - self.launcher = launcher - self.client = BluetoothClient(on_device_added=self.on_device_added) - self.paired_devices = {} - self.available_devices = {} - - self.bt_button = self.create_bluetooth_button() - self.scan_button = self.create_scan_button() - self.update_bt_button_style() - - def create_bluetooth_button(self): - button = Button( - child=MaterialIcon("bluetooth"), - h_align="center", - v_align="center", - on_clicked=self.bt_toggle, - ) - return button - - def create_scan_button(self): - return Button( - child=MaterialIcon("refresh"), - h_align="center", - v_align="center", - on_clicked=lambda *_: self.client.toggle_scan(), - ) - - def bt_toggle(self, *_): - self.client.toggle_power() - self.update_bt_button_style() - - def update_bt_button_style(self): - style = ( - "background-color: transparent;" - if self.client.enabled - else "background-color: @surfaceVariant; border-radius:100px; min-height: 50px; min-width: 50px;" - ) - self.bt_button.set_style(style) - - def show_bluetooth_menu(self, viewport): - viewport.children = [] - devices_box = Box(orientation="v", spacing=5) - - # Combine paired and available devices - all_devices = {**self.paired_devices, **self.available_devices} - for address, device in all_devices.items(): - device_button = self.create_device_button(device) - devices_box.add(device_button) - - viewport.add(devices_box) - - def create_device_button(self, device): - connection_status = "Connected" if device.connected else "" - return Button( - child=Box( - orientation="h", - spacing=10, - children=[ - Image(icon_name=device.icon_name, size=32), - Label(label=device.name), - Label(label=connection_status, h_align="end"), - ], - ), - on_clicked=lambda _, device=device: self.connect_to_device(device), - name="launcher-item", - ) - - def connect_to_device(self, device): - device.set_connecting(True) - self.show_bluetooth_menu(self.launcher.viewport) - - def on_device_added(self, client, address): - if device := client.get_device(address): - if device.paired: - self.paired_devices[address] = device - else: - self.available_devices[address] = device - - self.show_bluetooth_menu(self.launcher.viewport) - - def get_bluetooth_buttons(self): - return [self.bt_button, self.scan_button] diff --git a/config/fabric/modules/launcher/widgets/calendar.py b/config/fabric/modules/launcher/widgets/calendar.py deleted file mode 100644 index 2b522287..00000000 --- a/config/fabric/modules/launcher/widgets/calendar.py +++ /dev/null @@ -1,26 +0,0 @@ -from fabric.widgets.box import Box -from fabric.widgets.button import Button -from gi.repository import Gtk -from snippets import MaterialIcon - - -class Calendar: - def __init__(self, launcher): - self.launcher = launcher - self.today_button = Button( - child=MaterialIcon("event_available"), - v_align="center", - ) - - def show_calendar_menu(self, viewport): - viewport.children = [] - - calendar_container = Box( - name="calendar", - children=Gtk.Calendar(visible=True, hexpand=True), - ) - - viewport.add(calendar_container) - - def get_calendar_buttons(self): - return self.today_button diff --git a/config/fabric/modules/launcher/widgets/clipboard.py b/config/fabric/modules/launcher/widgets/clipboard.py deleted file mode 100644 index 7722633b..00000000 --- a/config/fabric/modules/launcher/widgets/clipboard.py +++ /dev/null @@ -1,140 +0,0 @@ -import os -import subprocess - -from fabric import Fabricator -from fabric.widgets.button import Button -from fabric.widgets.image import Image -from fabric.widgets.label import Label -from snippets import MaterialIcon - - -class ClipboardManager: - def __init__(self, launcher, viewport): - self.launcher = launcher - self.viewport = viewport - self.clipboard_history = [] - self._initialize_clipboard_watcher() - - def _initialize_clipboard_watcher(self): - self.wl_paste_watcher = Fabricator( - poll_from="wl-paste --watch echo", stream=True, interval=-1 - ) - self.wl_paste_watcher.connect( - "changed", lambda *_: self.update_clipboard_history() - ) - - def get_clip_history(self): - try: - result = subprocess.run( - ["cliphist", "list"], capture_output=True, text=True, check=True - ) - return self._parse_clip_history(result.stdout) - except subprocess.CalledProcessError: - return [] - - def _parse_clip_history(self, output): - return [ - {"content": line.strip(), "id": line.split()[0]} - for line in output.splitlines() - if line.strip() - ][:10] - - def update_clipboard_history(self): - new_history = self.get_clip_history() - if isinstance(new_history, list) and new_history != self.clipboard_history: - self.clipboard_history = new_history - self.refresh_ui() - - def refresh_ui(self): - self._clear_viewport() - self.show_clipboard_history(self.viewport) - - def _clear_viewport(self): - for child in self.viewport.children: - self.viewport.remove(child) - - def run_command(self, command, input_data=None): - try: - input_data = self._ensure_bytes(input_data) - return subprocess.run( - command, input=input_data, capture_output=True, check=True - ) - except subprocess.CalledProcessError: - return None - - def _ensure_bytes(self, input_data): - if input_data and not isinstance(input_data, bytes): - return input_data.encode() # Ensure input data is in bytes - return input_data - - def copy_by_id(self, clip_id: str): - command = f"cliphist decode {clip_id} | wl-copy" - try: - subprocess.run(command, shell=True, check=True) - except subprocess.CalledProcessError: - pass - - def save_cache_file(self, clip_id: str): - output_file = f"/tmp/cliphist/{clip_id}.png" - os.makedirs("/tmp/cliphist/", exist_ok=True) - - result = self.run_command(["cliphist", "decode", clip_id]) - if result: - self._write_to_cache(output_file, result.stdout) - return output_file - return None - - def _write_to_cache(self, output_file, data): - with open(output_file, "wb") as f: - f.write(data) - - def show_clipboard_history(self, viewport, query=""): - filtered_history = self._filter_clip_history(query) - for item in filtered_history: - self.add_clipboard_item(viewport, item) - - def _filter_clip_history(self, query): - if not self.clipboard_history: # Safeguard against None or empty - return [] - return [item for item in self.clipboard_history if query in item["content"]] - # return [item for item in self.clipboard_history if query in item["content"]] - - def add_clipboard_item(self, viewport, item): - if "png" in item["content"]: - self._add_image_button(viewport, item) - else: - self._add_text_button(viewport, item) - - def _add_image_button(self, viewport, item): - output_file = self.save_cache_file(item["id"]) - if output_file and os.path.exists(output_file): - image_button = Button( - h_align="start", - child=Image(file=output_file), - on_clicked=lambda _, clip_id=item["id"]: self.handle_clip_click( - clip_id - ), - name="cliphist-img-item", - ) - image_button.set_style(f"background-image: url('{output_file}');") - viewport.add(image_button) - - def _add_text_button(self, viewport, item): - label_button = Button( - child=Label( - label=item["content"][:35], # Truncate text for display - h_expand=True, - v_align="center", - h_align="start", - ), - on_clicked=lambda _, clip_id=item["id"]: self.handle_clip_click(clip_id), - name="launcher-item", - ) - viewport.add(label_button) - - def handle_clip_click(self, clip_id): - self.copy_by_id(clip_id) - self.launcher.set_visible(False) - - def get_clipboard_buttons(self): - return MaterialIcon("content_paste") diff --git a/config/fabric/modules/launcher/widgets/cliphist.py b/config/fabric/modules/launcher/widgets/cliphist.py new file mode 100644 index 00000000..2bcbc85f --- /dev/null +++ b/config/fabric/modules/launcher/widgets/cliphist.py @@ -0,0 +1,206 @@ +import os +import subprocess +from typing import List + +from fabric import Fabricator +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 +from snippets import MaterialIcon + + +class Cliphist(Box): + def __init__(self, **kwargs): + super().__init__( + name="cliphist-launcher", + all_visible=False, + visible=False, + **kwargs, + ) + + self._arranger_handler = 0 + self.cliphist_manager = CliphistManager(self) + self.viewport = None + + 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.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(), + ), + ], + ) + + self.launcher_box = Box( + name="cliphist-launcher-box", + spacing=10, + orientation="v", + h_expand=True, + children=[self.header_box], + ) + + self.add(self.launcher_box) + + def open_launcher(self): + if not self.viewport: + self.viewport = Box(name="viewport", spacing=4, orientation="v") + self.scrolled_window = ScrolledWindow( + name="scrolled-window", + spacing=10, + h_scrollbar_policy="never", + v_scrollbar_policy="never", + child=self.viewport, + ) + self.launcher_box.add(self.scrolled_window) + + self.viewport.children = [] + self.cliphist_manager.arrange_viewport() + + 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.cliphist_manager.arrange_viewport(text) + + +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 + ) + self.wl_paste_watcher.connect( + "changed", lambda *_: self.update_cliphist_history() + ) + + def get_clip_history(self) -> List[dict]: + try: + result = subprocess.run( + ["cliphist", "list"], capture_output=True, text=True, check=True + ) + return self._parse_clip_history(result.stdout) + except subprocess.CalledProcessError as e: + print(f"Error fetching cliphist history: {e}") + return [] + + def _parse_clip_history(self, output: str) -> List[dict]: + 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] + + def copy_clip(self, clip_id: str): + try: + decode_result = subprocess.run( + ["cliphist", "decode", clip_id], capture_output=True, check=True + ) + subprocess.run(["wl-copy"], input=decode_result.stdout, check=True) + self.launcher.close_launcher() + 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) + + try: + decode_result = subprocess.run( + ["cliphist", "decode", clip_id], capture_output=True, check=True + ) + + with open(output_file, "wb") as f: + f.write(decode_result.stdout) + + return output_file + except (subprocess.CalledProcessError, IOError) as e: + print(f"Error saving cache file for clip {clip_id}: {e}") + return None + + def query_clips(self, query: str = "") -> List[dict]: + if not query.strip(): + return self.get_clip_history() + + filtered_clips = [ + item + for item in self.get_clip_history() + if query.lower() in item["content"].lower() + ] + return filtered_clips + + def bake_clip_slot(self, item: dict) -> Button: + if "png" 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"]) + 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", + ) + button.set_style(f"background-image: url('{output_file}');") + return button + return None + + def _create_text_button(self, item: dict) -> Button: + return Button( + child=Label( + label=item["content"][:55] + + ("..." if len(item["content"]) > 55 else ""), + h_expand=True, + v_align="center", + h_align="start", + ), + on_clicked=lambda _, clip_id=item["id"]: self.copy_clip(clip_id), + name="clip-item", + ) + + def update_cliphist_history(self): + self.cliphist_history = self.get_clip_history() + if self.launcher.viewport: + self.arrange_viewport() + + def arrange_viewport(self, query: str = ""): + if not self.launcher.viewport: + return + + if self.launcher._arranger_handler: + remove_handler(self.launcher._arranger_handler) + + self.launcher.viewport.children = [] + filtered_clips = self.query_clips(query) + + for clip in filtered_clips: + button = self.bake_clip_slot(clip) + if button: + self.launcher.viewport.add(button) diff --git a/config/fabric/modules/launcher/widgets/dashboard.py b/config/fabric/modules/launcher/widgets/dashboard.py new file mode 100644 index 00000000..d266e0e1 --- /dev/null +++ b/config/fabric/modules/launcher/widgets/dashboard.py @@ -0,0 +1,242 @@ +from fabric.widgets.box import Box +from fabric.widgets.button import Button +from fabric.widgets.label import Label +from snippets import MaterialIcon + + +class Buttons(Box): + def __init__(self, **kwargs): + super().__init__( + name="buttons", + spacing=4, + h_align="center", + v_align="start", + h_expand=True, + v_expand=True, + visible=True, + all_visible=True, + ) + + self.network_status_button = Button( + name="network-status-button", + h_expand=True, + child=Box( + h_align="start", + v_align="center", + spacing=10, + children=[ + MaterialIcon("wifi"), + Box( + name="network-text", + orientation="v", + h_align="start", + v_align="center", + children=[ + Box( + children=[ + Label( + name="network-label", + label="Wi-Fi", + justification="left", + ), + Box(h_expand=True), + ] + ), + Box( + children=[ + Label( + name="network-ssid", + label="ARGOS_5GHz", + justification="left", + ), + Box(h_expand=True), + ] + ), + ], + ), + ], + ), + ) + + self.network_menu_button = Button( + name="network-menu-button", + child=MaterialIcon("chevron_right"), + ) + + self.network_button = Box( + name="network-button", + orientation="h", + h_align="fill", + v_align="center", + h_expand=True, + v_expand=True, + children=[ + self.network_status_button, + self.network_menu_button, + ], + ) + + self.bluetooth_status_button = Button( + name="bluetooth-status-button", + h_expand=True, + child=Box( + h_align="start", + v_align="center", + spacing=10, + children=[ + MaterialIcon("bluetooth"), + Box( + name="bluetooth-text", + orientation="v", + h_align="start", + v_align="center", + children=[ + Box( + children=[ + Label( + name="bluetooth-label", + label="Bluetooth", + justification="left", + ), + Box(h_expand=True), + ] + ), + Box( + children=[ + Label( + name="bluetooth-status", + label="Connected", + justification="left", + ), + Box(h_expand=True), + ] + ), + ], + ), + ], + ), + ) + + self.bluetooth_menu_button = Button( + name="bluetooth-menu-button", + child=MaterialIcon("chevron_right"), + ) + + self.bluetooth_button = Box( + name="bluetooth-button", + orientation="h", + h_align="fill", + v_align="center", + h_expand=True, + v_expand=True, + children=[ + self.bluetooth_status_button, + self.bluetooth_menu_button, + ], + ) + + self.night_mode_button = Button( + name="night-mode-button", + child=Box( + h_align="start", + v_align="center", + spacing=10, + children=[ + MaterialIcon("nightlight"), + Box( + name="night-mode-text", + orientation="v", + h_align="start", + v_align="center", + children=[ + Box( + children=[ + Label( + name="night-mode-label", + label="Night Mode", + justification="left", + ), + Box(h_expand=True), + ] + ), + Box( + children=[ + Label( + name="night-mode-status", + label="Enabled", + justification="left", + ), + Box(h_expand=True), + ] + ), + ], + ), + ], + ), + ) + + self.caffeine_button = Button( + name="caffeine-button", + child=Box( + h_align="start", + v_align="center", + spacing=10, + children=[ + MaterialIcon("coffee"), + Box( + name="caffeine-text", + orientation="v", + h_align="start", + v_align="center", + children=[ + Box( + children=[ + Label( + name="caffeine-label", + label="Caffeine", + justification="left", + ), + Box(h_expand=True), + ] + ), + Box( + children=[ + Label( + name="caffeine-status", + label="Enabled", + justification="left", + ), + Box(h_expand=True), + ] + ), + ], + ), + ], + ), + ) + + self.add(self.network_button) + self.add(self.bluetooth_button) + self.add(self.night_mode_button) + self.add(self.caffeine_button) + + self.show_all() + + +class Dashboard(Box): + def __init__(self, **kwargs): + super().__init__( + name="dashboard", + h_align="center", + v_align="start", + h_expand=True, + v_expand=True, + visible=True, + all_visible=True, + ) + + self.buttons = Buttons() + + self.add(self.buttons) + + self.show_all() diff --git a/config/fabric/modules/launcher/widgets/emoji.py b/config/fabric/modules/launcher/widgets/emoji.py index 10d869d2..b8149020 100644 --- a/config/fabric/modules/launcher/widgets/emoji.py +++ b/config/fabric/modules/launcher/widgets/emoji.py @@ -3,25 +3,102 @@ import subprocess from typing import Generator, List import ijson +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.label import Label +from fabric.widgets.scrolledwindow import ScrolledWindow +from gi.repository import GLib from snippets import MaterialIcon +class Emoji(Box): + def __init__(self, **kwargs): + super().__init__( + name="emoji-launcher", + all_visible=False, + visible=False, + **kwargs, + ) + + self._arranger_handler: int = 0 + self.emoji_manager = EmojiManager(self) + self.viewport = None + + 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()), + ) + + 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(), + ), + ], + ) + + self.launcher_box = Box( + name="emoji-launcher-box", + spacing=10, + orientation="v", + h_expand=True, + children=[self.header_box], + ) + + self.add(self.launcher_box) + + def open_launcher(self): + if not self.viewport: + self.viewport = Box(name="viewport", spacing=4, orientation="v") + self.scrolled_window = ScrolledWindow( + name="scrolled-window", + spacing=10, + h_scrollbar_policy="never", + v_scrollbar_policy="never", + child=self.viewport, + ) + self.launcher_box.add(self.scrolled_window) + + self.viewport.children = [] + self.emoji_manager.arrange_viewport() + + 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.emoji_manager.arrange_viewport(text) + + class EmojiManager: def __init__(self, launcher): self.launcher = launcher - self.emoji_file_path = os.path.expanduser("~/fabric/assets/emoji.json") + self.emoji_file_path = os.path.expanduser("~/quickbar/assets/emoji.json") def load_emojis(self) -> Generator[tuple, None, None]: if not os.path.exists(self.emoji_file_path): + print(f"Emoji file not found: {self.emoji_file_path}") return try: with open(self.emoji_file_path, "r") as file: for emoji_str, item in ijson.kvitems(file, ""): yield emoji_str, item["name"], item["slug"], item["group"] - except (ijson.JSONError, KeyError, OSError): + except (ijson.JSONError, KeyError, OSError) as e: + print(f"Error loading emojis: {e}") return def query_emojis(self, query: str) -> List[tuple]: @@ -34,32 +111,36 @@ class EmojiManager: def copy_emoji(self, emoji: tuple): subprocess.run(["wl-copy"], input=emoji[0].encode(), check=True) - self.launcher.set_visible(False) + self.launcher.close_launcher() - def show_emojis(self, viewport, query: str): - filtered_emojis = self.query_emojis(query) - self._display_emoji_grid(viewport, filtered_emojis) - - def _display_emoji_grid(self, viewport, emojis: List[tuple]): - row = Box(orientation="h", spacing=10) - for emoji in emojis: - button = self._create_emoji_button(emoji) - row.add(button) - - if len(row.children) >= 12: - viewport.add(row) - row = Box(orientation="h", spacing=10) - - if row.children: - viewport.add(row) - - def _create_emoji_button(self, emoji: tuple) -> Button: + def bake_emoji_slot(self, emoji: tuple, **kwargs) -> Button: return Button( - child=Label(label=emoji[0], h_pack="start"), - tooltip_text=f"Copy {emoji[1]}", - on_clicked=lambda *_: self.copy_emoji(emoji), name="emoji-item", + child=Label(label=emoji[0], h_align="center"), + tooltip_text=emoji[1], + on_clicked=lambda *_: self.copy_emoji(emoji), + **kwargs, ) - def get_emoji_buttons(self): - return MaterialIcon("mood") + def arrange_viewport(self, query: str = ""): + if not self.launcher.viewport: + return + + ( + remove_handler(self.launcher._arranger_handler) + if self.launcher._arranger_handler + else None + ) + self.launcher.viewport.children = [] + + filtered_emojis = self.query_emojis(query) + + row = Box(name="emoji-row", spacing=10, orientation="h") + for emoji in filtered_emojis: + row.add(self.bake_emoji_slot(emoji)) + if len(row.children) >= 12: + self.launcher.viewport.add(row) + row = Box(name="emoji-row", spacing=10, orientation="h") + + if row.children: + self.launcher.viewport.add(row) diff --git a/config/fabric/modules/launcher/widgets/power.py b/config/fabric/modules/launcher/widgets/power.py new file mode 100644 index 00000000..0150e1e8 --- /dev/null +++ b/config/fabric/modules/launcher/widgets/power.py @@ -0,0 +1,86 @@ +from fabric.widgets.box import Box +from fabric.widgets.button import Button +from gi.repository import GLib + +from snippets import MaterialIcon + + +class PowerMenu(Box): + def __init__(self, **kwargs): + super().__init__( + name="power-menu", + orientation="h", + spacing=10, + v_align="center", + h_align="center", + v_expand=True, + h_expand=True, + visible=True, + **kwargs, + ) + + self.btn_lock = Button( + name="power-menu-button", + child=MaterialIcon("lock", 50), + on_clicked=self.lock, + ) + + self.btn_suspend = Button( + name="power-menu-button", + child=MaterialIcon("sleep", 50), + on_clicked=self.suspend, + ) + + self.btn_logout = Button( + name="power-menu-button", + child=MaterialIcon("logout", 50), + on_clicked=self.logout, + ) + + self.btn_reboot = Button( + name="power-menu-button", + child=MaterialIcon("restart_alt", 50), + on_clicked=self.reboot, + ) + + self.btn_shutdown = Button( + name="power-menu-button", + child=MaterialIcon("power_settings_new", 50), + on_clicked=self.poweroff, + ) + + self.buttons = [ + self.btn_lock, + self.btn_suspend, + self.btn_logout, + self.btn_reboot, + self.btn_shutdown, + ] + + for button in self.buttons: + self.add(button) + + self.show_all() + + def close_menu(self): + GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") + + def lock(self, *_): + GLib.spawn_command_line_async("hyprlock --immediate") + self.close_menu() + + def suspend(self, *_): + GLib.spawn_command_line_async("systemctl suspend") + self.close_menu() + + def logout(self, *_): + GLib.spawn_command_line_async("hyprctl dispatch exit") + self.close_menu() + + def reboot(self, *_): + GLib.spawn_command_line_async("systemctl reboot") + self.close_menu() + + def poweroff(self, *_): + GLib.spawn_command_line_async("systemctl poweroff") + self.close_menu() diff --git a/config/fabric/modules/launcher/widgets/power_menu.py b/config/fabric/modules/launcher/widgets/power_menu.py deleted file mode 100644 index 97f052a8..00000000 --- a/config/fabric/modules/launcher/widgets/power_menu.py +++ /dev/null @@ -1,102 +0,0 @@ -import os - -from fabric.utils import exec_shell_command, exec_shell_command_async -from fabric.widgets.box import Box -from fabric.widgets.button import Button -from fabric.widgets.label import Label -from loguru import logger -from snippets import MaterialIcon - -IDLE_BUTTON_ACTIVE_STYLE = "background-color: @surfaceVariant; min-width:50px; min-height:50px; border-radius:100px;" -IDLE_BUTTON_INACTIVE_STYLE = "background-color: transparent;" - - -class PowerMenu: - def __init__(self, launcher): - self.launcher = launcher - self.idle_inhibitor = False - self.idle_button = Button( - child=MaterialIcon("schedule"), - v_align="center", - on_clicked=self.toggle_idle_inhibitor, - ) - self.idle_button.set_style(IDLE_BUTTON_INACTIVE_STYLE) - - def toggle_idle_inhibitor(self, *_): - self.idle_inhibitor = not self.idle_inhibitor - script_path = os.path.expanduser( - "~/fabric/assets/scripts/wayland-idle-inhibitor.py" - ) - - if self.idle_inhibitor and not self.check_idle_state(): - exec_shell_command_async( - ["python3", script_path], - lambda output: logger.info(f"Idle inhibitor output: {output}"), - ) - self.idle_button.set_style(IDLE_BUTTON_ACTIVE_STYLE) - else: - exec_shell_command("pkill -f wayland-idle-inhibitor.py") - self.idle_button.set_style(IDLE_BUTTON_INACTIVE_STYLE) - - def check_idle_state(self): - pid_check = exec_shell_command("pidof wayland-idle-inhibitor.py") - return "wayland-idle-inhibitor.py" in pid_check - - def show_power_menu(self, viewport, query: str = ""): - viewport.children = [] - - power_options = [ - { - "label": "Shutdown", - "icon": "power_settings_new", - "action": self.shutdown, - }, - {"label": "Logout", "icon": "logout", "action": self.logout}, - {"label": "Reboot", "icon": "restart_alt", "action": self.reboot}, - {"label": "Suspend", "icon": "sleep", "action": self.suspend}, - {"label": "Lock", "icon": "lock", "action": self.lock}, - ] - - # Filter power options based on the query using a generator - filtered_options = ( - ( - option - for option in power_options - if query.lower() in option["label"].lower() - ) - if query - else power_options - ) - - for option in filtered_options: - button = Button( - child=Box( - orientation="h", - spacing=10, - children=[ - MaterialIcon(option["icon"], size=28), - Label(label=option["label"], h_align="start"), - ], - ), - on_clicked=lambda _, action=option["action"]: action(), - name="launcher-item", - ) - viewport.add(button) - - def shutdown(self): - exec_shell_command("systemctl poweroff") - - def reboot(self): - exec_shell_command("systemctl reboot") - - def suspend(self): - exec_shell_command("systemctl suspend") - - def logout(self): - exec_shell_command("hyprctl dispatch logout") - - def lock(self): - exec_shell_command("hyprlock --immediate") - - def get_power_buttons(self): - return self.idle_button diff --git a/config/fabric/modules/launcher/widgets/shell.py b/config/fabric/modules/launcher/widgets/shell.py index 729c6544..e69de29b 100644 --- a/config/fabric/modules/launcher/widgets/shell.py +++ b/config/fabric/modules/launcher/widgets/shell.py @@ -1,78 +0,0 @@ -import os -import subprocess - -from fabric.widgets.button import Button -from fabric.widgets.label import Label -from snippets import MaterialIcon - -CACHE_DIR = os.getenv( - "XDG_CACHE_HOME", os.path.join(os.path.expanduser("~"), ".cache", "fabric") -) -BINS = os.path.join(CACHE_DIR, "binaries") - - -class ShellCommandManager: - def __init__(self, launcher): - self.launcher = launcher - self.binaries = set() # Use a set to store unique binaries - self.reload_binaries() - - def reload_binaries(self): - paths = os.getenv("PATH", "").split(":") - self.binaries = set() - - for path in paths: - self.binaries.update(self.list_binaries_in_path(path)) - - # Write unique binaries to the cache file - with open(BINS, "w") as f: - f.write("\n".join(self.binaries)) - - def list_binaries_in_path(self, path): - if not os.path.exists(path): - return [] - try: - return [ - entry - for entry in os.listdir(path) - if os.access(os.path.join(path, entry), os.X_OK) - ] - except OSError: - return [] - - def show_shell_commands(self, viewport, search_query: str): - if not search_query: - return - - results = self.query_binaries(search_query) - self.display_results(viewport, results) - - def query_binaries(self, filter_str: str): - # Use a generator to filter binaries on demand - filtered_bins = (cmd for cmd in self.binaries if filter_str in cmd) - return list(dict.fromkeys(filtered_bins))[:16] # Deduplicate and limit to 16 - - def display_results(self, viewport, results): - for command in results: - button = Button( - child=Label( - label=command, - v_align="center", - h_align="start", - ), - on_clicked=lambda _, cmd=command: self.execute_command(cmd), - name="launcher-item", - ) - viewport.add(button) - - def execute_command(self, cmd: str): - try: - output = subprocess.check_output(cmd, shell=True, text=True) - print(output) - except subprocess.CalledProcessError as e: - print(e.output) - finally: - self.launcher.set_visible(False) - - def get_shell_buttons(self): - return MaterialIcon("terminal") diff --git a/config/fabric/modules/launcher/widgets/todo.py b/config/fabric/modules/launcher/widgets/todo.py new file mode 100644 index 00000000..0c25b5b4 --- /dev/null +++ b/config/fabric/modules/launcher/widgets/todo.py @@ -0,0 +1,182 @@ +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 +from fabric.widgets.label import Label +from fabric.widgets.scrolledwindow import ScrolledWindow +from gi.repository import GLib +from snippets import MaterialIcon + + +class TodoManager(Box): + def __init__(self, **kwargs): + super().__init__( + name="todo-launcher", + all_visible=False, + visible=False, + **kwargs, + ) + + self._arranger_handler = 0 + self.todo_manager = TodoListManager(self) + self.viewport = None + + 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()), + ) + + self.header_box = Box( + name="header-box", + spacing=10, + orientation="h", + children=[ + self.todo_entry, + Button( + name="add-button", + child=MaterialIcon("add"), + tooltip_text="Add Todo", + on_clicked=lambda *_: self.handle_add_todo( + self.todo_entry.get_text() + ), + ), + Button( + name="close-button", + child=MaterialIcon("close"), + tooltip_text="Exit", + on_clicked=lambda *_: self.close_launcher(), + ), + ], + ) + + self.launcher_box = Box( + name="todo-launcher-box", + spacing=10, + orientation="v", + h_expand=True, + children=[self.header_box], + ) + + self.add(self.launcher_box) + + def open_launcher(self): + if not self.viewport: + self.viewport = Box(name="viewport", spacing=4, orientation="v") + self.scrolled_window = ScrolledWindow( + name="scrolled-window", + spacing=10, + h_scrollbar_policy="never", + v_scrollbar_policy="never", + child=self.viewport, + ) + self.launcher_box.add(self.scrolled_window) + + self.viewport.children = [] + self.todo_manager.arrange_viewport() + + 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) + self.todo_entry.set_text("") + + +class TodoListManager: + def __init__(self, launcher): + self.launcher = launcher + self.todos = [] + self.todo_file = os.path.expanduser("~/.local/share/fabric/todos.json") + self.load_todos() + + def load_todos(self): + os.makedirs(os.path.dirname(self.todo_file), exist_ok=True) + try: + if os.path.exists(self.todo_file): + with open(self.todo_file, "r") as f: + self.todos = json.load(f) + except Exception as e: + print(f"Error loading todos: {e}") + self.todos = [] + + def save_todos(self): + try: + with open(self.todo_file, "w") as f: + json.dump(self.todos, f) + except Exception as e: + print(f"Error saving todos: {e}") + + def add_todo(self, content: str): + todo = {"content": content, "completed": False, "id": len(self.todos)} + self.todos.append(todo) + self.save_todos() + self.arrange_viewport() + + def toggle_todo(self, todo_id: int): + for todo in self.todos: + if todo["id"] == todo_id: + todo["completed"] = not todo["completed"] + break + self.save_todos() + self.arrange_viewport() + + def delete_todo(self, todo_id: int): + self.todos = [todo for todo in self.todos if todo["id"] != todo_id] + self.save_todos() + self.arrange_viewport() + + def bake_todo_slot(self, todo: dict) -> Box: + todo_box = Box( + name="todo-item", + spacing=10, + orientation="h", + h_expand=True, + ) + + checkbox = Button( + name="todo-checkbox", + child=MaterialIcon( + "check_box" if todo["completed"] else "check_box_outline_blank" + ), + on_clicked=lambda _, todo_id=todo["id"]: self.toggle_todo(todo_id), + ) + + label = Label( + label=todo["content"], + h_expand=True, + v_align="center", + h_align="start", + name="todo-label-completed" if todo["completed"] else "todo-label", + ) + + delete_button = Button( + name="delete-button", + child=MaterialIcon("delete"), + on_clicked=lambda _, todo_id=todo["id"]: self.delete_todo(todo_id), + ) + + todo_box.add(checkbox) + todo_box.add(label) + todo_box.add(delete_button) + + return todo_box + + def arrange_viewport(self): + if not self.launcher.viewport: + return + + self.launcher.viewport.children = [] + + for todo in self.todos: + todo_slot = self.bake_todo_slot(todo) + self.launcher.viewport.add(todo_slot) diff --git a/config/fabric/modules/launcher/widgets/wallpaper.py b/config/fabric/modules/launcher/widgets/wallpaper.py deleted file mode 100644 index 7ea4b8a3..00000000 --- a/config/fabric/modules/launcher/widgets/wallpaper.py +++ /dev/null @@ -1,167 +0,0 @@ -import hashlib -import os - -from fabric.utils import exec_shell_command, exec_shell_command_async -from fabric.widgets.box import Box -from fabric.widgets.button import Button -from gi.repository import GdkPixbuf -from loguru import logger - -from snippets import MaterialIcon - - -class WallpaperManager: - IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".webp"} - CACHE_DIR = os.path.expanduser("~/.cache/fabric/thumbnails/wallpapers") - WALLPAPER_SCRIPT_PATH = os.path.expanduser("~/dotfiles/hypr/scripts/wallpaper.py") - - def __init__(self): - self.wallpaper_dir = os.path.expanduser("~/Pictures/wallpapers") - os.makedirs(self.CACHE_DIR, exist_ok=True) - self.thumbnails = [] - self.theme_toggle_button = self._create_theme_toggle_button() - self._update_button_style() - - def _create_theme_toggle_button(self): - return Button( - child=MaterialIcon("contrast"), - v_align="center", - on_clicked=self.toggle_dark_mode, - ) - - def toggle_dark_mode(self, *_): - exec_shell_command( - os.path.expanduser("~/fabric/assets/scripts/dark-theme.sh --toggle") - ) - self._update_button_style() - - 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 _update_button_style(self): - dark_mode = self.check_dark_mode_state() - style = ( - "background-color: @surfaceVariant; border-radius:100px; min-height:50px; min-width:50px;" - if dark_mode - else "background-color: transparent; border-radius:100px;" - ) - self.theme_toggle_button.set_style(style) - - def get_cache_path(self, file_name: str) -> str: - file_hash = hashlib.md5(file_name.encode("utf-8")).hexdigest() - return os.path.join(self.CACHE_DIR, f"{file_hash}.png") - - def create_thumbnail(self, image_path: str, thumbnail_size=100): - try: - pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_path) - width, height = pixbuf.get_width(), pixbuf.get_height() - if width > height: - new_width = thumbnail_size - new_height = int(height * (thumbnail_size / width)) - else: - new_height = thumbnail_size - new_width = int(width * (thumbnail_size / height)) - return pixbuf.scale_simple( - new_width, new_height, GdkPixbuf.InterpType.BILINEAR - ) - except Exception as e: - logger.error(f"Error creating thumbnail for {image_path}: {e}") - return None - - def generate_or_load_thumbnail(self, wallpaper_path): - cache_path = self.get_cache_path(os.path.basename(wallpaper_path)) - - if not os.path.exists(cache_path): - pixbuf = self.create_thumbnail(wallpaper_path) - if pixbuf: - pixbuf.savev(cache_path, "png", [], []) - return cache_path - - def show_wallpaper_thumbnails(self, viewport, search_term: str = ""): - wallpapers = list(self._get_wallpapers(search_term))[:24] - if not wallpapers: - self._show_no_wallpapers_message(viewport) - return - - self._display_thumbnails(viewport, wallpapers) - - def _show_no_wallpapers_message(self, viewport): - viewport.add( - Box( - orientation="h", - style="padding:20px;", - children=[Button(child="No wallpapers found!", v_align="center")], - ) - ) - - def _display_thumbnails(self, viewport, wallpapers): - row = Box(orientation="h", spacing=10, style="margin:5px;") - - for index, wallpaper in enumerate(wallpapers, 1): - thumbnail_path = self.generate_or_load_thumbnail(wallpaper) - row.add(self._create_wallpaper_thumbnail(thumbnail_path, wallpaper)) - - if index % 6 == 0: - viewport.add(row) - row = Box(orientation="h", spacing=10, style="margin:5px;") - - if row.children: - viewport.add(row) - - def _get_wallpapers(self, search_term: str): - return ( - os.path.join(self.wallpaper_dir, file_name) - for file_name in os.listdir(self.wallpaper_dir) - if os.path.isfile(os.path.join(self.wallpaper_dir, file_name)) - and os.path.splitext(file_name)[1].lower() in self.IMAGE_EXTENSIONS - and self._matches_search(file_name, search_term) - ) - - def _matches_search(self, file_name, search_term: str): - return not search_term or search_term.lower() in file_name.lower() - - def _thumbnail_style(self, thumbnail_path): - return ( - f"background-image: url('{thumbnail_path}'); " - "min-width: 64px; min-height: 64px; " - "background-repeat: no-repeat; " - "background-size: cover; background-position: center;" - ) - - def _create_wallpaper_thumbnail(self, thumbnail_path, wallpaper_path): - return Button( - child=Box( - orientation="h", - h_align="center", - v_align="center", - style=self._thumbnail_style(thumbnail_path), - ), - h_align="start", - v_align="center", - name="wall-item", - on_clicked=lambda _: self._select_wallpaper(wallpaper_path), - ) - - def _select_wallpaper(self, wallpaper_path): - self._apply_wallpaper(wallpaper_path) - - def _apply_wallpaper(self, wallpaper_path): - self._execute_wallpaper_script("--image", wallpaper_path) - - def apply_wallpaper_random(self): - self._execute_wallpaper_script("-R") - - def _execute_wallpaper_script(self, *args): - try: - exec_shell_command_async( - ["python3", self.WALLPAPER_SCRIPT_PATH, *args], - lambda output: logger.info(f"Wallpaper script output: {output}"), - ) - except Exception as e: - logger.error(f"Error executing wallpaper script: {e}") - - def get_wallpaper_buttons(self): - return self.theme_toggle_button diff --git a/config/fabric/modules/launcher/widgets/wallpapers.py b/config/fabric/modules/launcher/widgets/wallpapers.py new file mode 100644 index 00000000..d09babe0 --- /dev/null +++ b/config/fabric/modules/launcher/widgets/wallpapers.py @@ -0,0 +1,217 @@ +import hashlib +import json +import os + +from fabric.widgets.box import Box +from fabric.widgets.button import Button +from fabric.widgets.entry import Entry +from fabric.widgets.scrolledwindow import ScrolledWindow +from gi.repository import GdkPixbuf, GLib, Gtk +from snippets import MaterialIcon + + +class WallpaperSelector(Box): + CACHE_DIR = os.path.expanduser("~/.cache/fabric/wallpapers") + SETTINGS_FILE = os.path.expanduser("~/dotfiles/.settings/settings.json") + + SCHEMES = { + "TonalSpot": "tonalSpot", + "Expressive": "expressive", + "FruitSalad": "fruitSalad", + "Monochrome": "monochrome", + "Rainbow": "rainbow", + "Vibrant": "vibrant", + "Neutral": "neutral", + "Fidelity": "fidelity", + "Content": "content", + } + + def __init__(self, wallpapers_dir: str, **kwargs): + super().__init__(name="wallpapers", spacing=4, orientation="v", **kwargs) + + self.wallpapers_dir = wallpapers_dir + os.makedirs(self.CACHE_DIR, exist_ok=True) + + self.files = [f for f in os.listdir(wallpapers_dir) if self._is_image(f)] + self.thumbnails = [] + + self._init_viewport() + self._init_search_entry() + self._init_scheme_dropdown() + self._init_layout() + + self._start_thumbnail_thread() + self.show_all() + + def _init_viewport(self): + self.viewport = Gtk.IconView() + self.viewport.set_model(Gtk.ListStore(GdkPixbuf.Pixbuf, str)) + self.viewport.set_pixbuf_column(0) + self.viewport.set_text_column(1) + self.viewport.set_item_width(0) + self.viewport.connect("item-activated", self.on_wallpaper_selected) + + self.scrolled_window = ScrolledWindow( + name="scrolled-window", + spacing=10, + h_expand=True, + v_expand=True, + child=self.viewport, + ) + + 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()), + ) + + def _init_scheme_dropdown(self): + self.scheme_dropdown = Gtk.ComboBoxText() + self.scheme_dropdown.set_name("scheme-dropdown") + self.scheme_dropdown.set_tooltip_text("Select color scheme") + + for display_name, scheme_id in sorted(self.SCHEMES.items()): + self.scheme_dropdown.append(scheme_id, display_name) + + self.scheme_dropdown.set_active_id("tonalSpot") + self.scheme_dropdown.connect("changed", self.on_scheme_changed) + + self.dropdown_box = Box( + name="dropdown-box", + spacing=10, + orientation="h", + children=[ + self.scheme_dropdown, + MaterialIcon("keyboard_arrow_down"), + ], + ) + + def _init_layout(self): + self.header_box = 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(), + ), + ], + ) + + 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 = [ + (thumb, name) + for thumb, name in self.thumbnails + if query.casefold() in name.casefold() + ] + + filtered_thumbnails.sort(key=lambda x: x[1].lower()) + + for pixbuf, file_name in filtered_thumbnails: + self.viewport.get_model().append([pixbuf, file_name]) + + def on_wallpaper_selected(self, iconview, path): + model = iconview.get_model() + file_name = model[path][1] + full_path = os.path.join(self.wallpapers_dir, file_name) + selected_scheme = self.scheme_dropdown.get_active_id() + home_dir = GLib.get_home_dir() + command = ( + f"python -O {home_dir}/dotfiles/hypr/scripts/wallpaper.py -I {full_path}" + ) + GLib.spawn_command_line_async(command) + self.update_scheme(selected_scheme) + + def on_scheme_changed(self, combo): + scheme_id = combo.get_active_id() + display_name = next( + 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 + + # Apply the selected scheme immediately + home_dir = GLib.get_home_dir() + color_generator = os.path.join(home_dir, "dotfiles/material-colors/generate.py") + try: + command = f'python -O {color_generator} -R --scheme "{scheme_id}"' + GLib.spawn_command_line_async(command) + print(f"Applied color scheme: {display_name}") + except Exception as e: + print(f"Failed to apply color scheme: {e}") + + def update_scheme(self, scheme: str): + try: + with open(self.SETTINGS_FILE, "r") as f: + settings = json.loads(f.read()) + + settings["generation-scheme"] = scheme + + with open(self.SETTINGS_FILE, "w") as f: + json.dump(settings, f, indent=2) + except Exception as error: + print(f"Failed to update generation-scheme in settings.json: {error}") + + def _start_thumbnail_thread(self): + thread = GLib.Thread.new("thumbnail-loader", self._preload_thumbnails, None) + + def _preload_thumbnails(self, _data): + for file_name in sorted(self.files): + full_path = os.path.join(self.wallpapers_dir, file_name) + cache_path = self._get_cache_path(file_name) + + if not os.path.exists(cache_path): + pixbuf = self._create_thumbnail(full_path) + if pixbuf: + pixbuf.savev(cache_path, "png", [], []) + else: + pixbuf = GdkPixbuf.Pixbuf.new_from_file(cache_path) + + if pixbuf: + GLib.idle_add(self._add_thumbnail_to_view, pixbuf, file_name) + + def _add_thumbnail_to_view(self, pixbuf, file_name): + self.thumbnails.append((pixbuf, file_name)) + self.viewport.get_model().append([pixbuf, file_name]) + return False + + def _create_thumbnail(self, image_path: str, thumbnail_size=96): + try: + pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_path) + width, height = pixbuf.get_width(), pixbuf.get_height() + if width > height: + new_width = thumbnail_size + new_height = int(height * (thumbnail_size / width)) + else: + new_height = thumbnail_size + new_width = int(width * (thumbnail_size / height)) + return pixbuf.scale_simple( + new_width, new_height, GdkPixbuf.InterpType.BILINEAR + ) + except Exception as e: + print(f"Error creating thumbnail for {image_path}: {e}") + return None + + def _get_cache_path(self, file_name: str) -> str: + file_hash = hashlib.md5(file_name.encode("utf-8")).hexdigest() + return os.path.join(self.CACHE_DIR, f"{file_hash}.png") + + @staticmethod + def _is_image(file_name: str) -> bool: + return file_name.lower().endswith( + (".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp") + ) diff --git a/config/fabric/modules/launcher/widgets/wifi.py b/config/fabric/modules/launcher/widgets/wifi.py index 0b8ee2a2..e69de29b 100644 --- a/config/fabric/modules/launcher/widgets/wifi.py +++ b/config/fabric/modules/launcher/widgets/wifi.py @@ -1,99 +0,0 @@ -from fabric.widgets.box import Box -from fabric.widgets.button import Button -from fabric.widgets.image import Image -from fabric.widgets.label import Label -from services import NetworkClient -from snippets import MaterialIcon - - -class WifiMenu: - def __init__(self, launcher): - self.launcher = launcher - self.client = NetworkClient() - self.paired_devices = {} - self.available_devices = {} - - self.wifi_toggle_button = Button( - child=MaterialIcon("signal_wifi_4_bar"), - h_align="center", - v_align="center", - on_clicked=self.toggle_wifi, - ) - self.update_wifi_button_style() - - self.rescan_button = Button( - child=MaterialIcon("refresh"), - h_align="center", - v_align="center", - on_clicked=self.scan_for_networks, - ) - - self.client.device_ready.connect(self.on_device_added) - - def update_wifi_button_style(self): - if self.check_wifi_state(): - self.wifi_toggle_button.set_style("background-color: transparent;") - else: - self.wifi_toggle_button.set_style( - "background-color: @surfaceVariant; border-radius:100px; min-height:50px; min-width:50px;" - ) - - def check_wifi_state(self): - return self.client.wifi_device.enabled if self.client.wifi_device else False - - def show_wifi_menu(self, viewport): - viewport.children = [] - - devices_box = Box(orientation="v", spacing=5) - - # Iterate over the list of available access points - for ap in self.client.wifi_device.access_points: - is_connected = ap["ssid"] == self.client.wifi_device.ssid # Compare SSID - - device_button = Button( - child=Box( - orientation="h", - spacing=10, - children=[ - Image(icon_name=ap["icon-name"], size=32), - Label(label=ap["ssid"]), # Show SSID - Box( - orientation="h", - children=[ - Label( - label="Connected" if is_connected else "", - h_align="end", - ), - ], - ), - ], - ), - on_clicked=lambda _, ap=ap: ( - self.connect_to_ap(ap, is_connected), - self.launcher.set_visible(False), - ), - name="launcher-item", - ) - devices_box.add(device_button) - - viewport.add(devices_box) - - def connect_to_ap(self, ap, is_connected): - if not is_connected: - self.client.connect_wifi_bssid(ap["bssid"]) - - def on_device_added(self, client): - self.show_wifi_menu(self.launcher.viewport) - - def scan_for_networks(self, button): - self.client.wifi_device.scan() - self.show_wifi_menu(self.launcher.viewport) - - def toggle_wifi(self, button): - self.update_wifi_button_style() - if self.client.wifi_device: - self.client.wifi_device.toggle_wifi() - self.show_wifi_menu(self.launcher.viewport) - - def get_wifi_buttons(self): - return [self.wifi_toggle_button, self.rescan_button] -- 2.43.0 From f127b074fdf14d4bfd73e8eaa7c8c8d0cf4625f7 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 07:59:04 +0545 Subject: [PATCH 02/38] integrate all module in launcher --- config/fabric/modules/launcher/launcher.py | 402 +++++++++------------ 1 file changed, 161 insertions(+), 241 deletions(-) diff --git a/config/fabric/modules/launcher/launcher.py b/config/fabric/modules/launcher/launcher.py index b4f6596f..72ddd180 100644 --- a/config/fabric/modules/launcher/launcher.py +++ b/config/fabric/modules/launcher/launcher.py @@ -1,279 +1,199 @@ -from fabric.utils import ( - get_desktop_applications, - idle_add, - invoke_repeater, - 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.revealer import Revealer -from fabric.widgets.scrolledwindow import ScrolledWindow +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 ( - BluetoothMenu, - Calendar, - ClipboardManager, - EmojiManager, + AppLauncher, + Cliphist, + Emoji, PowerMenu, - ShellCommandManager, - WallpaperManager, - WifiMenu, - handle_application_search, -) -from snippets import ( - MaterialIcon, - get_current_uptime, - get_profile_picture_path, - read_config, - username, + TodoManager, + WallpaperSelector, ) class Launcher(Window): def __init__(self, **kwargs): - self.config = read_config() super().__init__( layer="top", anchor="center", - exclusivity="none", - keyboard_mode="on-demand", visible=False, all_visible=False, - **kwargs, ) - self.all_apps = get_desktop_applications() - self.initialize_managers() - self.uptime_label = Label( - label=get_current_uptime(), style="margin-left: 60px;" + + self.launcher = AppLauncher() + self.wallpapers = WallpaperSelector(os.path.expanduser("~/Pictures/wallpapers")) + self.power = PowerMenu() + self.emoji = Emoji() + self.cliphist = Cliphist() + self.todo = TodoManager() + + # Initialize viewports as None + self._emoji_viewport = None + self._cliphist_viewport = None + self._todo_viewport = None + + self.stack = Stack( + name="launcher-content", + v_expand=True, + h_expand=True, + transition_type="crossfade", + transition_duration=250, + children=[ + self.launcher, + self.wallpapers, + self.power, + self.emoji, + self.cliphist, + self.todo, + ], ) - self.commands = self.config.get("commands", []) - self.command_map = self.build_command_map() - self.setup_ui() - self.connect("key-press-event", self.on_key_press) - self.update_uptime_label() - def initialize_managers(self): - self.clipboard_manager = ClipboardManager(self, self.get_viewport()) - self.emoji_manager = EmojiManager(self) - self.shell_command_manager = ShellCommandManager(self) - self.wallpaper_manager = WallpaperManager() - self.power_menu = PowerMenu(self) - self.bluetooth_menu = BluetoothMenu(self) - self.network_menu = WifiMenu(self) - self.calendar_menu = Calendar(self) - - def setup_ui(self): - self.default_button = Button( - child=MaterialIcon("grid_view"), + self.launcher_box = CenterBox( + name="launcher", + orientation="h", h_align="center", v_align="center", + start_children=self.stack, ) - self.scrolled_window = self.create_scrolled_window() - self.scrolled_revealer = self.create_revealer() - self.search_entry = self.create_search_entry() - self.additional_box = self.create_additional_box() - self.search_box = Box( - spacing=10, - orientation="h", - children=[self.search_entry, self.default_button], - ) - launcher_box = Box( - orientation="v", - name="launcher", - children=[ - self.search_box, - self.additional_box, - self.scrolled_revealer, - ], - ) - self.add(launcher_box) + + 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() - - def create_search_entry(self): - entry = Entry( - placeholder="Type ':' to list subcommands", - h_expand=True, - notify_text=lambda entry, *_: self.debounce_search(entry.get_text()), - ) - entry.set_icon_from_icon_name(0, "preferences-system-search-symbolic") - return entry - - def create_scrolled_window(self): - return ScrolledWindow( - style=" transition: min-height 50s cubic-bezier(0.42, 0, 0.58, 1);", - child=self.get_viewport(), - h_scrollbar_policy="never", - v_scrollbar_policy="never", - ) - - def create_revealer(self): - return Revealer( - style=" transition: min-height 50s cubic-bezier(0.42, 0, 0.58, 1);", - child=self.scrolled_window, - transition_type="crossfade", - ) - - def create_additional_box(self): - return Box( - orientation="h", - spacing=10, - children=[ - Box( - name="profile-pic", - style=f"background-image: url(\"file://{get_profile_picture_path() or ''}\")", - ), - Label(label=username()), - self.uptime_label, - ], - ) - - def get_viewport(self): - if not hasattr(self, "viewport"): - self.viewport = Box(spacing=10, orientation="v") - return self.viewport - - def update_uptime_label(self): - self.uptime_label.set_label(get_current_uptime()) - invoke_repeater( - 60 * 1000, lambda: self.uptime_label.set_label(get_current_uptime()) - ) - - def build_command_map(self): - return {cmd["command"]: cmd["handler"] for cmd in self.commands} - - def debounce_search(self, query: str): - if hasattr(self, "_arranger_handler"): - remove_handler(self._arranger_handler) - self._arranger_handler = idle_add(self.arrange_viewport, query, pin=True) - - def arrange_viewport(self, query: str = ""): - - self.get_viewport().children = [] - for command, handler_name in self.command_map.items(): - if query.startswith(command): - handler = getattr(self, handler_name, None) - if handler: - handler(query[len(command) :].strip()) - return - - if query.startswith(":"): - self.additional_box.set_visible(False) - self.update_dynamic_button([self.default_button]) - self.show_help(query[1:]) - self.scrolled_revealer.reveal() - return - handle_application_search(self, query) - - def update_dynamic_button(self, new_buttons): - if not isinstance(new_buttons, list): - new_buttons = [new_buttons] - for child in self.search_box.children[1:]: - self.search_box.remove(child) - for new_button in new_buttons: - self.search_box.add(new_button) + self.hide() + self.wallpapers.viewport.hide() def on_key_press(self, widget, event): - from gi.repository import Gdk - - if self.is_visible() and event.keyval == Gdk.KEY_Escape: - self.set_visible(False) + if event.keyval == Gdk.KEY_Escape: + self.close() return True return False - def load_commands(self): - return {cmd["command"]: cmd["description"] for cmd in self.commands} + def on_button_enter(self, widget, event): + window = widget.get_window() + if window: + window.set_cursor(Gdk.Cursor(Gdk.CursorType.HAND2)) - def show_help(self, query: str): - filtered_help = [ - (command, description) - for command, description in self.load_commands().items() - if query.lower() in command[1:].lower() + def on_button_leave(self, widget, event): + window = widget.get_window() + if window: + window.set_cursor(None) + + def close(self): + self.set_keyboard_mode("none") + self.hide() + + for widget in [ + self.launcher, + self.wallpapers, + self.power, + self.emoji, + self.cliphist, + self.todo, + ]: + widget.remove_style_class("open") + + # Handle wallpaper viewport + if widget == self.wallpapers: + self.wallpapers.viewport.hide() + self.wallpapers.viewport.set_property("name", None) + + # Handle emoji viewport safely + if widget == self.emoji and hasattr(widget, "viewport") and widget.viewport: + widget.viewport.hide() + + # Handle cliphist viewport safely + if ( + widget == self.cliphist + and hasattr(widget, "viewport") + and widget.viewport + ): + widget.viewport.hide() + + if widget == self.todo and hasattr(widget, "viewport") and widget.viewport: + widget.viewport.hide() + + style_classes = [ + "launcher", + "wallpapers", + "power", + "emoji", + "cliphist", + "todo", ] + 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) - if not filtered_help: - return - for command, description in filtered_help: - button = Button( - child=self.create_help_button_content(command, description), - name="launcher-item", - ) - self.get_viewport().add(button) + return True - def create_help_button_content(self, command, description): - return Box( - orientation="h", - spacing=10, - children=[ - Label(label=command, h_expand=True, h_align="start"), - Label( - label=description, - h_expand=True, - h_align="end", - ), - ], - ) + def open(self, widget): + self.set_keyboard_mode("exclusive") + self.show() - def toggle(self): - self.set_visible(not self.is_visible()) - if self.is_visible(): - self.update_dynamic_button(self.default_button) - self.search_entry.set_text("") - self.search_entry.grab_focus() + widgets = { + "launcher": self.launcher, + "wallpapers": self.wallpapers, + "power": self.power, + "emoji": self.emoji, + "cliphist": self.cliphist, + "todo": self.todo, + } - def show_network(self, *_): - self.network_menu.show_wifi_menu(self.viewport) - dynamic_buttons = self.network_menu.get_wifi_buttons() - self.update_dynamic_button(dynamic_buttons) - self.scrolled_revealer.reveal() + 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) - def show_emojis(self, query: str): - self.emoji_manager.show_emojis(self.get_viewport(), query) - dynamic_buttons = self.emoji_manager.get_emoji_buttons() - self.update_dynamic_button(dynamic_buttons) - self.scrolled_revealer.reveal() + for w in widgets.values(): + w.remove_style_class("open") - def show_clipboard_history(self, query: str): - self.clipboard_manager.show_clipboard_history(self.get_viewport(), query) - dynamic_buttons = self.clipboard_manager.get_clipboard_buttons() - self.update_dynamic_button(dynamic_buttons) - self.scrolled_revealer.reveal() + 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") - def show_powermenu(self, query: str = ""): - self.power_menu.show_power_menu(self.get_viewport(), query) - dynamic_buttons = self.power_menu.get_power_buttons() - self.update_dynamic_button(dynamic_buttons) - self.scrolled_revealer.reveal() + if widget == "launcher": + self.launcher.open_launcher() + self.launcher.search_entry.set_text("") + self.launcher.search_entry.grab_focus() - def show_shell_commands(self, query: str): - if not query: - dynamic_buttons = self.shell_command_manager.get_shell_buttons() - self.update_dynamic_button(dynamic_buttons) - self.scrolled_revealer.unreveal() - return - self.shell_command_manager.show_shell_commands(self.get_viewport(), query) - dynamic_buttons = self.shell_command_manager.get_shell_buttons() - self.update_dynamic_button(dynamic_buttons) - self.scrolled_revealer.reveal() + 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" + ), + ), + ) - def show_wallpapers(self, query: str): - if query == "random": - self.wallpaper_manager.apply_wallpaper_random() - else: - self.wallpaper_manager.show_wallpaper_thumbnails(self.get_viewport(), query) - dynamic_buttons = self.wallpaper_manager.get_wallpaper_buttons() - self.update_dynamic_button(dynamic_buttons) - self.scrolled_revealer.reveal() + elif widget == "emoji": + self.emoji.open_launcher() + self.emoji.search_entry.set_text("") + self.emoji.search_entry.grab_focus() - def show_bluetooth_settings(self, *_): - self.bluetooth_menu.show_bluetooth_menu(self.viewport) - dynamic_buttons = self.bluetooth_menu.get_bluetooth_buttons() - self.update_dynamic_button(dynamic_buttons) - self.scrolled_revealer.reveal() + elif widget == "cliphist": + self.cliphist.open_launcher() + self.cliphist.search_entry.set_text("") + self.cliphist.search_entry.grab_focus() - def show_calendar(self, *_): - self.calendar_menu.show_calendar_menu(self.viewport) - dynamic_buttons = self.calendar_menu.get_calendar_buttons() - self.update_dynamic_button(dynamic_buttons) - self.scrolled_revealer.reveal() + elif widget == "todo": + self.todo.open_launcher() + self.todo.todo_entry.set_text("") + self.todo.todo_entry.grab_focus() + + else: + if hasattr(self.wallpapers, "viewport"): + self.wallpapers.viewport.hide() + self.wallpapers.viewport.set_property("name", None) -- 2.43.0 From eba42cb6a984c2632b7899174a222102b9527f64 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 08:00:54 +0545 Subject: [PATCH 03/38] added styles --- config/fabric/main.py | 27 ++- config/fabric/styles/bar.css | 13 +- config/fabric/styles/launcher.css | 171 ++------------- config/fabric/styles/launcher/applauncher.css | 42 ++++ config/fabric/styles/launcher/bluetooth.css | 0 config/fabric/styles/launcher/cliphist.css | 29 +++ config/fabric/styles/launcher/dashboard.css | 0 config/fabric/styles/launcher/emoji.css | 16 ++ config/fabric/styles/launcher/powermenu.css | 26 +++ config/fabric/styles/launcher/todo.css | 24 +++ config/fabric/styles/launcher/wallpapers.css | 27 +++ config/fabric/styles/launcher/wifi.css | 0 config/fabric/styles/main.css | 10 +- config/material-colors/generate.py | 197 +++++++++--------- .../templates/alacritty-dark.toml | 72 +++++++ .../templates/alacritty-light.toml | 72 +++++++ .../material-colors/templates/alacritty.toml | 10 + .../templates/material-discord.scss | 51 +++-- 18 files changed, 497 insertions(+), 290 deletions(-) create mode 100644 config/fabric/styles/launcher/applauncher.css create mode 100644 config/fabric/styles/launcher/bluetooth.css create mode 100644 config/fabric/styles/launcher/cliphist.css create mode 100644 config/fabric/styles/launcher/dashboard.css create mode 100644 config/fabric/styles/launcher/emoji.css create mode 100644 config/fabric/styles/launcher/powermenu.css create mode 100644 config/fabric/styles/launcher/todo.css create mode 100644 config/fabric/styles/launcher/wallpapers.css create mode 100644 config/fabric/styles/launcher/wifi.css create mode 100644 config/material-colors/templates/alacritty-dark.toml create mode 100644 config/material-colors/templates/alacritty-light.toml create mode 100644 config/material-colors/templates/alacritty.toml diff --git a/config/fabric/main.py b/config/fabric/main.py index 0e3199eb..6237311c 100644 --- a/config/fabric/main.py +++ b/config/fabric/main.py @@ -1,10 +1,10 @@ import os import setproctitle -from loguru import logger - from fabric import Application from fabric.utils import get_relative_path, monitor_file +from loguru import logger + from modules.bar.bar import Bar from modules.launcher.launcher import Launcher from modules.notification_popup import NotificationPopup @@ -14,18 +14,34 @@ from services import ScreenRecorder logger.disable("fabric.hyprland.widgets") +def update_main_css(): + colors_css_path = f"/home/{os.getlogin()}/.cache/material/colors.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) + css_file.seek(0) + css_file.write(updated_content) + css_file.truncate() + else: + logger.warning(f"[Main] colors.css not found at {colors_css_path}") + + def apply_style(app: Application): - logger.info("[Main] CSS applied") + logger.info("[Main] Applying CSS") app.set_stylesheet_from_file(get_relative_path("styles/main.css")) if __name__ == "__main__": + update_main_css() sc = ScreenRecorder() bar = Bar() osd = OSDContainer() notif = NotificationPopup() launcher = Launcher() - launcher.hide() app = Application( "quickbar", @@ -35,12 +51,13 @@ if __name__ == "__main__": ) setproctitle.setproctitle("quickbar") + # Monitor CSS files for changes css_file = monitor_file(get_relative_path("styles")) _ = css_file.connect("changed", lambda *_: apply_style(app)) color_css_file = monitor_file(f"/home/{os.getlogin()}/.cache/material/colors.css") _ = color_css_file.connect("changed", lambda *_: apply_style(app)) + # Apply the styles and run the application apply_style(app) - app.run() diff --git a/config/fabric/styles/bar.css b/config/fabric/styles/bar.css index 1e3d4137..d1edd9b0 100644 --- a/config/fabric/styles/bar.css +++ b/config/fabric/styles/bar.css @@ -86,20 +86,25 @@ } menu { + border: solid 1px @outlineVariant; + border-radius: 16px; background-color: @surfaceContainer; + padding: 6px; } menu > menuitem { - border-radius: 12px; - padding: 10px; - margin-left: 2px; - margin-right: 2px; + border-radius: 10px; + padding: 6px 10px; } menu > menuitem:hover { background-color: mix(@onSurface, @surface, 0.85); } +menu > menuitem:hover > label { + color: @onSurface; +} + /* * ── applets ─────────────────────────────────────────────────────────── */ diff --git a/config/fabric/styles/launcher.css b/config/fabric/styles/launcher.css index 0ad7cb01..32a88b69 100644 --- a/config/fabric/styles/launcher.css +++ b/config/fabric/styles/launcher.css @@ -4,7 +4,7 @@ background-color: @surface; border-radius: 24px; padding: 18px; - min-width: 480px; + transition: all 0.5s cubic-bezier(0.5, 0.25, 0, 1); } #launcher entry { @@ -28,159 +28,26 @@ background-color: transparent; } -#profile-pic { - background-color: transparent; - background-position: center; - background-repeat: no-repeat; - background-size: cover; +#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: 20px; - margin: 4px; + padding: 10px; } -#launcher button#app-item { - border-radius: 11px; - background-color: transparent; - background-image: none; - box-shadow: none; - transition: 200ms; - padding: 7px; -} - -#launcher button#app-item:hover #title, -#launcher button#app-item:focus #title { - color: @primar; -} - -#launcher button#app-item:hover #description, -#launcher button#app-item:focus #description { - color: @inversePrimary; -} - -#launcher button#app-item:hover image, -#launcher button#app-item:focus image { - -gtk-icon-shadow: 2px 2px @primary; -} - -#launcher button#app-item:active { - background-color: @primaryContainer; - border-radius: 11px; - box-shadow: inset 0 0 0 1px rgba(158, 142, 130, 0.04); -} - -#launcher button#app-item:active #title { - color: @foreground; -} - -#launcher button#emoji-item { - border-radius: 11px; - background-color: transparent; - background-image: none; - box-shadow: none; - padding: 0px; -} - -#launcher button#emoji-item:disabled { - color: mix(@onSurface, transparent, 0.38); -} - -#launcher button#emoji-item label { - font-size: 24px; -} - -#launcher button#emoji-item:hover, -#launcher button#emoji-item:focus { - text-shadow: 2px 2px 2px @primary; -} - -#launcher button#cliphist-img-item { - background-size: cover; - background-position: center; - background-repeat: no-repeat; - border-radius: 8px; - min-width: 70px; - min-height: 70px; -} - -#launcher button#cliphist-img-item:hover, -#launcher button#cliphist-img-item:focus { - box-shadow: 2px 2px 2px @primary; -} - -#launcher button#launcher-item { - border-radius: 11px; - background-color: transparent; - background-image: none; - box-shadow: none; -} - -#launcher button#launcher-item:disabled { - color: mix(@onSurface, transparent, 0.38); -} - -#launcher button#launcher-item:hover, -#launcher button#launcher-item:focus { - text-shadow: 2pt 2pt 2pt @primary; -} - -#launcher button#wall-item { - border-radius: 0px; - background-color: transparent; - background-image: none; - box-shadow: none; - padding: 5px; -} - -#launcher button#wall-item:disabled { - color: mix(@onSurface, transparent, 0.38); -} - -#launcher button#wall-item:hover, -#launcher button#wall-item:focus { - box-shadow: 2pt 2pt 2pt @primary; -} - -.activated { - background-color: @surfaceVariant; +#close-button:hover, +#close-button:focus { border-radius: 100px; -} - -#calendar calendar { - all: unset; - font-size: 18px; - padding: 5px; -} - -#calendar calendar.button { - all: unset; - transition: 200ms; - border-radius: 10px; - background-color: transparent; - background-image: none; - box-shadow: none; -} - -#calendar calendar:selected { - box-shadow: - inset 0 -7px 0 0 @primary, - inset 0 0 0 1px @surfaceVariant; - border-radius: 6px; -} - -#calendar calendar.header { - background-color: transparent; - border: none; -} - -#calendar calendar.highlight { - background-color: transparent; - color: @onSurface; -} - -#calendar calendar:hover { - color: @errorContainer; -} - -#calendar calendar:indeterminate { - color: mix(@onSurfaceVariant, transparent, 0.3); + background-color: @errorContainer; } diff --git a/config/fabric/styles/launcher/applauncher.css b/config/fabric/styles/launcher/applauncher.css new file mode 100644 index 00000000..87b7f793 --- /dev/null +++ b/config/fabric/styles/launcher/applauncher.css @@ -0,0 +1,42 @@ +#app-slot-button { + border-radius: 16px; + padding: 16px; + transition: padding 0.25s cubic-bezier(0.5, 0.25, 0, 1); + animation: loadSlot 0.5s ease; +} + +@keyframes loadSlot { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +#app-slot-button:hover, +#app-slot-button:focus { + background-color: mix(@onSurface, @surface, 0.92); + padding-left: 24px; +} + +#app-slot-button:active { + background-color: @primaryContainer; +} + +#app-label { + color: @onSurface; +} + +#wallpaper-icons { + animation: fade-in 0.25s ease-in-out; +} + +@keyframes fade-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} diff --git a/config/fabric/styles/launcher/bluetooth.css b/config/fabric/styles/launcher/bluetooth.css new file mode 100644 index 00000000..e69de29b diff --git a/config/fabric/styles/launcher/cliphist.css b/config/fabric/styles/launcher/cliphist.css new file mode 100644 index 00000000..52afcb1a --- /dev/null +++ b/config/fabric/styles/launcher/cliphist.css @@ -0,0 +1,29 @@ +#cliphist-launcher-box button#clip-img-item { + background-size: cover; + background-position: center; + background-repeat: no-repeat; + border-radius: 8px; + min-width: 70px; + min-height: 70px; +} + +#cliphist-launcher-box button#clip-img-item:hover, +#cliphist-launcher-box button#clip-img-item:focus { + box-shadow: 2px 2px 2px @primary; +} + +#cliphist-launcher-box button#clip-item { + border-radius: 11px; + background-color: transparent; + background-image: none; + box-shadow: none; + padding: 7px; +} +#cliphist-launcher-box button#clip-item { + font-size: 24px; +} + +#cliphist-launcher-box button#clip-item:hover, +#cliphist-launcher-box button#clip-item:focus { + text-shadow: 2px 2px 2px @primary; +} diff --git a/config/fabric/styles/launcher/dashboard.css b/config/fabric/styles/launcher/dashboard.css new file mode 100644 index 00000000..e69de29b diff --git a/config/fabric/styles/launcher/emoji.css b/config/fabric/styles/launcher/emoji.css new file mode 100644 index 00000000..146ceec9 --- /dev/null +++ b/config/fabric/styles/launcher/emoji.css @@ -0,0 +1,16 @@ +#emoji-launcher-box button#emoji-item { + border-radius: 11px; + background-color: transparent; + background-image: none; + box-shadow: none; + padding: 0px; +} + +#emoji-launcher-box button#emoji-item label { + font-size: 24px; +} + +#emoji-launcher-box button#emoji-item:hover, +#emoji-launcher-box button#emoji-item:focus { + text-shadow: 2px 2px 2px @primary; +} diff --git a/config/fabric/styles/launcher/powermenu.css b/config/fabric/styles/launcher/powermenu.css new file mode 100644 index 00000000..fbbbb471 --- /dev/null +++ b/config/fabric/styles/launcher/powermenu.css @@ -0,0 +1,26 @@ +#power-menu-button { + border-radius: 20px; + padding: 20px; +} + +#power-menu-button:hover, +#power-menu-button:focus { + background-color: mix(@onSurface, @surface, 0.8); +} + +#power-menu-button:hover label, +#power-menu-button:focus label { + color: @primary; +} + +#power-menu-button:active { + background-image: radial-gradient( + circle, + mix(@onSurfaceVariant, transparent, 0.7) 10%, + transparent 0% + ); +} + +#power-menu-button:active label { + color: @shadow; +} diff --git a/config/fabric/styles/launcher/todo.css b/config/fabric/styles/launcher/todo.css new file mode 100644 index 00000000..b10f5635 --- /dev/null +++ b/config/fabric/styles/launcher/todo.css @@ -0,0 +1,24 @@ +#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; +} diff --git a/config/fabric/styles/launcher/wallpapers.css b/config/fabric/styles/launcher/wallpapers.css new file mode 100644 index 00000000..d981758e --- /dev/null +++ b/config/fabric/styles/launcher/wallpapers.css @@ -0,0 +1,27 @@ +#wallpaper-icons { + animation: fade-in 0.25s ease-in-out; +} + +@keyframes fade-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} + +#wallpaper-icons:selected { + background-color: @primary; + color: @background; + border-radius: 8px; +} + +#dropdown-box { + background-color: @surface; + padding: 8px; +} + +#scheme-dropdown { + font-weight: bold; +} diff --git a/config/fabric/styles/launcher/wifi.css b/config/fabric/styles/launcher/wifi.css new file mode 100644 index 00000000..e69de29b diff --git a/config/fabric/styles/main.css b/config/fabric/styles/main.css index e99c6262..acb1b38e 100644 --- a/config/fabric/styles/main.css +++ b/config/fabric/styles/main.css @@ -1,8 +1,14 @@ -@import url(/home/sankalp/.cache/material/colors.css); -@import "./launcher.css"; +@import url(../../.cache/material/colors.css); @import "./bar.css"; @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"; * { all: unset; diff --git a/config/material-colors/generate.py b/config/material-colors/generate.py index d4edcc57..32504e0c 100644 --- a/config/material-colors/generate.py +++ b/config/material-colors/generate.py @@ -41,7 +41,7 @@ def join(*args): return os.path.join(*args) -home = os.path.expanduser("~") +home = os.path.expanduser('~') script_dir = os.path.dirname(os.path.abspath(__file__)) cache_path = f"{home}/.cache/material/" @@ -49,14 +49,14 @@ os.makedirs(cache_path, exist_ok=True) def rgb_to_hex(rgb): - return "#{:02x}{:02x}{:02x}".format(*rgb[:3]) + return '#{:02x}{:02x}{:02x}'.format(*rgb[:3]) def rgba_to_rgb(rgba): - return f"{rgba[0]}, {rgba[1]}, {rgba[2]}" + return f'{rgba[0]}, {rgba[1]}, {rgba[2]}' -class Color: +class Color(): def __init__(self, scheme) -> None: self.scheme = scheme @@ -70,12 +70,8 @@ class Color: class ColorsCache: def __init__( - self, - colors: DynamicScheme | dict, - wallpaper: str, - original_color: int, - contrast_level: int, - scheme_name: str, + self, colors: DynamicScheme | dict, wallpaper: str, + original_color: int, contrast_level: int, scheme_name: str ) -> None: self.colors: dict[str, str] = {} self.wallpaper = wallpaper @@ -99,7 +95,7 @@ def colors_dict(cache: ColorsCache): "colors": cache.colors, "original_color": cache.original_color, "contrast_level": cache.contrast_level, - "scheme_name": cache.scheme_name, + "scheme_name": cache.scheme_name } return dict @@ -112,7 +108,10 @@ def get_cache_object(object: dict | str): original_color = object["original_color"] contrast_level = object.get("contrast_level", 0) scheme_name = object.get("scheme_name", "tonalSpot") - return ColorsCache(colors, wallpaper, original_color, contrast_level, scheme_name) + return ColorsCache( + colors, wallpaper, original_color, + contrast_level, scheme_name + ) def get_file_list(folder_path): @@ -125,9 +124,11 @@ def get_file_list(folder_path): ready_templates = { "colors.css": "@define-color {name} {hex};\n", - "colors.scss": "${name}: {hex};\n", + "colors.scss": "${name}: {hex};\n" +} +additional = { + "onBackground": "foreground" } -additional = {"onBackground": "foreground"} def generate_color_map(scheme: DynamicScheme): @@ -146,23 +147,25 @@ class ColorFormatter: def apply_transformations(self, value, transformations): intermediate_transforms = [ - t for t in transformations if not (t.startswith("strip") or t == "rgb") + t for t in transformations + if not (t.startswith("strip") or t == "rgb") ] final_transforms = [ - t for t in transformations if t.startswith("strip") or t == "rgb" + t for t in transformations + if t.startswith("strip") or t == "rgb" ] for transform in intermediate_transforms: if transform.startswith("lighten"): - percent = int(re.search(r"\d+", transform).group()) + percent = int(re.search(r'\d+', transform).group()) value = self.adjust_brightness(value, percent) elif transform.startswith("darken"): - percent = int(re.search(r"\d+", transform).group()) + percent = int(re.search(r'\d+', transform).group()) value = self.adjust_brightness(value, -percent) for transform in final_transforms: if transform.startswith("strip"): - value = value.lstrip("#") + value = value.lstrip('#') elif transform == "rgb": value = self.hex_to_rgb(value) @@ -172,22 +175,24 @@ class ColorFormatter: def min_max(v): return min(255, max(0, v)) - hex_color = hex_color.lstrip("#") - r, g, b = (int(hex_color[i : i + 2], 16) for i in (0, 2, 4)) + hex_color = hex_color.lstrip('#') + r, g, b = (int(hex_color[i:i+2], 16) for i in (0, 2, 4)) r = min_max(int(r * (1 + factor / 100))) g = min_max(int(g * (1 + factor / 100))) b = min_max(int(b * (1 + factor / 100))) - return f"#{r:02X}{g:02X}{b:02X}".lower() + return f'#{r:02X}{g:02X}{b:02X}'.lower() def hex_to_rgb(self, hex_color): - hex_color = hex_color.lstrip("#") - r, g, b = (int(hex_color[i : i + 2], 16) for i in (0, 2, 4)) - return f"{r},{g},{b}" + hex_color = hex_color.lstrip('#') + r, g, b = (int(hex_color[i:i+2], 16) for i in (0, 2, 4)) + return f'{r},{g},{b}' def parse_transformations(self, transformations_str): - transformations = re.findall(r"(\w+)(?:\((\d*)\))?", transformations_str) + transformations = re.findall( + r'(\w+)(?:\((\d*)\))?', transformations_str + ) result = [] for command, arg in transformations: if command: @@ -198,7 +203,7 @@ class ColorFormatter: return result def format(self, text): - pattern = r"(<(\w+)(?:\.(.+))?>)" + pattern = r'(<(\w+)(?:\.(.+))?>)' matches = re.findall(pattern, text) result = [] last_end = 0 @@ -206,30 +211,27 @@ class ColorFormatter: for match in matches: full_match, key, transformations_str = match if key in self.color_map: - result.append(text[last_end : text.find(full_match, last_end)]) + result.append(text[last_end:text.find(full_match, last_end)]) value = self.color_map[key] if transformations_str: - transformations = self.parse_transformations(transformations_str) + transformations = self.parse_transformations( + transformations_str + ) value = self.apply_transformations(value, transformations) result.append(value) last_end = text.find(full_match, last_end) + len(full_match) result.append(text[last_end:]) - result = "".join(result) - pattern = r"<\\\\([^>]+)>" + result = ''.join(result) + pattern = r'<\\\\([^>]+)>' - result = re.sub(pattern, r"<\1>", result) + result = re.sub(pattern, r'<\1>', result) return result -def generate_templates( - folder: str, - output_folder: str, - scheme: DynamicScheme, - color_scheme: str, - wallpaper: str = "", -): +def generate_templates(folder: str, output_folder: str, scheme: DynamicScheme, + color_scheme: str, wallpaper: str = ''): if not os.path.exists(output_folder): os.makedirs(output_folder) if not os.path.exists(folder): @@ -242,12 +244,13 @@ def generate_templates( formatter = ColorFormatter(scheme) template = formatter.format(template) template = ( - template.replace("", color_scheme) + template + .replace("", color_scheme) .replace("", output_folder) .replace("", wallpaper) ) new_path = join(output_folder, os.path.basename(file_path)) - with open(new_path, "w") as f: + with open(new_path, 'w') as f: f.write(template) for file in ready_templates: @@ -259,17 +262,21 @@ def generate_templates( hex_color = rgb_to_hex(rgba) rgb_color = rgba_to_rgb(rgba) new_line = ready_templates[file].format( - name=color, hex=hex_color, rgb=rgb_color + name=color, + hex=hex_color, + rgb=rgb_color ) _template += new_line if color in additional: new_line = ready_templates[file].format( - name=additional[color], hex=hex_color, rgb=rgb_color + name=additional[color], + hex=hex_color, + rgb=rgb_color ) _template += new_line new_path = join(output_folder, os.path.basename(file)) - with open(new_path, "w") as f: + with open(new_path, 'w') as f: f.write(_template) @@ -280,9 +287,9 @@ def run_hooks(folder: str): for file_path in file_list: file_name = os.path.basename(file_path) if str(file_name).endswith(".py"): - subprocess.run(["python", "-O", file_path]) + subprocess.run(['python', '-O', file_path]) elif str(file_name).endswith(".sh"): - subprocess.run(["sh", file_path]) + subprocess.run(['sh', file_path]) def process_image(image_path, quality=2, num_colors=128): @@ -290,18 +297,18 @@ def process_image(image_path, quality=2, num_colors=128): global cache_path _cache_path = join(cache_path, "cached_colors") hash_object = hashlib.md5(image_path.encode()) - cache_filename = hash_object.hexdigest() + ".pkl" + cache_filename = hash_object.hexdigest() + '.pkl' os.makedirs(_cache_path, exist_ok=True) return join(_cache_path, cache_filename) def load_from_cache(cache_path): if os.path.exists(cache_path): - with open(cache_path, "rb") as f: + with open(cache_path, 'rb') as f: return pickle.load(f) return None def save_to_cache(cache_path, data): - with open(cache_path, "wb") as f: + with open(cache_path, 'wb') as f: pickle.dump(data, f) cache_path = get_cache_path(image_path) @@ -310,7 +317,7 @@ def process_image(image_path, quality=2, num_colors=128): if cached_result is not None: return cached_result - image = Image.open(image_path).convert("RGB") + image = Image.open(image_path).convert('RGB') image_data = np.array(image) pixel_array = image_data[::quality, ::quality].reshape(-1, 3) @@ -325,11 +332,8 @@ def process_image(image_path, quality=2, num_colors=128): def main( - color_scheme: str, - image_path: str, - use_color: int | None = None, - scheme_name: str | None = None, - contrast_level: int = 0, + color_scheme: str, image_path: str, use_color: int | None = None, + scheme_name: str | None = None, contrast_level: int = 0 ): scheme_name = scheme_name or "tonalSpot" scheme = schemes[scheme_name] @@ -340,31 +344,34 @@ def main( else: color = use_color - scheme = scheme(Hct.from_int(color), is_dark, contrast_level) + scheme = scheme( + Hct.from_int(color), + is_dark, + contrast_level + ) # for color in vars(MaterialDynamicColors).keys(): # color_name = getattr(MaterialDynamicColors, color) # if hasattr(color_name, "get_hct"): # print(color, rgb_to_hex(color_name.get_hct(scheme).to_rgba())) - with open(join(cache_path, "colors.json"), "w") as f: - object = ColorsCache(scheme, image_path, color, contrast_level, scheme_name) + with open(join(cache_path, "colors.json"), 'w') as f: + object = ColorsCache( + scheme, image_path, color, contrast_level, scheme_name + ) json.dump(colors_dict(object), f, indent=2) generate_templates( f"{script_dir}/templates", cache_path, scheme, color_scheme, image_path ) generate_templates( - f"{script_dir}/templates/svg", - join(cache_path, "svg/"), - scheme, - color_scheme, - image_path, + f"{script_dir}/templates/svg", join(cache_path, "svg/"), scheme, + color_scheme, image_path ) if is_dark: - subprocess.run(["sh", join(script_dir, "gtk-material.sh")]) + subprocess.run(['sh', join(script_dir, 'gtk-material.sh')]) else: - subprocess.run(["sh", join(script_dir, "gtk-material.sh"), "--light"]) + subprocess.run(['sh', join(script_dir, 'gtk-material.sh'), '--light']) run_hooks(join(script_dir, "hooks")) @@ -372,27 +379,26 @@ def main( def _argparse() -> tuple[bool, bool, str, str, str, str]: parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group(required=True) - group.add_argument("-R", help="Restore previous colorscheme.", action="store_true") group.add_argument( - "-w", help="Use last used wallpaper for color generation.", action="store_true" + "-R", help="Restore previous colorscheme.", action='store_true' + ) + group.add_argument( + "-w", help="Use last used wallpaper for color generation.", + action='store_true' + ) + group.add_argument( + "--image", type=str, help="Image for color scheme generation" ) - group.add_argument("--image", type=str, help="Image for color scheme generation") group.add_argument( "--color", type=str, help="Main color for color scheme generation" ) parser.add_argument( - "--color-scheme", - type=str, - default="dark", - choices=["dark", "light"], - help="Color scheme variant", + '--color-scheme', type=str, default='dark', choices=['dark', 'light'], + help="Color scheme variant" ) parser.add_argument( - "--scheme", - type=str, - default="", - choices=list(schemes.keys()), - help="Scheme for color generation", + '--scheme', type=str, default="", + choices=list(schemes.keys()), help="Scheme for color generation" ) args = parser.parse_args() @@ -404,23 +410,15 @@ def _argparse() -> tuple[bool, bool, str, str, str, str]: use_color = args.color scheme = args.scheme return ( - restore_palette, - use_last_used_wallpaper, - image, - color_scheme, - use_color, - scheme, + restore_palette, use_last_used_wallpaper, image, + color_scheme, use_color, scheme ) def _main(): ( - restore_palette, - use_last_used_wallpaper, - image, - color_scheme, - use_color, - scheme, + restore_palette, use_last_used_wallpaper, image, + color_scheme, use_color, scheme ) = _argparse() if not scheme: scheme = None @@ -429,17 +427,13 @@ def _main(): with open(join(cache_path, "colors.json")) as f: content = get_cache_object(f.read()) main( - color_scheme, - image_path=content.wallpaper, - use_color=int(use_color.lstrip("#"), 16), - scheme_name=scheme, + color_scheme, image_path=content.wallpaper, + use_color=int(use_color.lstrip('#'), 16), scheme_name=scheme ) except Exception: main( - color_scheme, - image_path="/dev/null", - use_color=int(use_color.lstrip("#"), 16), - scheme_name=scheme, + color_scheme, image_path="/dev/null", + use_color=int(use_color.lstrip('#'), 16), scheme_name=scheme ) elif restore_palette: @@ -450,7 +444,7 @@ def _main(): image_path=content.wallpaper, use_color=content.original_color, scheme_name=scheme or content.scheme_name, - contrast_level=content.contrast_level, + contrast_level=content.contrast_level ) elif use_last_used_wallpaper: with open(join(cache_path, "colors.json")) as f: @@ -459,12 +453,13 @@ def _main(): color_scheme, image_path=content.wallpaper, scheme_name=scheme or content.scheme_name, - contrast_level=content.contrast_level, + contrast_level=content.contrast_level ) else: if os.path.isdir(image): files = [ - f for f in os.listdir(image) if f.endswith((".png", ".jpg", ".jpeg")) + f for f in os.listdir(image) + if f.endswith(('.png', '.jpg', '.jpeg')) ] if files: image = join(image, random.choice(files)) diff --git a/config/material-colors/templates/alacritty-dark.toml b/config/material-colors/templates/alacritty-dark.toml new file mode 100644 index 00000000..3f3c701b --- /dev/null +++ b/config/material-colors/templates/alacritty-dark.toml @@ -0,0 +1,72 @@ +[colors.primary] +background = '' +foreground = '' + + +[colors.cursor] +text = '#1E1E2E' +cursor = '#F5E0DC' + +[colors.vi_mode_cursor] +text = '#1E1E2E' +cursor = '#B4BEFE' + + +[colors.search.matches] +foreground = '#1E1E2E' +background = '#A6ADC8' + +[colors.search.focused_match] +foreground = '#1E1E2E' +background = '#A6E3A1' + +[colors.footer_bar] +foreground = '#1E1E2E' +background = '#A6ADC8' + + +[colors.hints.start] +foreground = '#1E1E2E' +background = '#F9E2AF' + +[colors.hints.end] +foreground = '#1E1E2E' +background = '#A6ADC8' + + +[colors.selection] +text = '#1E1E2E' +background = '#F5E0DC' + + +[colors.normal] +black = '#45475A' +red = '#F38BA8' +green = '#A6E3A1' +yellow = '#F9E2AF' +blue = '#89B4FA' +magenta = '#F5C2E7' +cyan = '#94E2D5' +white = '#BAC2DE' + + +[colors.bright] +black = '#585B70' +red = '#F38BA8' +green = '#A6E3A1' +yellow = '#F9E2AF' +blue = '#89B4FA' +magenta = '#F5C2E7' +cyan = '#94E2D5' +white = '#A6ADC8' + + +[colors.dim] +black = '#45475A' +red = '#F38BA8' +green = '#A6E3A1' +yellow = '#F9E2AF' +blue = '#89B4FA' +magenta = '#F5C2E7' +cyan = '#94E2D5' +white = '#BAC2DE' diff --git a/config/material-colors/templates/alacritty-light.toml b/config/material-colors/templates/alacritty-light.toml new file mode 100644 index 00000000..a86bdecd --- /dev/null +++ b/config/material-colors/templates/alacritty-light.toml @@ -0,0 +1,72 @@ +[colors.primary] +background = '' +foreground = '' + + +[colors.cursor] +text = '#EFF1F5' +cursor = '#DC8A78' + +[colors.vi_mode_cursor] +text = '#EFF1F5' +cursor = '#7287FD' + + +[colors.search.matches] +foreground = '#EFF1F5' +background = '#6C6F85' + +[colors.search.focused_match] +foreground = '#EFF1F5' +background = '#40A02B' + +[colors.footer_bar] +foreground = '#EFF1F5' +background = '#6C6F85' + + +[colors.hints.start] +foreground = '#EFF1F5' +background = '#DF8E1D' + +[colors.hints.end] +foreground = '#EFF1F5' +background = '#6C6F85' + + +[colors.selection] +text = '#EFF1F5' +background = '#DC8A78' + + +[colors.normal] +black = '#5C5F77' +red = '#D20F39' +green = '#40A02B' +yellow = '#DF8E1D' +blue = '#1E66F5' +magenta = '#EA76CB' +cyan = '#179299' +white = '#ACB0BE' + + +[colors.bright] +black = '#6C6F85' +red = '#D20F39' +green = '#40A02B' +yellow = '#DF8E1D' +blue = '#1E66F5' +magenta = '#EA76CB' +cyan = '#179299' +white = '#BCC0CC' + + +[colors.dim] +black = '#5C5F77' +red = '#D20F39' +green = '#40A02B' +yellow = '#DF8E1D' +blue = '#1E66F5' +magenta = '#EA76CB' +cyan = '#179299' +white = '#ACB0BE' diff --git a/config/material-colors/templates/alacritty.toml b/config/material-colors/templates/alacritty.toml new file mode 100644 index 00000000..f62d7013 --- /dev/null +++ b/config/material-colors/templates/alacritty.toml @@ -0,0 +1,10 @@ +[general] +import = [ + "/alacritty-.toml" +] +[font] +normal = { family = "MesloLGS NF", style = "Regular" } +bold = { family = "MesloLGS NF", style = "Bold" } +italic = { family = "MesloLGS NF", style = "Italic" } +bold_italic = { family = "MesloLGS NF", style = "Bold Italic" } +size = 12.0 diff --git a/config/material-colors/templates/material-discord.scss b/config/material-colors/templates/material-discord.scss index ca6cc513..607ee998 100644 --- a/config/material-colors/templates/material-discord.scss +++ b/config/material-colors/templates/material-discord.scss @@ -11,46 +11,45 @@ $saturation: round(color.channel($primary, "saturation", $space: hsl)); $lightness: round(color.channel($primary, "lightness", $space: hsl)); * { - transition: color 0.2s ease-in-out; - transition-property: background-color, color; + transition: color 0.2s ease-in-out; + transition-property: background-color, color; } .theme-#{$color-scheme} { - --main-color: #{$background}; - --main-alt: #{$surfaceContainerLow}; + --main-color: #{$background}; + --main-alt: #{$surfaceContainerLow}; - --message-color: #{$surfaceContainerLowest}; - --message-color-hover: #{$surfaceContainer}; - --message-color-alt: #{$surfaceContainer}; - --attachment-color: #{$background}; + --message-color: #{$surfaceContainerLowest}; + --message-color-hover: #{$surfaceContainer}; + --message-color-alt: #{$surfaceContainer}; + --attachment-color: #{$background}; - --accent-hue: #{$hue}; - --accent-saturation: #{$saturation}; - --accent-lightness: #{$lightness}; - --accent-text-color: #{$onPrimary}; + --accent-hue: #{$hue}; + --accent-saturation: #{$saturation}; + --accent-lightness: #{$lightness}; + --accent-text-color: #{$onPrimary}; - --main-textarea-color: #{$surfaceContainerHigh}; - --main-textarea-color-alt: #{$surfaceContainerHighest}; - --status-picker-color: #{$surfaceContainerHigh}; + --main-textarea-color: #{$surfaceContainerHigh}; + --main-textarea-color-alt: #{$surfaceContainerHighest}; + --status-picker-color: #{$surfaceContainerHigh}; - --tooltip-color: #{$surfaceContainer}; - --popout-color: #{$surfaceContainer}; - --popout-color-alt: #{$surfaceContainerLowest}; - --popout-header-border: #{$onSurface}; - --separator-color: #{$outlineVariant}; - --sidebar-panel-color: #{$surfaceContainerLowest}; - --server-color: #{$surfaceContainerLow}; + --tooltip-color: #{$surfaceContainer}; + --popout-color: #{$surfaceContainer}; + --popout-color-alt: #{$surfaceContainerLowest}; + --popout-header-border: #{$onSurface}; + --separator-color: #{$outlineVariant}; + --sidebar-panel-color: #{$surfaceContainerLowest}; + --server-color: #{$surfaceContainerLow}; } [class*="botTag_"] svg path { - fill: #{$onPrimary}; + fill: #{$onPrimary}; } [class*="repliedTextContent_"] { - padding: 0px 5px 0px 5px !important; + padding: 0px 5px 0px 5px !important; } [class*="userPopoutOuter_"] { - border-radius: 16px !important; + border-radius: 16px !important; } - -- 2.43.0 From 1ff584a9aa8912c9c5e6d09edf992b03a8cc1da6 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 08:03:49 +0545 Subject: [PATCH 04/38] updates --- config/hypr/UserConfigs/Startup_Apps.conf | 6 ++---- config/hypr/UserConfigs/UserKeybinds.conf | 11 +++++++++-- config/hypr/UserConfigs/WindowRules.conf | 2 -- config/{fabric => quickbar}/assets/config.json | 0 config/{fabric => quickbar}/assets/emoji.json | 0 .../{fabric => quickbar}/assets/scripts/cliphist.sh | 0 .../{fabric => quickbar}/assets/scripts/dark-theme.sh | 0 .../assets/scripts/wayland-idle-inhibitor.py | 0 config/{fabric => quickbar}/main.py | 0 config/{fabric => quickbar}/modules/bar/bar.py | 0 .../modules/bar/widgets/__init__.py | 0 .../modules/bar/widgets/battery.py | 0 .../modules/bar/widgets/bluetooth.py | 0 .../{fabric => quickbar}/modules/bar/widgets/idle.py | 0 .../{fabric => quickbar}/modules/bar/widgets/info.py | 0 .../modules/bar/widgets/microphone.py | 0 .../modules/bar/widgets/network.py | 0 .../modules/bar/widgets/powerprofile.py | 0 .../modules/bar/widgets/taskbar.py | 0 .../modules/bar/widgets/volume.py | 0 .../modules/bar/widgets/workspace.py | 0 .../{fabric => quickbar}/modules/launcher/launcher.py | 0 .../modules/launcher/widgets/__init__.py | 0 .../modules/launcher/widgets/applauncher.py | 0 .../modules/launcher/widgets/bluetooth.py | 0 .../modules/launcher/widgets/cliphist.py | 0 .../modules/launcher/widgets/dashboard.py | 0 .../modules/launcher/widgets/emoji.py | 0 .../modules/launcher/widgets/power.py | 0 .../modules/launcher/widgets/shell.py | 0 .../modules/launcher/widgets/todo.py | 0 .../modules/launcher/widgets/wallpapers.py | 0 .../modules/launcher/widgets/wifi.py | 0 .../modules/notification_popup.py | 0 config/{fabric => quickbar}/modules/osd.py | 0 config/{fabric => quickbar}/ruff.toml | 0 config/{fabric => quickbar}/services/__init__.py | 0 config/{fabric => quickbar}/services/brightness.py | 0 config/{fabric => quickbar}/services/screen_record.py | 0 config/{fabric => quickbar}/services/wifi.py | 0 config/{fabric => quickbar}/snippets/__init__.py | 0 config/{fabric => quickbar}/snippets/animator.py | 0 config/{fabric => quickbar}/snippets/custom_image.py | 0 config/{fabric => quickbar}/snippets/functions.py | 0 config/{fabric => quickbar}/snippets/icon.py | 0 config/{fabric => quickbar}/snippets/icon_resolver.py | 0 config/{fabric => quickbar}/styles/bar.css | 0 config/{fabric => quickbar}/styles/launcher.css | 0 .../styles/launcher/applauncher.css | 0 .../styles/launcher/bluetooth.css | 0 .../{fabric => quickbar}/styles/launcher/cliphist.css | 0 .../styles/launcher/dashboard.css | 0 config/{fabric => quickbar}/styles/launcher/emoji.css | 0 .../styles/launcher/powermenu.css | 0 config/{fabric => quickbar}/styles/launcher/todo.css | 0 .../styles/launcher/wallpapers.css | 0 config/{fabric => quickbar}/styles/launcher/wifi.css | 0 config/{fabric => quickbar}/styles/main.css | 2 +- config/{fabric => quickbar}/styles/notification.css | 0 config/{fabric => quickbar}/styles/osd.css | 0 60 files changed, 12 insertions(+), 9 deletions(-) rename config/{fabric => quickbar}/assets/config.json (100%) rename config/{fabric => quickbar}/assets/emoji.json (100%) rename config/{fabric => quickbar}/assets/scripts/cliphist.sh (100%) rename config/{fabric => quickbar}/assets/scripts/dark-theme.sh (100%) rename config/{fabric => quickbar}/assets/scripts/wayland-idle-inhibitor.py (100%) rename config/{fabric => quickbar}/main.py (100%) rename config/{fabric => quickbar}/modules/bar/bar.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/__init__.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/battery.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/bluetooth.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/idle.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/info.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/microphone.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/network.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/powerprofile.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/taskbar.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/volume.py (100%) rename config/{fabric => quickbar}/modules/bar/widgets/workspace.py (100%) rename config/{fabric => quickbar}/modules/launcher/launcher.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/__init__.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/applauncher.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/bluetooth.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/cliphist.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/dashboard.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/emoji.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/power.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/shell.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/todo.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/wallpapers.py (100%) rename config/{fabric => quickbar}/modules/launcher/widgets/wifi.py (100%) rename config/{fabric => quickbar}/modules/notification_popup.py (100%) rename config/{fabric => quickbar}/modules/osd.py (100%) rename config/{fabric => quickbar}/ruff.toml (100%) rename config/{fabric => quickbar}/services/__init__.py (100%) rename config/{fabric => quickbar}/services/brightness.py (100%) rename config/{fabric => quickbar}/services/screen_record.py (100%) rename config/{fabric => quickbar}/services/wifi.py (100%) rename config/{fabric => quickbar}/snippets/__init__.py (100%) rename config/{fabric => quickbar}/snippets/animator.py (100%) rename config/{fabric => quickbar}/snippets/custom_image.py (100%) rename config/{fabric => quickbar}/snippets/functions.py (100%) rename config/{fabric => quickbar}/snippets/icon.py (100%) rename config/{fabric => quickbar}/snippets/icon_resolver.py (100%) rename config/{fabric => quickbar}/styles/bar.css (100%) rename config/{fabric => quickbar}/styles/launcher.css (100%) rename config/{fabric => quickbar}/styles/launcher/applauncher.css (100%) rename config/{fabric => quickbar}/styles/launcher/bluetooth.css (100%) rename config/{fabric => quickbar}/styles/launcher/cliphist.css (100%) rename config/{fabric => quickbar}/styles/launcher/dashboard.css (100%) rename config/{fabric => quickbar}/styles/launcher/emoji.css (100%) rename config/{fabric => quickbar}/styles/launcher/powermenu.css (100%) rename config/{fabric => quickbar}/styles/launcher/todo.css (100%) rename config/{fabric => quickbar}/styles/launcher/wallpapers.css (100%) rename config/{fabric => quickbar}/styles/launcher/wifi.css (100%) rename config/{fabric => quickbar}/styles/main.css (96%) rename config/{fabric => quickbar}/styles/notification.css (100%) rename config/{fabric => quickbar}/styles/osd.css (100%) diff --git a/config/hypr/UserConfigs/Startup_Apps.conf b/config/hypr/UserConfigs/Startup_Apps.conf index 0ecd3d48..3c4ece84 100644 --- a/config/hypr/UserConfigs/Startup_Apps.conf +++ b/config/hypr/UserConfigs/Startup_Apps.conf @@ -13,10 +13,8 @@ exec-once = systemctl --user import-environment QT_QPA_PLATFORMTHEME exec-once = $scriptsDir/Polkit.sh # startup apps -#exec-once = waybar & -# exec-once = ~/fabric/start & -# exec-once = ags & -exec-once = cd ~/fabric && python main.py + +exec-once = cd ~/dotfiles/quickbar && 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 980c3c20..fd6a4abe 100644 --- a/config/hypr/UserConfigs/UserKeybinds.conf +++ b/config/hypr/UserConfigs/UserKeybinds.conf @@ -28,7 +28,7 @@ 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 ~/fabric/main.py & +bind = ALT, t, exec, killall quickbar || sleep 0.5 && python ~/quickbar/main.py & bind = $mainMod, R, exec, $fabric 'sc.screencast_start(True)' bind = $mainMod_SHIFT, R, exec, $fabric 'sc.screencast_stop()' @@ -38,6 +38,13 @@ bind=,Print, exec, $fabric 'sc.screenshot(True)' bind = Super, y, exec, XDG_CURRENT_DESKTOP="gnome" gnome-control-center -bind = $mainMod, D, exec, $fabric 'launcher.toggle()' +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 diff --git a/config/hypr/UserConfigs/WindowRules.conf b/config/hypr/UserConfigs/WindowRules.conf index 95a31db5..a893df14 100644 --- a/config/hypr/UserConfigs/WindowRules.conf +++ b/config/hypr/UserConfigs/WindowRules.conf @@ -8,8 +8,6 @@ windowrulev2 = noinitialfocus,class:^(xwaylandvideobridge)$ windowrulev2 = maxsize 1 1,class:^(xwaylandvideobridge)$ windowrulev2 = noblur,class:^(xwaylandvideobridge)$ -# Workspace Rules -#windowrule = stayfocused, ^(com.github.Aylur.ags)$ # MPV/VLC windowrule = workspace 5, ^(.*vlc.*)$|(.*mpv.*)$ diff --git a/config/fabric/assets/config.json b/config/quickbar/assets/config.json similarity index 100% rename from config/fabric/assets/config.json rename to config/quickbar/assets/config.json diff --git a/config/fabric/assets/emoji.json b/config/quickbar/assets/emoji.json similarity index 100% rename from config/fabric/assets/emoji.json rename to config/quickbar/assets/emoji.json diff --git a/config/fabric/assets/scripts/cliphist.sh b/config/quickbar/assets/scripts/cliphist.sh similarity index 100% rename from config/fabric/assets/scripts/cliphist.sh rename to config/quickbar/assets/scripts/cliphist.sh diff --git a/config/fabric/assets/scripts/dark-theme.sh b/config/quickbar/assets/scripts/dark-theme.sh similarity index 100% rename from config/fabric/assets/scripts/dark-theme.sh rename to config/quickbar/assets/scripts/dark-theme.sh diff --git a/config/fabric/assets/scripts/wayland-idle-inhibitor.py b/config/quickbar/assets/scripts/wayland-idle-inhibitor.py similarity index 100% rename from config/fabric/assets/scripts/wayland-idle-inhibitor.py rename to config/quickbar/assets/scripts/wayland-idle-inhibitor.py diff --git a/config/fabric/main.py b/config/quickbar/main.py similarity index 100% rename from config/fabric/main.py rename to config/quickbar/main.py diff --git a/config/fabric/modules/bar/bar.py b/config/quickbar/modules/bar/bar.py similarity index 100% rename from config/fabric/modules/bar/bar.py rename to config/quickbar/modules/bar/bar.py diff --git a/config/fabric/modules/bar/widgets/__init__.py b/config/quickbar/modules/bar/widgets/__init__.py similarity index 100% rename from config/fabric/modules/bar/widgets/__init__.py rename to config/quickbar/modules/bar/widgets/__init__.py diff --git a/config/fabric/modules/bar/widgets/battery.py b/config/quickbar/modules/bar/widgets/battery.py similarity index 100% rename from config/fabric/modules/bar/widgets/battery.py rename to config/quickbar/modules/bar/widgets/battery.py diff --git a/config/fabric/modules/bar/widgets/bluetooth.py b/config/quickbar/modules/bar/widgets/bluetooth.py similarity index 100% rename from config/fabric/modules/bar/widgets/bluetooth.py rename to config/quickbar/modules/bar/widgets/bluetooth.py diff --git a/config/fabric/modules/bar/widgets/idle.py b/config/quickbar/modules/bar/widgets/idle.py similarity index 100% rename from config/fabric/modules/bar/widgets/idle.py rename to config/quickbar/modules/bar/widgets/idle.py diff --git a/config/fabric/modules/bar/widgets/info.py b/config/quickbar/modules/bar/widgets/info.py similarity index 100% rename from config/fabric/modules/bar/widgets/info.py rename to config/quickbar/modules/bar/widgets/info.py diff --git a/config/fabric/modules/bar/widgets/microphone.py b/config/quickbar/modules/bar/widgets/microphone.py similarity index 100% rename from config/fabric/modules/bar/widgets/microphone.py rename to config/quickbar/modules/bar/widgets/microphone.py diff --git a/config/fabric/modules/bar/widgets/network.py b/config/quickbar/modules/bar/widgets/network.py similarity index 100% rename from config/fabric/modules/bar/widgets/network.py rename to config/quickbar/modules/bar/widgets/network.py diff --git a/config/fabric/modules/bar/widgets/powerprofile.py b/config/quickbar/modules/bar/widgets/powerprofile.py similarity index 100% rename from config/fabric/modules/bar/widgets/powerprofile.py rename to config/quickbar/modules/bar/widgets/powerprofile.py diff --git a/config/fabric/modules/bar/widgets/taskbar.py b/config/quickbar/modules/bar/widgets/taskbar.py similarity index 100% rename from config/fabric/modules/bar/widgets/taskbar.py rename to config/quickbar/modules/bar/widgets/taskbar.py diff --git a/config/fabric/modules/bar/widgets/volume.py b/config/quickbar/modules/bar/widgets/volume.py similarity index 100% rename from config/fabric/modules/bar/widgets/volume.py rename to config/quickbar/modules/bar/widgets/volume.py diff --git a/config/fabric/modules/bar/widgets/workspace.py b/config/quickbar/modules/bar/widgets/workspace.py similarity index 100% rename from config/fabric/modules/bar/widgets/workspace.py rename to config/quickbar/modules/bar/widgets/workspace.py diff --git a/config/fabric/modules/launcher/launcher.py b/config/quickbar/modules/launcher/launcher.py similarity index 100% rename from config/fabric/modules/launcher/launcher.py rename to config/quickbar/modules/launcher/launcher.py diff --git a/config/fabric/modules/launcher/widgets/__init__.py b/config/quickbar/modules/launcher/widgets/__init__.py similarity index 100% rename from config/fabric/modules/launcher/widgets/__init__.py rename to config/quickbar/modules/launcher/widgets/__init__.py diff --git a/config/fabric/modules/launcher/widgets/applauncher.py b/config/quickbar/modules/launcher/widgets/applauncher.py similarity index 100% rename from config/fabric/modules/launcher/widgets/applauncher.py rename to config/quickbar/modules/launcher/widgets/applauncher.py diff --git a/config/fabric/modules/launcher/widgets/bluetooth.py b/config/quickbar/modules/launcher/widgets/bluetooth.py similarity index 100% rename from config/fabric/modules/launcher/widgets/bluetooth.py rename to config/quickbar/modules/launcher/widgets/bluetooth.py diff --git a/config/fabric/modules/launcher/widgets/cliphist.py b/config/quickbar/modules/launcher/widgets/cliphist.py similarity index 100% rename from config/fabric/modules/launcher/widgets/cliphist.py rename to config/quickbar/modules/launcher/widgets/cliphist.py diff --git a/config/fabric/modules/launcher/widgets/dashboard.py b/config/quickbar/modules/launcher/widgets/dashboard.py similarity index 100% rename from config/fabric/modules/launcher/widgets/dashboard.py rename to config/quickbar/modules/launcher/widgets/dashboard.py diff --git a/config/fabric/modules/launcher/widgets/emoji.py b/config/quickbar/modules/launcher/widgets/emoji.py similarity index 100% rename from config/fabric/modules/launcher/widgets/emoji.py rename to config/quickbar/modules/launcher/widgets/emoji.py diff --git a/config/fabric/modules/launcher/widgets/power.py b/config/quickbar/modules/launcher/widgets/power.py similarity index 100% rename from config/fabric/modules/launcher/widgets/power.py rename to config/quickbar/modules/launcher/widgets/power.py diff --git a/config/fabric/modules/launcher/widgets/shell.py b/config/quickbar/modules/launcher/widgets/shell.py similarity index 100% rename from config/fabric/modules/launcher/widgets/shell.py rename to config/quickbar/modules/launcher/widgets/shell.py diff --git a/config/fabric/modules/launcher/widgets/todo.py b/config/quickbar/modules/launcher/widgets/todo.py similarity index 100% rename from config/fabric/modules/launcher/widgets/todo.py rename to config/quickbar/modules/launcher/widgets/todo.py diff --git a/config/fabric/modules/launcher/widgets/wallpapers.py b/config/quickbar/modules/launcher/widgets/wallpapers.py similarity index 100% rename from config/fabric/modules/launcher/widgets/wallpapers.py rename to config/quickbar/modules/launcher/widgets/wallpapers.py diff --git a/config/fabric/modules/launcher/widgets/wifi.py b/config/quickbar/modules/launcher/widgets/wifi.py similarity index 100% rename from config/fabric/modules/launcher/widgets/wifi.py rename to config/quickbar/modules/launcher/widgets/wifi.py diff --git a/config/fabric/modules/notification_popup.py b/config/quickbar/modules/notification_popup.py similarity index 100% rename from config/fabric/modules/notification_popup.py rename to config/quickbar/modules/notification_popup.py diff --git a/config/fabric/modules/osd.py b/config/quickbar/modules/osd.py similarity index 100% rename from config/fabric/modules/osd.py rename to config/quickbar/modules/osd.py diff --git a/config/fabric/ruff.toml b/config/quickbar/ruff.toml similarity index 100% rename from config/fabric/ruff.toml rename to config/quickbar/ruff.toml diff --git a/config/fabric/services/__init__.py b/config/quickbar/services/__init__.py similarity index 100% rename from config/fabric/services/__init__.py rename to config/quickbar/services/__init__.py diff --git a/config/fabric/services/brightness.py b/config/quickbar/services/brightness.py similarity index 100% rename from config/fabric/services/brightness.py rename to config/quickbar/services/brightness.py diff --git a/config/fabric/services/screen_record.py b/config/quickbar/services/screen_record.py similarity index 100% rename from config/fabric/services/screen_record.py rename to config/quickbar/services/screen_record.py diff --git a/config/fabric/services/wifi.py b/config/quickbar/services/wifi.py similarity index 100% rename from config/fabric/services/wifi.py rename to config/quickbar/services/wifi.py diff --git a/config/fabric/snippets/__init__.py b/config/quickbar/snippets/__init__.py similarity index 100% rename from config/fabric/snippets/__init__.py rename to config/quickbar/snippets/__init__.py diff --git a/config/fabric/snippets/animator.py b/config/quickbar/snippets/animator.py similarity index 100% rename from config/fabric/snippets/animator.py rename to config/quickbar/snippets/animator.py diff --git a/config/fabric/snippets/custom_image.py b/config/quickbar/snippets/custom_image.py similarity index 100% rename from config/fabric/snippets/custom_image.py rename to config/quickbar/snippets/custom_image.py diff --git a/config/fabric/snippets/functions.py b/config/quickbar/snippets/functions.py similarity index 100% rename from config/fabric/snippets/functions.py rename to config/quickbar/snippets/functions.py diff --git a/config/fabric/snippets/icon.py b/config/quickbar/snippets/icon.py similarity index 100% rename from config/fabric/snippets/icon.py rename to config/quickbar/snippets/icon.py diff --git a/config/fabric/snippets/icon_resolver.py b/config/quickbar/snippets/icon_resolver.py similarity index 100% rename from config/fabric/snippets/icon_resolver.py rename to config/quickbar/snippets/icon_resolver.py diff --git a/config/fabric/styles/bar.css b/config/quickbar/styles/bar.css similarity index 100% rename from config/fabric/styles/bar.css rename to config/quickbar/styles/bar.css diff --git a/config/fabric/styles/launcher.css b/config/quickbar/styles/launcher.css similarity index 100% rename from config/fabric/styles/launcher.css rename to config/quickbar/styles/launcher.css diff --git a/config/fabric/styles/launcher/applauncher.css b/config/quickbar/styles/launcher/applauncher.css similarity index 100% rename from config/fabric/styles/launcher/applauncher.css rename to config/quickbar/styles/launcher/applauncher.css diff --git a/config/fabric/styles/launcher/bluetooth.css b/config/quickbar/styles/launcher/bluetooth.css similarity index 100% rename from config/fabric/styles/launcher/bluetooth.css rename to config/quickbar/styles/launcher/bluetooth.css diff --git a/config/fabric/styles/launcher/cliphist.css b/config/quickbar/styles/launcher/cliphist.css similarity index 100% rename from config/fabric/styles/launcher/cliphist.css rename to config/quickbar/styles/launcher/cliphist.css diff --git a/config/fabric/styles/launcher/dashboard.css b/config/quickbar/styles/launcher/dashboard.css similarity index 100% rename from config/fabric/styles/launcher/dashboard.css rename to config/quickbar/styles/launcher/dashboard.css diff --git a/config/fabric/styles/launcher/emoji.css b/config/quickbar/styles/launcher/emoji.css similarity index 100% rename from config/fabric/styles/launcher/emoji.css rename to config/quickbar/styles/launcher/emoji.css diff --git a/config/fabric/styles/launcher/powermenu.css b/config/quickbar/styles/launcher/powermenu.css similarity index 100% rename from config/fabric/styles/launcher/powermenu.css rename to config/quickbar/styles/launcher/powermenu.css diff --git a/config/fabric/styles/launcher/todo.css b/config/quickbar/styles/launcher/todo.css similarity index 100% rename from config/fabric/styles/launcher/todo.css rename to config/quickbar/styles/launcher/todo.css diff --git a/config/fabric/styles/launcher/wallpapers.css b/config/quickbar/styles/launcher/wallpapers.css similarity index 100% rename from config/fabric/styles/launcher/wallpapers.css rename to config/quickbar/styles/launcher/wallpapers.css diff --git a/config/fabric/styles/launcher/wifi.css b/config/quickbar/styles/launcher/wifi.css similarity index 100% rename from config/fabric/styles/launcher/wifi.css rename to config/quickbar/styles/launcher/wifi.css diff --git a/config/fabric/styles/main.css b/config/quickbar/styles/main.css similarity index 96% rename from config/fabric/styles/main.css rename to config/quickbar/styles/main.css index acb1b38e..6f869569 100644 --- a/config/fabric/styles/main.css +++ b/config/quickbar/styles/main.css @@ -1,4 +1,4 @@ -@import url(../../.cache/material/colors.css); +@import url(../../../.cache/material/colors.css); @import "./bar.css"; @import "./notification.css"; @import "./osd.css"; diff --git a/config/fabric/styles/notification.css b/config/quickbar/styles/notification.css similarity index 100% rename from config/fabric/styles/notification.css rename to config/quickbar/styles/notification.css diff --git a/config/fabric/styles/osd.css b/config/quickbar/styles/osd.css similarity index 100% rename from config/fabric/styles/osd.css rename to config/quickbar/styles/osd.css -- 2.43.0 From a302814a60ea612340f6aab4e7d0170bb42877ff Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 08:32:05 +0545 Subject: [PATCH 05/38] update READEME --- README.md | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f0d640f0..2e2acd5d 100644 --- a/README.md +++ b/README.md @@ -22,18 +22,30 @@ > [!NOTE] > This repository is in the alpha stage and primarily for personal use. The organization and configurations may change significantly in the future. -### Features - -**TODO** - -### Showcase: - -### Installation +#### Build with **[Fabric](https://github.com/Fabric-Development/fabric)** -**TODO** +## Packages -### Acknowledgements +```sh +python-setproctitle, python-fabric-git, grimblast, wf-recoder, brightnessctl, gnome-bluetooth-3.0 cliphist, python-psutil python-loguru, adw-gtk-theme, power-profile-daemon, python-materialyoucolor-git, python-pywayland, python-pyxdg, python-pillow, python-numpy, python-requests, +``` -**TODO** +**font** + +```sh +ttf-font-awesome, otf-font-awesome, ttf-material-symbols-variable-git, ttf-google-sans, ttf-opensans, ttf-robot +``` + +# ToDo + +- [ ] Add wifi, bluetooth, shrunner widget +- [ ] Dashboard +- [ ] Notification panel +- [ ] Better css +- [ ] Documentation +- [ ] Window Switcher +- [ ] maybe calendar with events +- [ ] Audio and Brightness Controller +- [ ] New Screenshot -- 2.43.0 From afdfa620b360e5d0c8d56320ef833029c3d673ac Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 08:42:25 +0545 Subject: [PATCH 06/38] package added --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e2acd5d..d7f2777a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ ## Packages ```sh -python-setproctitle, python-fabric-git, grimblast, wf-recoder, brightnessctl, gnome-bluetooth-3.0 cliphist, python-psutil python-loguru, adw-gtk-theme, power-profile-daemon, python-materialyoucolor-git, python-pywayland, python-pyxdg, python-pillow, python-numpy, python-requests, +python-setproctitle, python-fabric-git, fabric-cli-git, grimblast, wf-recoder, brightnessctl, gnome-bluetooth-3.0 cliphist, python-psutil python-loguru, adw-gtk-theme, power-profile-daemon, python-materialyoucolor-git, python-pywayland, python-pyxdg, python-pillow, python-numpy, python-requests, ``` **font** -- 2.43.0 From b6f4fced034e1dd5ff5c66fdeacf53513ce9fc8a Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 08:59:35 +0545 Subject: [PATCH 07/38] fix --- config/hypr/UserConfigs/UserKeybinds.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/hypr/UserConfigs/UserKeybinds.conf b/config/hypr/UserConfigs/UserKeybinds.conf index fd6a4abe..1dab5707 100644 --- a/config/hypr/UserConfigs/UserKeybinds.conf +++ b/config/hypr/UserConfigs/UserKeybinds.conf @@ -28,7 +28,7 @@ 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 ~/quickbar/main.py & +bind = ALT, t, exec, killall quickbar || sleep 0.5 && python ~/dotfiles/quickbar/main.py & bind = $mainMod, R, exec, $fabric 'sc.screencast_start(True)' bind = $mainMod_SHIFT, R, exec, $fabric 'sc.screencast_stop()' -- 2.43.0 From a1b23b8a42025fc28fa34b86fb991d226156ab8e Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 11:07:13 +0545 Subject: [PATCH 08/38] fix --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d7f2777a..98a716b4 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,6 @@ ttf-font-awesome, otf-font-awesome, ttf-material-symbols-variable-git, ttf-googl - [ ] Notification panel - [ ] Better css - [ ] Documentation -- [ ] Window Switcher - [ ] maybe calendar with events - [ ] Audio and Brightness Controller - [ ] New Screenshot -- 2.43.0 From bc3a1fe2ccc0a1bad91da9f8176978f50f9bf7d0 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 21:26:07 +0545 Subject: [PATCH 09/38] added bluetooth widget --- .../modules/launcher/widgets/bluetooth.py | 244 ++++++++++++++++++ 1 file changed, 244 insertions(+) diff --git a/config/quickbar/modules/launcher/widgets/bluetooth.py b/config/quickbar/modules/launcher/widgets/bluetooth.py index e69de29b..afa5d369 100644 --- a/config/quickbar/modules/launcher/widgets/bluetooth.py +++ b/config/quickbar/modules/launcher/widgets/bluetooth.py @@ -0,0 +1,244 @@ +from fabric.bluetooth import BluetoothClient, BluetoothDevice +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.label import Label +from fabric.widgets.scrolledwindow import ScrolledWindow +from gi.repository import Gdk, GLib +from snippets import MaterialIcon + + +class BluetoothManager(Box): + def __init__(self, **kwargs): + super().__init__( + name="bluetooth-launcher", + all_visible=False, + visible=False, + **kwargs, + ) + + self._arranger_handler: int = 0 + self.device_manager = DeviceManager(self) + self.viewport = None + + self.search_entry = Entry( + name="search-entry", + placeholder="Search Devices...", + 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="power-button", + child=MaterialIcon("bluetooth"), + tooltip_text="Toggle Bluetooth", + on_clicked=lambda *_: self.device_manager.toggle_bluetooth(), + ), + Button( + name="scan-button", + child=MaterialIcon("search"), + tooltip_text="Scan for Devices", + on_clicked=lambda *_: self.device_manager.toggle_scan(), + ), + Button( + name="close-button", + child=MaterialIcon("close"), + tooltip_text="Exit", + on_clicked=lambda *_: self.close_launcher(), + ), + ], + ) + + self.launcher_box = Box( + name="bluetooth-launcher-box", + spacing=10, + orientation="v", + h_expand=True, + children=[self.header_box], + ) + + self.add(self.launcher_box) + + self.is_active = False # Track whether the Bluetooth section is active + self.polling_handler = None # Track the polling handler + + self.connect("key-press-event", self.on_key_press) + + def on_key_press(self, widget, event): + """Handle Escape key press to close the launcher""" + if event.keyval == Gdk.KEY_Escape: + self.close_launcher() + return True # Stop further processing of the event + return False # Allow normal event processing + + def open_launcher(self): + if not self.is_active: + self.is_active = True + if not self.viewport: + self.viewport = Box(name="viewport", spacing=4, orientation="v") + self.scrolled_window = ScrolledWindow( + name="scrolled-window", + spacing=10, + h_scrollbar_policy="never", + v_scrollbar_policy="never", + child=self.viewport, + ) + self.launcher_box.add(self.scrolled_window) + + self.viewport.children = [] + self.device_manager.arrange_viewport() + + self.viewport.show() + self.search_entry.grab_focus() + + # Start refreshing devices when Bluetooth section is open + self.start_device_polling() + + def close_launcher(self): + self.is_active = False # Mark as not active + if self.viewport: + self.viewport.hide() + self.viewport = None # Reset the viewport reference + + # Stop the polling when Bluetooth section is closed + self.stop_device_polling() + + GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") + + def handle_search_input(self, text: str): + if text.lower() == ":bt": # Only handle Bluetooth search when ":bt" is input + self.open_launcher() + else: + self.device_manager.arrange_viewport(text) + + def start_device_polling(self): + if not self.polling_handler and self.is_active: + print("Starting polling...") + self.polling_handler = GLib.timeout_add( + 5000, self.device_manager.refresh_devices + ) + + def stop_device_polling(self): + if self.polling_handler: + print("Stopping polling...") + GLib.source_remove(self.polling_handler) + self.polling_handler = None + + +class DeviceManager: + def __init__(self, launcher): + self.launcher = launcher + self.bluetooth_client = BluetoothClient( + on_device_added=self.on_device_added, + on_device_removed=self.on_device_removed, + ) + self._cached_devices = [] + + 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): + 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) + self.refresh_viewport() + + def on_device_removed(self, client: BluetoothClient, address: str): + self._cached_devices = [ + device for device in self._cached_devices if device.address != address + ] + self.refresh_viewport() + + def refresh_viewport(self): + GLib.idle_add(self.arrange_viewport) + + def query_devices(self, query: str = "") -> list: + devices = [] + query = query.lower() + + for device in self._cached_devices: + name = device.name or "Unknown Device" + if query in name.lower(): + devices.append(device) + + return sorted( + devices, key=lambda d: (not d.paired, d.name or "Unknown Device") + )[:48] + + def connect_device(self, device: BluetoothDevice): + device.set_connecting(not device.connected) + + def bake_device_slot(self, device: BluetoothDevice, **kwargs) -> Box: + status_icon = MaterialIcon("link" if device.connected else "link_off") + + 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, + ) + + def arrange_viewport(self, query: str = ""): + if not self.launcher.viewport: + return + + ( + remove_handler(self.launcher._arranger_handler) + if self.launcher._arranger_handler + else None + ) + self.launcher.viewport.children = [] + + filtered_devices = self.query_devices(query) + + 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)) + + if paired_devices := [d for d in filtered_devices if d.paired]: + for device in paired_devices: + self.launcher.viewport.add(self.bake_device_slot(device)) + + if not filtered_devices: + self.launcher.viewport.add( + Label( + label="No devices found" if not query else "No matching devices", + name="empty-label", + h_align="center", + ) + ) -- 2.43.0 From b2d22f212f8a152039bdfc490cd54a16b9f587ba Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 21:26:23 +0545 Subject: [PATCH 10/38] added bluetooth widget --- config/quickbar/modules/launcher/widgets/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/config/quickbar/modules/launcher/widgets/__init__.py b/config/quickbar/modules/launcher/widgets/__init__.py index 39ae1b09..38276c1b 100644 --- a/config/quickbar/modules/launcher/widgets/__init__.py +++ b/config/quickbar/modules/launcher/widgets/__init__.py @@ -1,4 +1,5 @@ from .applauncher import * +from .bluetooth import * from .cliphist import * from .dashboard import * from .emoji import * -- 2.43.0 From 07a31cd0a01cc2d6c77f022f3b7c90baeb96fde1 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 21:28:51 +0545 Subject: [PATCH 11/38] added bluetooth widget --- README.md | 4 +++- config/quickbar/modules/launcher/launcher.py | 17 +++++++++++++++++ config/quickbar/styles/launcher/bluetooth.css | 10 ++++++++++ config/quickbar/styles/main.css | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 98a716b4..185b158d 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,9 @@ ttf-font-awesome, otf-font-awesome, ttf-material-symbols-variable-git, ttf-googl # ToDo -- [ ] Add wifi, bluetooth, shrunner widget +- [x] Add bluetooth widget +- [ ] Add shrunner widget +- [ ] Add wifi widget - [ ] Dashboard - [ ] Notification panel - [ ] Better css diff --git a/config/quickbar/modules/launcher/launcher.py b/config/quickbar/modules/launcher/launcher.py index 72ddd180..e1bc7739 100644 --- a/config/quickbar/modules/launcher/launcher.py +++ b/config/quickbar/modules/launcher/launcher.py @@ -6,6 +6,7 @@ from fabric.widgets.wayland import WaylandWindow as Window from gi.repository import Gdk, GLib from modules.launcher.widgets import ( AppLauncher, + BluetoothManager, Cliphist, Emoji, PowerMenu, @@ -29,11 +30,13 @@ class Launcher(Window): self.emoji = Emoji() self.cliphist = Cliphist() self.todo = TodoManager() + self.bluetooth = BluetoothManager() # Initialize viewports as None self._emoji_viewport = None self._cliphist_viewport = None self._todo_viewport = None + self._bluetooth_viewport = None self.stack = Stack( name="launcher-content", @@ -48,6 +51,7 @@ class Launcher(Window): self.emoji, self.cliphist, self.todo, + self.bluetooth, ], ) @@ -89,6 +93,8 @@ class Launcher(Window): def close(self): self.set_keyboard_mode("none") self.hide() + if self.bluetooth.is_active: + self.bluetooth.stop_device_polling() for widget in [ self.launcher, @@ -97,6 +103,7 @@ class Launcher(Window): self.emoji, self.cliphist, self.todo, + self.bluetooth, ]: widget.remove_style_class("open") @@ -120,6 +127,9 @@ class Launcher(Window): if widget == self.todo and hasattr(widget, "viewport") and widget.viewport: widget.viewport.hide() + if widget == self.bluetooth and widget.viewport: + widget.viewport.children = [] + style_classes = [ "launcher", "wallpapers", @@ -127,6 +137,7 @@ class Launcher(Window): "emoji", "cliphist", "todo", + "bluetooth", ] for style_class in style_classes: if self.stack.get_style_context().has_class(style_class): @@ -145,6 +156,7 @@ class Launcher(Window): "emoji": self.emoji, "cliphist": self.cliphist, "todo": self.todo, + "bluetooth": self.bluetooth, } style_classes = list(widgets.keys()) @@ -193,6 +205,11 @@ class Launcher(Window): self.todo.todo_entry.set_text("") self.todo.todo_entry.grab_focus() + elif widget == "bluetooth": + self.bluetooth.open_launcher() + self.bluetooth.search_entry.set_text("") + self.bluetooth.search_entry.grab_focus() + else: if hasattr(self.wallpapers, "viewport"): self.wallpapers.viewport.hide() diff --git a/config/quickbar/styles/launcher/bluetooth.css b/config/quickbar/styles/launcher/bluetooth.css index e69de29b..032e880b 100644 --- a/config/quickbar/styles/launcher/bluetooth.css +++ b/config/quickbar/styles/launcher/bluetooth.css @@ -0,0 +1,10 @@ +#device-slot { + background-color: @suraceVariant; + border-radius: 5px; + padding: 8px; +} + +#device-slot:hover, +#device-slot:focus { + background-color: mix(@onSurface, @surface, 0.92); +} diff --git a/config/quickbar/styles/main.css b/config/quickbar/styles/main.css index 6f869569..d41d8a2c 100644 --- a/config/quickbar/styles/main.css +++ b/config/quickbar/styles/main.css @@ -9,6 +9,7 @@ @import "./launcher/todo.css"; @import "./launcher/emoji.css"; @import "./launcher/cliphist.css"; +@import "./launcher/bluetooth.css"; * { all: unset; -- 2.43.0 From 4f9fea6d8f3e98c22a6a74e3a7c8c0b4e1c3c885 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 21:42:48 +0545 Subject: [PATCH 12/38] fix bluetooth manager --- config/quickbar/modules/launcher/launcher.py | 3 ++ .../modules/launcher/widgets/bluetooth.py | 41 +++++++------------ 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/config/quickbar/modules/launcher/launcher.py b/config/quickbar/modules/launcher/launcher.py index e1bc7739..48afec1c 100644 --- a/config/quickbar/modules/launcher/launcher.py +++ b/config/quickbar/modules/launcher/launcher.py @@ -128,7 +128,9 @@ class Launcher(Window): widget.viewport.hide() if widget == self.bluetooth and widget.viewport: + widget.viewport.hide() widget.viewport.children = [] + widget.is_active = False style_classes = [ "launcher", @@ -209,6 +211,7 @@ class Launcher(Window): self.bluetooth.open_launcher() self.bluetooth.search_entry.set_text("") self.bluetooth.search_entry.grab_focus() + self.bluetooth.device_manager.arrange_viewport() else: if hasattr(self.wallpapers, "viewport"): diff --git a/config/quickbar/modules/launcher/widgets/bluetooth.py b/config/quickbar/modules/launcher/widgets/bluetooth.py index afa5d369..8f997cb5 100644 --- a/config/quickbar/modules/launcher/widgets/bluetooth.py +++ b/config/quickbar/modules/launcher/widgets/bluetooth.py @@ -18,7 +18,7 @@ class BluetoothManager(Box): **kwargs, ) - self._arranger_handler: int = 0 + self._arranger_handler = None self.device_manager = DeviceManager(self) self.viewport = None @@ -26,8 +26,8 @@ class BluetoothManager(Box): name="search-entry", placeholder="Search Devices...", 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()), + notify_text=self.handle_search_input, + on_activate=self.handle_search_input, ) self.header_box = Box( @@ -40,19 +40,19 @@ class BluetoothManager(Box): name="power-button", child=MaterialIcon("bluetooth"), tooltip_text="Toggle Bluetooth", - on_clicked=lambda *_: self.device_manager.toggle_bluetooth(), + on_clicked=self.device_manager.toggle_bluetooth, ), Button( name="scan-button", child=MaterialIcon("search"), tooltip_text="Scan for Devices", - on_clicked=lambda *_: self.device_manager.toggle_scan(), + on_clicked=self.device_manager.toggle_scan, ), Button( name="close-button", child=MaterialIcon("close"), tooltip_text="Exit", - on_clicked=lambda *_: self.close_launcher(), + on_clicked=self.close_launcher, ), ], ) @@ -67,17 +67,8 @@ class BluetoothManager(Box): self.add(self.launcher_box) - self.is_active = False # Track whether the Bluetooth section is active - self.polling_handler = None # Track the polling handler - - self.connect("key-press-event", self.on_key_press) - - def on_key_press(self, widget, event): - """Handle Escape key press to close the launcher""" - if event.keyval == Gdk.KEY_Escape: - self.close_launcher() - return True # Stop further processing of the event - return False # Allow normal event processing + self.is_active = False + self.polling_handler = None def open_launcher(self): if not self.is_active: @@ -99,36 +90,34 @@ class BluetoothManager(Box): self.viewport.show() self.search_entry.grab_focus() - # Start refreshing devices when Bluetooth section is open self.start_device_polling() + else: + self.device_manager.arrange_viewport() def close_launcher(self): - self.is_active = False # Mark as not active + self.is_active = False if self.viewport: - self.viewport.hide() - self.viewport = None # Reset the viewport reference + self.viewport.children = [] + # self.launcher_box.remove(self.scrolled_window) + # self.viewport = None - # Stop the polling when Bluetooth section is closed self.stop_device_polling() - GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") def handle_search_input(self, text: str): - if text.lower() == ":bt": # Only handle Bluetooth search when ":bt" is input + if text.lower() == ":bt": self.open_launcher() else: self.device_manager.arrange_viewport(text) def start_device_polling(self): if not self.polling_handler and self.is_active: - print("Starting polling...") self.polling_handler = GLib.timeout_add( 5000, self.device_manager.refresh_devices ) def stop_device_polling(self): if self.polling_handler: - print("Stopping polling...") GLib.source_remove(self.polling_handler) self.polling_handler = None -- 2.43.0 From 5f74b31e917b3005706cf63eea3fef305a574619 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 22:05:02 +0545 Subject: [PATCH 13/38] added sh runner --- README.md | 2 +- config/quickbar/modules/launcher/launcher.py | 18 ++- .../modules/launcher/widgets/__init__.py | 1 + .../quickbar/modules/launcher/widgets/sh.py | 152 ++++++++++++++++++ .../modules/launcher/widgets/shell.py | 0 5 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 config/quickbar/modules/launcher/widgets/sh.py delete mode 100644 config/quickbar/modules/launcher/widgets/shell.py diff --git a/README.md b/README.md index 185b158d..389b6b34 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ ttf-font-awesome, otf-font-awesome, ttf-material-symbols-variable-git, ttf-googl # ToDo - [x] Add bluetooth widget -- [ ] Add shrunner widget +- [x] Add shrunner widget - [ ] Add wifi widget - [ ] Dashboard - [ ] Notification panel diff --git a/config/quickbar/modules/launcher/launcher.py b/config/quickbar/modules/launcher/launcher.py index 48afec1c..5feb0fdc 100644 --- a/config/quickbar/modules/launcher/launcher.py +++ b/config/quickbar/modules/launcher/launcher.py @@ -10,6 +10,7 @@ from modules.launcher.widgets import ( Cliphist, Emoji, PowerMenu, + Sh, TodoManager, WallpaperSelector, ) @@ -31,12 +32,14 @@ class Launcher(Window): self.cliphist = Cliphist() self.todo = TodoManager() self.bluetooth = BluetoothManager() + self.sh = Sh() # Initialize viewports as None self._emoji_viewport = None self._cliphist_viewport = None self._todo_viewport = None self._bluetooth_viewport = None + self._sh_viewport = None self.stack = Stack( name="launcher-content", @@ -52,6 +55,7 @@ class Launcher(Window): self.cliphist, self.todo, self.bluetooth, + self.sh, ], ) @@ -104,19 +108,17 @@ class Launcher(Window): self.cliphist, self.todo, self.bluetooth, + self.sh, ]: widget.remove_style_class("open") - # Handle wallpaper viewport if widget == self.wallpapers: self.wallpapers.viewport.hide() self.wallpapers.viewport.set_property("name", None) - # Handle emoji viewport safely if widget == self.emoji and hasattr(widget, "viewport") and widget.viewport: widget.viewport.hide() - # Handle cliphist viewport safely if ( widget == self.cliphist and hasattr(widget, "viewport") @@ -132,6 +134,9 @@ class Launcher(Window): widget.viewport.children = [] widget.is_active = False + if widget == self.sh and widget.viewport: + widget.viewport.hide() + style_classes = [ "launcher", "wallpapers", @@ -140,6 +145,7 @@ class Launcher(Window): "cliphist", "todo", "bluetooth", + "sh", ] for style_class in style_classes: if self.stack.get_style_context().has_class(style_class): @@ -159,6 +165,7 @@ class Launcher(Window): "cliphist": self.cliphist, "todo": self.todo, "bluetooth": self.bluetooth, + "sh": self.sh, } style_classes = list(widgets.keys()) @@ -213,6 +220,11 @@ class Launcher(Window): self.bluetooth.search_entry.grab_focus() self.bluetooth.device_manager.arrange_viewport() + elif widget == "sh": + self.sh.open_launcher() + self.sh.search_entry.set_text("") + self.sh.search_entry.grab_focus() + else: if hasattr(self.wallpapers, "viewport"): self.wallpapers.viewport.hide() diff --git a/config/quickbar/modules/launcher/widgets/__init__.py b/config/quickbar/modules/launcher/widgets/__init__.py index 38276c1b..24ba7fe1 100644 --- a/config/quickbar/modules/launcher/widgets/__init__.py +++ b/config/quickbar/modules/launcher/widgets/__init__.py @@ -4,5 +4,6 @@ from .cliphist import * from .dashboard import * from .emoji import * from .power import * +from .sh import * from .todo import * from .wallpapers import * diff --git a/config/quickbar/modules/launcher/widgets/sh.py b/config/quickbar/modules/launcher/widgets/sh.py new file mode 100644 index 00000000..4ef96f84 --- /dev/null +++ b/config/quickbar/modules/launcher/widgets/sh.py @@ -0,0 +1,152 @@ +import os +import subprocess +from typing import List + +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( + "XDG_CACHE_HOME", os.path.join(os.path.expanduser("~"), ".cache", "fabric") +) +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, + ) + + self._arranger_handler: int = 0 + self.shell_command_manager = ShellCommandManager(self) + self.viewport = None + + 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(), + ), + ], + ) + + self.launcher_box = Box( + name="shell-command-launcher-box", + spacing=10, + orientation="v", + h_expand=True, + children=[self.header_box], + ) + + self.add(self.launcher_box) + + def open_launcher(self): + if not self.viewport: + self.viewport = Box(name="viewport", spacing=10, orientation="v") + self.scrolled_window = ScrolledWindow( + name="scrolled-window", + spacing=10, + h_scrollbar_policy="never", + v_scrollbar_policy="never", + child=self.viewport, + ) + self.launcher_box.add(self.scrolled_window) + + self.viewport.children = [] + self.shell_command_manager.show_shell_commands(self.viewport, "") + + 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) + + +class ShellCommandManager: + def __init__(self, launcher): + self.launcher = launcher + self.binaries = set() + self.reload_binaries() + + def reload_binaries(self): + paths = os.getenv("PATH", "").split(":") + self.binaries = set() + + for path in paths: + self.binaries.update(self.list_binaries_in_path(path)) + + with open(BINS, "w") as f: + f.write("\n".join(self.binaries)) + + def list_binaries_in_path(self, path): + if not os.path.exists(path): + return [] + try: + return [ + entry + for entry in os.listdir(path) + if os.access(os.path.join(path, entry), os.X_OK) + ] + except OSError: + return [] + + def show_shell_commands(self, viewport, search_query: str): + if not search_query: + return + + viewport.children = [] + + results = self.query_binaries(search_query) + self.display_results(viewport, results) + + def query_binaries(self, filter_str: str) -> List[str]: + filter_str = filter_str.lower() + filtered_bins = (cmd for cmd in self.binaries if filter_str in cmd) + return list(dict.fromkeys(filtered_bins))[:16] + + def display_results(self, viewport, results: List[str]): + for command in results: + button = Button( + child=Label( + label=command, + v_align="center", + h_align="start", + ), + on_clicked=lambda _, cmd=command: self.execute_command(cmd), + name="sh-item", + ) + viewport.add(button) + + def execute_command(self, cmd: str): + try: + output = subprocess.check_output(cmd, shell=True, text=True) + print(output) + except subprocess.CalledProcessError as e: + print(e.output) + finally: + self.launcher.set_visible(False) diff --git a/config/quickbar/modules/launcher/widgets/shell.py b/config/quickbar/modules/launcher/widgets/shell.py deleted file mode 100644 index e69de29b..00000000 -- 2.43.0 From cbdbdf2c637694c7db73819fc59e5e3b38e331cb Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 22:08:31 +0545 Subject: [PATCH 14/38] fix bluetooth manager --- .../quickbar/modules/launcher/widgets/bluetooth.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/config/quickbar/modules/launcher/widgets/bluetooth.py b/config/quickbar/modules/launcher/widgets/bluetooth.py index 8f997cb5..60a27921 100644 --- a/config/quickbar/modules/launcher/widgets/bluetooth.py +++ b/config/quickbar/modules/launcher/widgets/bluetooth.py @@ -98,17 +98,16 @@ class BluetoothManager(Box): self.is_active = False if self.viewport: self.viewport.children = [] - # self.launcher_box.remove(self.scrolled_window) - # self.viewport = None self.stop_device_polling() GLib.spawn_command_line_async("fabric-cli exec quickbar 'launcher.close()'") - def handle_search_input(self, text: str): - if text.lower() == ":bt": - self.open_launcher() - else: - self.device_manager.arrange_viewport(text) + 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) def start_device_polling(self): if not self.polling_handler and self.is_active: -- 2.43.0 From 0b4a420e5c6ef2948066c6317599a49467cc2117 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 22:13:39 +0545 Subject: [PATCH 15/38] added style --- config/quickbar/styles/launcher/sh.css | 15 +++++++++++++++ config/quickbar/styles/main.css | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 config/quickbar/styles/launcher/sh.css diff --git a/config/quickbar/styles/launcher/sh.css b/config/quickbar/styles/launcher/sh.css new file mode 100644 index 00000000..795fdf4e --- /dev/null +++ b/config/quickbar/styles/launcher/sh.css @@ -0,0 +1,15 @@ +#shell-command-launcher-box button#sh-item { + border-radius: 11px; + background-color: transparent; + background-image: none; + box-shadow: none; + padding: 0px; +} +#shell-command-launcher-box button#sh-item { + font-size: 24px; +} + +#shell-command-launcher-box button#sh-item:hover, +#shell-command-launcher-box button#sh-item:focus { + text-shadow: 2px 2px 2px @primary; +} diff --git a/config/quickbar/styles/main.css b/config/quickbar/styles/main.css index d41d8a2c..6fea8f75 100644 --- a/config/quickbar/styles/main.css +++ b/config/quickbar/styles/main.css @@ -1,4 +1,4 @@ -@import url(../../../.cache/material/colors.css); +@import url(../../.cache/material/colors.css); @import "./bar.css"; @import "./notification.css"; @import "./osd.css"; @@ -10,6 +10,7 @@ @import "./launcher/emoji.css"; @import "./launcher/cliphist.css"; @import "./launcher/bluetooth.css"; +@import "./launcher/sh.css"; * { all: unset; -- 2.43.0 From 641a5dd981bf2d477e19a9492108da4ce0ff9c35 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 22:15:49 +0545 Subject: [PATCH 16/38] updates README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 389b6b34..413208aa 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,10 @@ ttf-font-awesome, otf-font-awesome, ttf-material-symbols-variable-git, ttf-googl - [x] Add bluetooth widget - [x] Add shrunner widget - [ ] Add wifi widget -- [ ] Dashboard -- [ ] Notification panel -- [ ] Better css -- [ ] Documentation +- [ ] Add Dashboard widget +- [ ] Add Notification panel +- [ ] Improve CSS Styling +- [ ] Add Documentation - [ ] maybe calendar with events - [ ] Audio and Brightness Controller - [ ] New Screenshot -- 2.43.0 From 225f71f00bfc9c90cb5d09d620e8e3aa1807c111 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 22:19:04 +0545 Subject: [PATCH 17/38] updates README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 413208aa..6e75d7c2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ > [!WARNING] -> This configuration is made by myself, for myself, and with very little concern for other's preferences. This configuration is not meant to be "good", it's just meant to be comfortable for me. Let it also known that this is _VERY_ WIP. +> This configuration is personal, created specifically for my own preferences and comfort. It is not intended to be universally appealing, but rather customized for my own use. Please note that this project is very much a work in progress (WIP).
@@ -15,12 +15,12 @@ ## Overview -

This repository contains my personal dotfiles and configuration files. It's currently in an early, experimental phase and may not be suitable for general use.

+

This repository contains my personal dotfiles and configuration files. It is currently in its alpha stage and primarily intended for personal use. As such, it may not be suitable for general use and could undergo significant changes in the future.

> [!NOTE] -> This repository is in the alpha stage and primarily for personal use. The organization and configurations may change significantly in the future. +> Please be aware that this repository is in an experimental phase and subject to frequent updates. The structure and configurations may evolve drastically over time. -- 2.43.0 From c5422c422f4085d8cc594180a0e4da2087c77d49 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 11 Jan 2025 22:22:05 +0545 Subject: [PATCH 18/38] fix icon --- config/quickbar/modules/launcher/widgets/bluetooth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/quickbar/modules/launcher/widgets/bluetooth.py b/config/quickbar/modules/launcher/widgets/bluetooth.py index 60a27921..500c6d33 100644 --- a/config/quickbar/modules/launcher/widgets/bluetooth.py +++ b/config/quickbar/modules/launcher/widgets/bluetooth.py @@ -44,7 +44,7 @@ class BluetoothManager(Box): ), Button( name="scan-button", - child=MaterialIcon("search"), + child=MaterialIcon("sync"), tooltip_text="Scan for Devices", on_clicked=self.device_manager.toggle_scan, ), -- 2.43.0 From f01dbfe6c719d03254c1a07effe0bee33c8a3dba Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Wed, 22 Jan 2025 15:34:20 +0545 Subject: [PATCH 19/38] update config.json for launcher --- config/quickbar/assets/config.json | 50 +++++------------------------- 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/config/quickbar/assets/config.json b/config/quickbar/assets/config.json index 9b339cff..d03f2218 100644 --- a/config/quickbar/assets/config.json +++ b/config/quickbar/assets/config.json @@ -1,44 +1,10 @@ { - "commands": [ - { - "command": ":em", - "description": "Copy an emoji", - "handler": "show_emojis" - }, - { - "command": ":sh", - "description": "Run executables from PATH", - "handler": "show_shell_commands" - }, - { - "command": ":wl", - "description": "Set the wallpaper", - "handler": "show_wallpapers" - }, - { - "command": ":nw", - "description": "List of available wifi networks", - "handler": "show_network" - }, - { - "command": ":bt", - "description": "Bluetooth", - "handler": "show_bluetooth_settings" - }, - { - "command": ":ch", - "description": "Copy a clipboard history entry", - "handler": "show_clipboard_history" - }, - { - "command": ":p", - "description": "Shutdown and go sleepy time", - "handler": "show_powermenu" - }, - { - "command": ":cl", - "description": "Show the calendar", - "handler": "show_calendar" - } - ] + "commands": { + ":wp": "launcher.open(\"wallpapers\")", + ":em": "launcher.open(\"emoji\")", + ":ch": "launcher.open(\"cliphist\")", + ":td": "launcher.open(\"todo\")", + ":bt": "launcher.open(\"bluetooth\")", + ":sh": "launcher.open(\"sh\")" + } } -- 2.43.0 From 63cd57d3591c0619ee3fc0eca3e79c1d98c8ac7c Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 24 Jan 2025 10:04:19 +0545 Subject: [PATCH 20/38] update --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6e75d7c2..d1b55233 100644 --- a/README.md +++ b/README.md @@ -48,5 +48,4 @@ ttf-font-awesome, otf-font-awesome, ttf-material-symbols-variable-git, ttf-googl - [ ] Improve CSS Styling - [ ] Add Documentation - [ ] maybe calendar with events -- [ ] Audio and Brightness Controller - [ ] New Screenshot -- 2.43.0 From a3fe5d6633d04b2f6a5654ea0b939240573f2b5c Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 24 Jan 2025 10:06:18 +0545 Subject: [PATCH 21/38] update --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d1b55233..a86cb33f 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,8 @@ ## Overview -

This repository contains my personal dotfiles and configuration files. It is currently in its alpha stage and primarily intended for personal use. As such, it may not be suitable for general use and could undergo significant changes in the future.

- - +
+This repository contains my personal dotfiles and configuration files. It is currently in its alpha stage and primarily intended for personal use. As such, it may not be suitable for general use and could undergo significant changes in the future.
> [!NOTE] > Please be aware that this repository is in an experimental phase and subject to frequent updates. The structure and configurations may evolve drastically over time. -- 2.43.0 From a49368cb28e1776d6eeea9e02e2fc7f9fd518fbd Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 24 Jan 2025 10:08:08 +0545 Subject: [PATCH 22/38] update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a86cb33f..25ee2630 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Codecov coverage GitHub code size - + ## Overview
-- 2.43.0 From 7468e200d2183453826c59f97dd1cf78043615f6 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 24 Jan 2025 10:08:42 +0545 Subject: [PATCH 23/38] update --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25ee2630..61c5b238 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,13 @@ Codecov coverage GitHub code size - ## Overview
This repository contains my personal dotfiles and configuration files. It is currently in its alpha stage and primarily intended for personal use. As such, it may not be suitable for general use and could undergo significant changes in the future.
+ + > [!NOTE] > Please be aware that this repository is in an experimental phase and subject to frequent updates. The structure and configurations may evolve drastically over time. -- 2.43.0 From 7d505d29a4839b4ea7c845777ad4b822cf6c5fef Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 24 Jan 2025 10:09:05 +0545 Subject: [PATCH 24/38] update --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 61c5b238..7aeb5533 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Codecov coverage GitHub code size + ## Overview
-- 2.43.0 From 72265d8d72641f82b66608c909e11a227ee3201d Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 2 Feb 2025 12:47:16 +0545 Subject: [PATCH 25/38] name changed to karya --- config/hypr/UserConfigs/Startup_Apps.conf | 2 +- config/hypr/UserConfigs/UserKeybinds.conf | 19 +- config/{quickbar => karya}/assets/config.json | 0 config/{quickbar => karya}/assets/emoji.json | 0 .../assets/scripts/dark-theme.sh | 0 .../assets/scripts/wayland-idle-inhibitor.py | 0 config/{quickbar => karya}/main.py | 16 +- config/{quickbar => karya}/modules/bar/bar.py | 52 ++-- .../modules/bar/components}/__init__.py | 2 +- .../modules/bar/components}/battery.py | 0 .../modules/bar/components}/bluetooth.py | 0 .../modules/bar/components}/idle.py | 4 +- .../modules/bar/components}/microphone.py | 0 .../modules/bar/components}/network.py | 0 .../modules/bar/components}/powerprofile.py | 2 +- .../modules/bar/components/stats.py} | 2 +- .../karya/modules/bar/components/taskbar.py | 154 +++++++++++ .../modules/bar/components}/volume.py | 6 +- .../modules/bar/components}/workspace.py | 0 .../modules/launcher/components}/__init__.py | 0 .../launcher/components}/applauncher.py | 104 ++++---- .../modules/launcher/components}/bluetooth.py | 173 +++++++++---- .../modules/launcher/components}/cliphist.py | 78 +++--- .../modules/launcher/components}/dashboard.py | 0 .../modules/launcher/components}/emoji.py | 10 +- .../modules/launcher/components}/power.py | 24 +- .../modules/launcher/components}/sh.py | 25 +- .../modules/launcher/components}/todo.py | 12 - .../launcher/components}/wallpapers.py | 49 ++-- .../modules/launcher/components}/wifi.py | 0 .../modules/launcher/launcher.py | 58 +---- .../modules/notification_popup.py | 5 - config/{quickbar => karya}/modules/osd.py | 17 +- config/karya/services/__init__.py | 9 + .../services/brightness.py | 0 .../services/screen_record.py | 18 +- config/{quickbar => karya}/services/wifi.py | 116 +++++++-- .../{quickbar => karya}/snippets/__init__.py | 3 +- .../{quickbar => karya}/snippets/animator.py | 0 .../functions.py => karya/snippets/config.py} | 2 +- .../snippets/custom_image.py | 0 config/{quickbar => karya}/snippets/icon.py | 0 .../launcher => karya/styles}/applauncher.css | 20 +- config/{quickbar => karya}/styles/bar.css | 25 +- .../launcher => karya/styles}/bluetooth.css | 0 .../launcher => karya/styles}/cliphist.css | 3 +- .../launcher => karya/styles}/dashboard.css | 0 .../launcher => karya/styles}/emoji.css | 0 config/karya/styles/launcher.css | 241 ++++++++++++++++++ config/{quickbar => karya}/styles/main.css | 8 - .../styles/notification.css | 0 config/{quickbar => karya}/styles/osd.css | 0 .../launcher => karya/styles}/powermenu.css | 14 +- .../styles/launcher => karya/styles}/sh.css | 0 .../styles/launcher => karya/styles}/todo.css | 0 .../launcher => karya/styles}/wallpapers.css | 17 +- .../styles/launcher => karya/styles}/wifi.css | 0 config/quickbar/assets/scripts/cliphist.sh | 44 ---- .../quickbar/modules/bar/widgets/taskbar.py | 113 -------- config/quickbar/ruff.toml | 10 - config/quickbar/services/__init__.py | 3 - config/quickbar/snippets/icon_resolver.py | 100 -------- config/quickbar/styles/launcher.css | 53 ---- 63 files changed, 902 insertions(+), 711 deletions(-) rename config/{quickbar => karya}/assets/config.json (100%) rename config/{quickbar => karya}/assets/emoji.json (100%) rename config/{quickbar => karya}/assets/scripts/dark-theme.sh (100%) rename config/{quickbar => karya}/assets/scripts/wayland-idle-inhibitor.py (100%) rename config/{quickbar => karya}/main.py (87%) rename config/{quickbar => karya}/modules/bar/bar.py (78%) rename config/{quickbar/modules/bar/widgets => karya/modules/bar/components}/__init__.py (91%) rename config/{quickbar/modules/bar/widgets => karya/modules/bar/components}/battery.py (100%) rename config/{quickbar/modules/bar/widgets => karya/modules/bar/components}/bluetooth.py (100%) rename config/{quickbar/modules/bar/widgets => karya/modules/bar/components}/idle.py (94%) rename config/{quickbar/modules/bar/widgets => karya/modules/bar/components}/microphone.py (100%) rename config/{quickbar/modules/bar/widgets => karya/modules/bar/components}/network.py (100%) rename config/{quickbar/modules/bar/widgets => karya/modules/bar/components}/powerprofile.py (93%) rename config/{quickbar/modules/bar/widgets/info.py => karya/modules/bar/components/stats.py} (98%) create mode 100644 config/karya/modules/bar/components/taskbar.py rename config/{quickbar/modules/bar/widgets => karya/modules/bar/components}/volume.py (95%) rename config/{quickbar/modules/bar/widgets => karya/modules/bar/components}/workspace.py (100%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/__init__.py (100%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/applauncher.py (61%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/bluetooth.py (57%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/cliphist.py (73%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/dashboard.py (100%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/emoji.py (91%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/power.py (75%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/sh.py (86%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/todo.py (91%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/wallpapers.py (83%) rename config/{quickbar/modules/launcher/widgets => karya/modules/launcher/components}/wifi.py (100%) rename config/{quickbar => karya}/modules/launcher/launcher.py (79%) rename config/{quickbar => karya}/modules/notification_popup.py (97%) rename config/{quickbar => karya}/modules/osd.py (95%) create mode 100644 config/karya/services/__init__.py rename config/{quickbar => karya}/services/brightness.py (100%) rename config/{quickbar => karya}/services/screen_record.py (92%) rename config/{quickbar => karya}/services/wifi.py (70%) rename config/{quickbar => karya}/snippets/__init__.py (57%) rename config/{quickbar => karya}/snippets/animator.py (100%) rename config/{quickbar/snippets/functions.py => karya/snippets/config.py} (95%) rename config/{quickbar => karya}/snippets/custom_image.py (100%) rename config/{quickbar => karya}/snippets/icon.py (100%) rename config/{quickbar/styles/launcher => karya/styles}/applauncher.css (60%) rename config/{quickbar => karya}/styles/bar.css (92%) rename config/{quickbar/styles/launcher => karya/styles}/bluetooth.css (100%) rename config/{quickbar/styles/launcher => karya/styles}/cliphist.css (97%) rename config/{quickbar/styles/launcher => karya/styles}/dashboard.css (100%) rename config/{quickbar/styles/launcher => karya/styles}/emoji.css (100%) create mode 100644 config/karya/styles/launcher.css rename config/{quickbar => karya}/styles/main.css (79%) rename config/{quickbar => karya}/styles/notification.css (100%) rename config/{quickbar => karya}/styles/osd.css (100%) rename config/{quickbar/styles/launcher => karya/styles}/powermenu.css (56%) rename config/{quickbar/styles/launcher => karya/styles}/sh.css (100%) rename config/{quickbar/styles/launcher => karya/styles}/todo.css (100%) rename config/{quickbar/styles/launcher => karya/styles}/wallpapers.css (57%) rename config/{quickbar/styles/launcher => karya/styles}/wifi.css (100%) delete mode 100755 config/quickbar/assets/scripts/cliphist.sh delete mode 100644 config/quickbar/modules/bar/widgets/taskbar.py delete mode 100644 config/quickbar/ruff.toml delete mode 100644 config/quickbar/services/__init__.py delete mode 100644 config/quickbar/snippets/icon_resolver.py delete mode 100644 config/quickbar/styles/launcher.css 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; -} -- 2.43.0 From 4cf43d70ed82a456005dbebfa1b4beb864da3d54 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 2 Feb 2025 12:49:36 +0545 Subject: [PATCH 26/38] update styles --- config/karya/styles/applauncher.css | 44 ----------------------------- config/karya/styles/bluetooth.css | 10 ------- config/karya/styles/cliphist.css | 30 -------------------- config/karya/styles/dashboard.css | 0 config/karya/styles/emoji.css | 16 ----------- config/karya/styles/main.css | 2 +- config/karya/styles/powermenu.css | 26 ----------------- config/karya/styles/sh.css | 15 ---------- config/karya/styles/todo.css | 24 ---------------- config/karya/styles/wallpapers.css | 40 -------------------------- config/karya/styles/wifi.css | 0 11 files changed, 1 insertion(+), 206 deletions(-) delete mode 100644 config/karya/styles/applauncher.css delete mode 100644 config/karya/styles/bluetooth.css delete mode 100644 config/karya/styles/cliphist.css delete mode 100644 config/karya/styles/dashboard.css delete mode 100644 config/karya/styles/emoji.css delete mode 100644 config/karya/styles/powermenu.css delete mode 100644 config/karya/styles/sh.css delete mode 100644 config/karya/styles/todo.css delete mode 100644 config/karya/styles/wallpapers.css delete mode 100644 config/karya/styles/wifi.css diff --git a/config/karya/styles/applauncher.css b/config/karya/styles/applauncher.css deleted file mode 100644 index 30a37c4e..00000000 --- a/config/karya/styles/applauncher.css +++ /dev/null @@ -1,44 +0,0 @@ -#launcher-app { - border-radius: 16px; - padding: 16px; - transition: padding 0.25s cubic-bezier(0.5, 0.25, 0, 1); - animation: loadSlot 0.5s ease; -} - -@keyframes loadSlot { - 0% { - opacity: 0; - } - - 100% { - opacity: 1; - } -} - -#launcher-app:hover image, -#launcher-app:focus imgae { - -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-icons { - animation: fade-in 0.25s ease-in-out; -} - -@keyframes fade-in { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} diff --git a/config/karya/styles/bluetooth.css b/config/karya/styles/bluetooth.css deleted file mode 100644 index 032e880b..00000000 --- a/config/karya/styles/bluetooth.css +++ /dev/null @@ -1,10 +0,0 @@ -#device-slot { - background-color: @suraceVariant; - border-radius: 5px; - padding: 8px; -} - -#device-slot:hover, -#device-slot:focus { - background-color: mix(@onSurface, @surface, 0.92); -} diff --git a/config/karya/styles/cliphist.css b/config/karya/styles/cliphist.css deleted file mode 100644 index fffb40bc..00000000 --- a/config/karya/styles/cliphist.css +++ /dev/null @@ -1,30 +0,0 @@ -#cliphist-launcher-box button#clip-img-item { - background-size: cover; - background-position: center; - background-repeat: no-repeat; - border-radius: 8px; - min-width: 70px; - min-height: 70px; -} - -#cliphist-launcher-box button#clip-img-item:hover, -#cliphist-launcher-box button#clip-img-item:focus { - box-shadow: 2px 2px 2px @primary; -} - -#cliphist-launcher-box button#clip-item { - border-radius: 11px; - background-color: transparent; - background-image: none; - box-shadow: none; - padding: 3px; -} - -#cliphist-launcher-box button#clip-item { - font-size: 24px; -} - -#cliphist-launcher-box button#clip-item:hover, -#cliphist-launcher-box button#clip-item:focus { - text-shadow: 2px 2px 2px @primary; -} diff --git a/config/karya/styles/dashboard.css b/config/karya/styles/dashboard.css deleted file mode 100644 index e69de29b..00000000 diff --git a/config/karya/styles/emoji.css b/config/karya/styles/emoji.css deleted file mode 100644 index 146ceec9..00000000 --- a/config/karya/styles/emoji.css +++ /dev/null @@ -1,16 +0,0 @@ -#emoji-launcher-box button#emoji-item { - border-radius: 11px; - background-color: transparent; - background-image: none; - box-shadow: none; - padding: 0px; -} - -#emoji-launcher-box button#emoji-item label { - font-size: 24px; -} - -#emoji-launcher-box button#emoji-item:hover, -#emoji-launcher-box button#emoji-item:focus { - text-shadow: 2px 2px 2px @primary; -} diff --git a/config/karya/styles/main.css b/config/karya/styles/main.css index 06b8be9a..77fa29cd 100644 --- a/config/karya/styles/main.css +++ b/config/karya/styles/main.css @@ -1,4 +1,4 @@ -@import url(../../.cache/material/colors.css); +@import url(../../../.cache/material/colors.css); @import "./bar.css"; @import "./notification.css"; @import "./osd.css"; diff --git a/config/karya/styles/powermenu.css b/config/karya/styles/powermenu.css deleted file mode 100644 index ff981805..00000000 --- a/config/karya/styles/powermenu.css +++ /dev/null @@ -1,26 +0,0 @@ -#powermenu-button { - border-radius: 20px; - padding: 20px; -} - -#powermenu-button:hover, -#powermenu-button:focus { - background-color: mix(@onSurface, @surface, 0.8); -} - -#powermenu-button:hover label, -#powermenu-button:focus label { - color: @primary; -} - -#powermenu-button:active { - background-image: radial-gradient( - circle, - mix(@onSurfaceVariant, transparent, 0.7) 10%, - transparent 0% - ); -} - -#powermenu-button:active label { - color: @shadow; -} diff --git a/config/karya/styles/sh.css b/config/karya/styles/sh.css deleted file mode 100644 index 795fdf4e..00000000 --- a/config/karya/styles/sh.css +++ /dev/null @@ -1,15 +0,0 @@ -#shell-command-launcher-box button#sh-item { - border-radius: 11px; - background-color: transparent; - background-image: none; - box-shadow: none; - padding: 0px; -} -#shell-command-launcher-box button#sh-item { - font-size: 24px; -} - -#shell-command-launcher-box button#sh-item:hover, -#shell-command-launcher-box button#sh-item:focus { - text-shadow: 2px 2px 2px @primary; -} diff --git a/config/karya/styles/todo.css b/config/karya/styles/todo.css deleted file mode 100644 index b10f5635..00000000 --- a/config/karya/styles/todo.css +++ /dev/null @@ -1,24 +0,0 @@ -#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; -} diff --git a/config/karya/styles/wallpapers.css b/config/karya/styles/wallpapers.css deleted file mode 100644 index 90caf42b..00000000 --- a/config/karya/styles/wallpapers.css +++ /dev/null @@ -1,40 +0,0 @@ -#wallpaper-icons { - animation: fade-in 0.25s ease-in-out; -} - -@keyframes fade-in { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} - -#wallpaper-icons:selected { - 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/karya/styles/wifi.css b/config/karya/styles/wifi.css deleted file mode 100644 index e69de29b..00000000 -- 2.43.0 From 7472e917367c30cdb2a4aa86dfe259c5d15c94ed Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 2 Feb 2025 16:16:47 +0545 Subject: [PATCH 27/38] update styles --- config/karya/styles/launcher.css | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/karya/styles/launcher.css b/config/karya/styles/launcher.css index 8b2115af..53509a7a 100644 --- a/config/karya/styles/launcher.css +++ b/config/karya/styles/launcher.css @@ -21,6 +21,14 @@ min-width: 620px; } +#launcher-content.bluetooth { + min-height: 420px; +} + +#launcher-content { + min-width: 420px; +} + #app-launcher, #wallpapers, #todo, @@ -29,6 +37,7 @@ #cliphist, #emoji, #powermenu { + opacity: 1; transition: all 0.25s cubic-bezier(0.5, 0.25, 0, 1); } -- 2.43.0 From 1db834448f3afda81aa338935408b500f371fc6a Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 2 Feb 2025 16:41:29 +0545 Subject: [PATCH 28/38] changed name to modus --- config/hypr/UserConfigs/Startup_Apps.conf | 2 +- config/hypr/UserConfigs/UserKeybinds.conf | 4 +- config/{karya => modus}/assets/config.json | 0 config/{karya => modus}/assets/emoji.json | 0 .../assets/scripts/dark-theme.sh | 0 .../assets/scripts/wayland-idle-inhibitor.py | 0 config/{karya => modus}/main.py | 4 +- config/{karya => modus}/modules/bar/bar.py | 0 .../modules/bar/components/__init__.py | 0 .../modules/bar/components/battery.py | 0 .../modules/bar/components/bluetooth.py | 0 .../modules/bar/components/idle.py | 0 .../modules/bar/components/microphone.py | 0 .../modules/bar/components/network.py | 0 .../modules/bar/components/powerprofile.py | 0 .../modules/bar/components/stats.py | 0 .../modules/bar/components/taskbar.py | 0 .../modules/bar/components/volume.py | 0 .../modules/bar/components/workspace.py | 0 .../modules/launcher/components/__init__.py | 0 .../launcher/components/applauncher.py | 4 +- .../components/bluetooth (copy 1).py} | 0 .../modules/launcher/components/bluetooth.py | 290 ++++++++++++++++++ .../modules/launcher/components/cliphist.py | 2 +- .../modules/launcher/components/dashboard.py | 0 .../modules/launcher/components/emoji.py | 4 +- .../modules/launcher/components/power.py | 2 +- .../modules/launcher/components/sh.py | 2 +- .../modules/launcher/components/todo.py | 0 .../modules/launcher/components/wallpapers.py | 0 .../modules/launcher/components/wifi.py | 0 .../modules/launcher/launcher (copy 1).py | 132 ++++++++ .../modules/launcher/launcher (copy 2).py | 194 ++++++++++++ .../modules/launcher/launcher.py | 43 +-- .../modules/notification_popup.py | 0 config/{karya => modus}/modules/osd.py | 0 config/{karya => modus}/services/__init__.py | 0 .../{karya => modus}/services/brightness.py | 0 .../services/screen_record.py | 0 config/{karya => modus}/services/wifi.py | 0 config/{karya => modus}/snippets/__init__.py | 0 config/{karya => modus}/snippets/animator.py | 0 config/{karya => modus}/snippets/config.py | 2 +- .../{karya => modus}/snippets/custom_image.py | 0 config/{karya => modus}/snippets/icon.py | 0 config/modus/styles/applauncher.css | 44 +++ config/{karya => modus}/styles/bar.css | 0 config/modus/styles/bluetooth.css | 10 + config/modus/styles/cliphist.css | 30 ++ config/modus/styles/dashboard.css | 0 config/modus/styles/emoji.css | 16 + config/{karya => modus}/styles/launcher.css | 0 config/{karya => modus}/styles/main.css | 2 +- .../{karya => modus}/styles/notification.css | 0 config/{karya => modus}/styles/osd.css | 0 config/modus/styles/powermenu.css | 26 ++ config/modus/styles/sh.css | 15 + config/modus/styles/todo.css | 24 ++ config/modus/styles/wallpapers.css | 40 +++ config/modus/styles/wifi.css | 0 60 files changed, 848 insertions(+), 44 deletions(-) rename config/{karya => modus}/assets/config.json (100%) rename config/{karya => modus}/assets/emoji.json (100%) rename config/{karya => modus}/assets/scripts/dark-theme.sh (100%) rename config/{karya => modus}/assets/scripts/wayland-idle-inhibitor.py (100%) rename config/{karya => modus}/main.py (97%) rename config/{karya => modus}/modules/bar/bar.py (100%) rename config/{karya => modus}/modules/bar/components/__init__.py (100%) rename config/{karya => modus}/modules/bar/components/battery.py (100%) rename config/{karya => modus}/modules/bar/components/bluetooth.py (100%) rename config/{karya => modus}/modules/bar/components/idle.py (100%) rename config/{karya => modus}/modules/bar/components/microphone.py (100%) rename config/{karya => modus}/modules/bar/components/network.py (100%) rename config/{karya => modus}/modules/bar/components/powerprofile.py (100%) rename config/{karya => modus}/modules/bar/components/stats.py (100%) rename config/{karya => modus}/modules/bar/components/taskbar.py (100%) rename config/{karya => modus}/modules/bar/components/volume.py (100%) rename config/{karya => modus}/modules/bar/components/workspace.py (100%) rename config/{karya => modus}/modules/launcher/components/__init__.py (100%) rename config/{karya => modus}/modules/launcher/components/applauncher.py (97%) rename config/{karya/modules/launcher/components/bluetooth.py => modus/modules/launcher/components/bluetooth (copy 1).py} (100%) create mode 100644 config/modus/modules/launcher/components/bluetooth.py rename config/{karya => modus}/modules/launcher/components/cliphist.py (99%) rename config/{karya => modus}/modules/launcher/components/dashboard.py (100%) rename config/{karya => modus}/modules/launcher/components/emoji.py (96%) rename config/{karya => modus}/modules/launcher/components/power.py (97%) rename config/{karya => modus}/modules/launcher/components/sh.py (98%) rename config/{karya => modus}/modules/launcher/components/todo.py (100%) rename config/{karya => modus}/modules/launcher/components/wallpapers.py (100%) rename config/{karya => modus}/modules/launcher/components/wifi.py (100%) create mode 100644 config/modus/modules/launcher/launcher (copy 1).py create mode 100644 config/modus/modules/launcher/launcher (copy 2).py rename config/{karya => modus}/modules/launcher/launcher.py (81%) rename config/{karya => modus}/modules/notification_popup.py (100%) rename config/{karya => modus}/modules/osd.py (100%) rename config/{karya => modus}/services/__init__.py (100%) rename config/{karya => modus}/services/brightness.py (100%) rename config/{karya => modus}/services/screen_record.py (100%) rename config/{karya => modus}/services/wifi.py (100%) rename config/{karya => modus}/snippets/__init__.py (100%) rename config/{karya => modus}/snippets/animator.py (100%) rename config/{karya => modus}/snippets/config.py (94%) rename config/{karya => modus}/snippets/custom_image.py (100%) rename config/{karya => modus}/snippets/icon.py (100%) create mode 100644 config/modus/styles/applauncher.css rename config/{karya => modus}/styles/bar.css (100%) create mode 100644 config/modus/styles/bluetooth.css create mode 100644 config/modus/styles/cliphist.css create mode 100644 config/modus/styles/dashboard.css create mode 100644 config/modus/styles/emoji.css rename config/{karya => modus}/styles/launcher.css (100%) rename config/{karya => modus}/styles/main.css (95%) rename config/{karya => modus}/styles/notification.css (100%) rename config/{karya => modus}/styles/osd.css (100%) create mode 100644 config/modus/styles/powermenu.css create mode 100644 config/modus/styles/sh.css create mode 100644 config/modus/styles/todo.css create mode 100644 config/modus/styles/wallpapers.css create mode 100644 config/modus/styles/wifi.css diff --git a/config/hypr/UserConfigs/Startup_Apps.conf b/config/hypr/UserConfigs/Startup_Apps.conf index 3f248ec5..2ee7d734 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/karya && python main.py +exec-once = cd ~/dotfiles/modus && 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 dad7ef78..55d44050 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 = fabric-cli exec karya +$fabric = fabric-cli exec modus # 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" @@ -28,7 +28,7 @@ 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_SHIFT, t, exec, killall karya || sleep 0.5 && python ~/karya/main.py & +bind = ALT_SHIFT, t, exec, killall modus || sleep 0.5 && python ~/dotfiles/modus/main.py & bind = $mainMod, R, exec, $fabric 'sc.screencast_start()' bind = $mainMod_SHIFT, R, exec, $fabric 'sc.screencast_stop()' diff --git a/config/karya/assets/config.json b/config/modus/assets/config.json similarity index 100% rename from config/karya/assets/config.json rename to config/modus/assets/config.json diff --git a/config/karya/assets/emoji.json b/config/modus/assets/emoji.json similarity index 100% rename from config/karya/assets/emoji.json rename to config/modus/assets/emoji.json diff --git a/config/karya/assets/scripts/dark-theme.sh b/config/modus/assets/scripts/dark-theme.sh similarity index 100% rename from config/karya/assets/scripts/dark-theme.sh rename to config/modus/assets/scripts/dark-theme.sh diff --git a/config/karya/assets/scripts/wayland-idle-inhibitor.py b/config/modus/assets/scripts/wayland-idle-inhibitor.py similarity index 100% rename from config/karya/assets/scripts/wayland-idle-inhibitor.py rename to config/modus/assets/scripts/wayland-idle-inhibitor.py diff --git a/config/karya/main.py b/config/modus/main.py similarity index 97% rename from config/karya/main.py rename to config/modus/main.py index 1fd1e1ea..a4cfef51 100644 --- a/config/karya/main.py +++ b/config/modus/main.py @@ -48,12 +48,12 @@ if __name__ == "__main__": launcher = Launcher() app = Application( - "karya", + "modus", bar, launcher, osd, ) - setproctitle.setproctitle("karya") + setproctitle.setproctitle("modus") # Monitor CSS files for changes css_file = monitor_file(get_relative_path("styles")) diff --git a/config/karya/modules/bar/bar.py b/config/modus/modules/bar/bar.py similarity index 100% rename from config/karya/modules/bar/bar.py rename to config/modus/modules/bar/bar.py diff --git a/config/karya/modules/bar/components/__init__.py b/config/modus/modules/bar/components/__init__.py similarity index 100% rename from config/karya/modules/bar/components/__init__.py rename to config/modus/modules/bar/components/__init__.py diff --git a/config/karya/modules/bar/components/battery.py b/config/modus/modules/bar/components/battery.py similarity index 100% rename from config/karya/modules/bar/components/battery.py rename to config/modus/modules/bar/components/battery.py diff --git a/config/karya/modules/bar/components/bluetooth.py b/config/modus/modules/bar/components/bluetooth.py similarity index 100% rename from config/karya/modules/bar/components/bluetooth.py rename to config/modus/modules/bar/components/bluetooth.py diff --git a/config/karya/modules/bar/components/idle.py b/config/modus/modules/bar/components/idle.py similarity index 100% rename from config/karya/modules/bar/components/idle.py rename to config/modus/modules/bar/components/idle.py diff --git a/config/karya/modules/bar/components/microphone.py b/config/modus/modules/bar/components/microphone.py similarity index 100% rename from config/karya/modules/bar/components/microphone.py rename to config/modus/modules/bar/components/microphone.py diff --git a/config/karya/modules/bar/components/network.py b/config/modus/modules/bar/components/network.py similarity index 100% rename from config/karya/modules/bar/components/network.py rename to config/modus/modules/bar/components/network.py diff --git a/config/karya/modules/bar/components/powerprofile.py b/config/modus/modules/bar/components/powerprofile.py similarity index 100% rename from config/karya/modules/bar/components/powerprofile.py rename to config/modus/modules/bar/components/powerprofile.py diff --git a/config/karya/modules/bar/components/stats.py b/config/modus/modules/bar/components/stats.py similarity index 100% rename from config/karya/modules/bar/components/stats.py rename to config/modus/modules/bar/components/stats.py diff --git a/config/karya/modules/bar/components/taskbar.py b/config/modus/modules/bar/components/taskbar.py similarity index 100% rename from config/karya/modules/bar/components/taskbar.py rename to config/modus/modules/bar/components/taskbar.py diff --git a/config/karya/modules/bar/components/volume.py b/config/modus/modules/bar/components/volume.py similarity index 100% rename from config/karya/modules/bar/components/volume.py rename to config/modus/modules/bar/components/volume.py diff --git a/config/karya/modules/bar/components/workspace.py b/config/modus/modules/bar/components/workspace.py similarity index 100% rename from config/karya/modules/bar/components/workspace.py rename to config/modus/modules/bar/components/workspace.py diff --git a/config/karya/modules/launcher/components/__init__.py b/config/modus/modules/launcher/components/__init__.py similarity index 100% rename from config/karya/modules/launcher/components/__init__.py rename to config/modus/modules/launcher/components/__init__.py diff --git a/config/karya/modules/launcher/components/applauncher.py b/config/modus/modules/launcher/components/applauncher.py similarity index 97% rename from config/karya/modules/launcher/components/applauncher.py rename to config/modus/modules/launcher/components/applauncher.py index 0f684c78..a51bd41e 100644 --- a/config/karya/modules/launcher/components/applauncher.py +++ b/config/modus/modules/launcher/components/applauncher.py @@ -69,7 +69,7 @@ class AppLauncher(Box): 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()'") + GLib.spawn_command_line_async("fabric-cli exec modus 'launcher.close()'") def handle_search_input(self, entry, *_): text = entry.get_text().strip() @@ -77,7 +77,7 @@ class AppLauncher(Box): if text in commands: command = commands[text] - GLib.spawn_command_line_async(f"fabric-cli exec karya '{command}'") + GLib.spawn_command_line_async(f"fabric-cli exec modus '{command}'") self.search_entry.set_text("") else: self.arrange_viewport(text) diff --git a/config/karya/modules/launcher/components/bluetooth.py b/config/modus/modules/launcher/components/bluetooth (copy 1).py similarity index 100% rename from config/karya/modules/launcher/components/bluetooth.py rename to config/modus/modules/launcher/components/bluetooth (copy 1).py diff --git a/config/modus/modules/launcher/components/bluetooth.py b/config/modus/modules/launcher/components/bluetooth.py new file mode 100644 index 00000000..6500f897 --- /dev/null +++ b/config/modus/modules/launcher/components/bluetooth.py @@ -0,0 +1,290 @@ +from fabric.bluetooth import BluetoothClient, BluetoothDevice +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 + +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): + super().__init__( + name="bluetooth-launcher", + all_visible=False, + visible=False, + **kwargs, + ) + + self._arranger_handler = None + self.device_manager = DeviceManager(self) + self.viewport = None + + self.search_entry = Entry( + name="search-entry", + 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( + child=MaterialIcon("sync"), + on_clicked=lambda *_: self.device_manager.bluetooth_client.toggle_scan(), + ), + ], + ) + + self.launcher_box = Box( + name="bluetooth-launcher-box", + spacing=10, + orientation="v", + h_expand=True, + children=[self.header_box], + ) + + self.add(self.launcher_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.viewport: + self.viewport = Box(name="viewport", spacing=4, orientation="v") + self.scrolled_window = ScrolledWindow( + name="scrolled-window", + spacing=10, + h_scrollbar_policy="never", + child=self.viewport, + ) + self.launcher_box.add(self.scrolled_window) + + self.viewport.children = [] + self.device_manager.arrange_viewport() + + self.viewport.show() + self.search_entry.grab_focus() + + self.start_device_polling() + + def handle_search_input(self, entry, text: str): + if isinstance(text, str): + self.device_manager.arrange_viewport(text) + + def start_device_polling(self): + GLib.timeout_add(5000, self.device_manager.refresh_devices) + + +class DeviceManager: + def __init__(self, launcher): + self.launcher = launcher + self.bluetooth_client = BluetoothClient( + on_device_added=self.on_device_added, + on_device_removed=self.on_device_removed, + ) + self._cached_devices = [] + + def refresh_devices(self, *_): + if not sel.bluetooth_client.enabled: + return True + if self.launcher.viewport: # Only refresh devices if Bluetooth section is open + self.arrange_viewport() + return True + + def toggle_bluetooth(self, *_): + self.bluetooth_client.toggle_power() + self.arrange_viewport() + + def on_device_added(self, client: BluetoothClient, address: str): + if device := client.get_device(address): + self._cached_devices.append(device) + self.refresh_viewport() + + def on_device_removed(self, client: BluetoothClient, address: str): + self._cached_devices = [ + device for device in self._cached_devices if device.address != address + ] + self.refresh_viewport() + + def refresh_viewport(self): + GLib.idle_add(self.arrange_viewport) + + def query_devices(self, query: str = "") -> list: + if not self.bluetooth_client.enabled: # Skip querying if Bluetooth is off + return [] # No devices to show when Bluetooth is off + devices = [] + query = query.lower() + + for device in self._cached_devices: + name = device.name or "Unknown Device" + 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.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=device_slot_children, + ) + + def arrange_viewport(self, query: str = ""): + if not self.launcher.viewport: + return + + # If Bluetooth is off, show a message that Bluetooth is off + if not self.bluetooth_client.enabled: + self.launcher.viewport.children = [] # Clear any existing content + self.launcher.viewport.add( + Label( + label="Bluetooth is off", # Display "Bluetooth is off" + h_align="center", + ) + ) + return + self.launcher.viewport.children = [] + + 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)) + + if paired_devices := [d for d in filtered_devices if d.paired]: + for device in paired_devices: + self.launcher.viewport.add(self.bake_device_slot(device)) + + if not filtered_devices: + self.launcher.viewport.add( + Label( + label="No devices found" if not query else "No matching devices", + name="empty-label", + h_align="center", + ) + ) diff --git a/config/karya/modules/launcher/components/cliphist.py b/config/modus/modules/launcher/components/cliphist.py similarity index 99% rename from config/karya/modules/launcher/components/cliphist.py rename to config/modus/modules/launcher/components/cliphist.py index a0579295..2d7e8b9c 100644 --- a/config/karya/modules/launcher/components/cliphist.py +++ b/config/modus/modules/launcher/components/cliphist.py @@ -81,7 +81,7 @@ class Cliphist(Box): def close_launcher(self): """Closes the clipboard history launcher and clears viewport.""" self.viewport.children = [] - GLib.spawn_command_line_async("fabric-cli exec karya 'launcher.close()'") + GLib.spawn_command_line_async("fabric-cli exec modus 'launcher.close()'") def handle_search_input(self, text: str): """Handles search input to filter clipboard history.""" diff --git a/config/karya/modules/launcher/components/dashboard.py b/config/modus/modules/launcher/components/dashboard.py similarity index 100% rename from config/karya/modules/launcher/components/dashboard.py rename to config/modus/modules/launcher/components/dashboard.py diff --git a/config/karya/modules/launcher/components/emoji.py b/config/modus/modules/launcher/components/emoji.py similarity index 96% rename from config/karya/modules/launcher/components/emoji.py rename to config/modus/modules/launcher/components/emoji.py index a4b78271..75537968 100644 --- a/config/karya/modules/launcher/components/emoji.py +++ b/config/modus/modules/launcher/components/emoji.py @@ -70,7 +70,7 @@ class Emoji(Box): self.search_entry.grab_focus() def close_launcher(self): - GLib.spawn_command_line_async("fabric-cli exec karya'launcher.close()'") + GLib.spawn_command_line_async("fabric-cli exec modus'launcher.close()'") def handle_search_input(self, text: str): self.emoji_manager.arrange_viewport(text) @@ -79,7 +79,7 @@ class Emoji(Box): class EmojiManager: def __init__(self, launcher): self.launcher = launcher - self.emoji_file_path = os.path.expanduser("~/quickbar/assets/emoji.json") + self.emoji_file_path = os.path.expanduser("~/dotfiles/modus/assets/emoji.json") def load_emojis(self) -> Generator[tuple, None, None]: if not os.path.exists(self.emoji_file_path): diff --git a/config/karya/modules/launcher/components/power.py b/config/modus/modules/launcher/components/power.py similarity index 97% rename from config/karya/modules/launcher/components/power.py rename to config/modus/modules/launcher/components/power.py index 81a9f7da..a2016058 100644 --- a/config/karya/modules/launcher/components/power.py +++ b/config/modus/modules/launcher/components/power.py @@ -63,7 +63,7 @@ class PowerMenu(Box): self.show_all() def close_menu(self): - GLib.spawn_command_line_async("fabric-cli exec karya 'launcher.close()'") + GLib.spawn_command_line_async("fabric-cli exec modus 'launcher.close()'") def lock(self, *_): GLib.spawn_command_line_async("hyprlock --immediate") diff --git a/config/karya/modules/launcher/components/sh.py b/config/modus/modules/launcher/components/sh.py similarity index 98% rename from config/karya/modules/launcher/components/sh.py rename to config/modus/modules/launcher/components/sh.py index b03de3d9..627a0ace 100644 --- a/config/karya/modules/launcher/components/sh.py +++ b/config/modus/modules/launcher/components/sh.py @@ -127,7 +127,7 @@ class ShellCommandManager: viewport.add(button) def close_menu(self): - GLib.spawn_command_line_async("fabric-cli exec karya 'launcher.close()'") + GLib.spawn_command_line_async("fabric-cli exec modus 'launcher.close()'") def execute_command(self, cmd: str): try: diff --git a/config/karya/modules/launcher/components/todo.py b/config/modus/modules/launcher/components/todo.py similarity index 100% rename from config/karya/modules/launcher/components/todo.py rename to config/modus/modules/launcher/components/todo.py diff --git a/config/karya/modules/launcher/components/wallpapers.py b/config/modus/modules/launcher/components/wallpapers.py similarity index 100% rename from config/karya/modules/launcher/components/wallpapers.py rename to config/modus/modules/launcher/components/wallpapers.py diff --git a/config/karya/modules/launcher/components/wifi.py b/config/modus/modules/launcher/components/wifi.py similarity index 100% rename from config/karya/modules/launcher/components/wifi.py rename to config/modus/modules/launcher/components/wifi.py diff --git a/config/modus/modules/launcher/launcher (copy 1).py b/config/modus/modules/launcher/launcher (copy 1).py new file mode 100644 index 00000000..fdcbf8c7 --- /dev/null +++ b/config/modus/modules/launcher/launcher (copy 1).py @@ -0,0 +1,132 @@ +from fabric.widgets.centerbox import CenterBox +from fabric.widgets.wayland import WaylandWindow as Window +from modules.launcher.components import ( + AppLauncher, + BluetoothManager, + Cliphist, + Emoji, + PowerMenu, + Sh, + TodoManager, + WallpaperSelector, +) + + +class Launcher(Window): + def __init__(self, **kwargs): + super().__init__( + layer="top", + anchor="center", + visible=False, + all_visible=False, + **kwargs, + ) + + self.launcher = AppLauncher() + self.wallpapers = WallpaperSelector() + self.power = PowerMenu() + self.emoji = Emoji() + self.cliphist = Cliphist() + self.todo = TodoManager() + self.bluetooth = BluetoothManager() + self.sh = Sh() + + self.widgets = { + "launcher": self.launcher, + "wallpapers": self.wallpapers, + "power": self.power, + "emoji": self.emoji, + "cliphist": self.cliphist, + "todo": self.todo, + "bluetooth": self.bluetooth, + "sh": self.sh, + } + + self.launcher_box = CenterBox( + name="launcher", + orientation="v", + start_children=[ + self.launcher, + self.wallpapers, + self.power, + self.emoji, + self.cliphist, + self.todo, + self.bluetooth, + self.sh, + ], + ) + + self.add(self.launcher_box) + self.show_all() + self.hide() + self.add_keybinding("Escape", lambda *_: self.close()) + + def close(self): + self.set_keyboard_mode("none") + self.hide() + + if self.bluetooth.is_active: + self.bluetooth.stop_device_polling() + + for widget in self.widgets.values(): + widget.hide() + + # if hasattr(widget, "viewport") and widget.viewport: + # widget.viewport.hide() + + return True + + def open(self, widget): + if widget not in self.widgets: + return + + self.set_keyboard_mode("exclusive") + self.show() + + for w in self.widgets.values(): + w.hide() + w.remove_style_class("open") + + self.widgets[widget].show() + + if widget == "launcher": + self.launcher.open_launcher() + self.launcher.search_entry.set_text("") + self.launcher.search_entry.grab_focus() + + elif widget == "wallpapers": + self.wallpapers.search_entry.set_text("") + self.wallpapers.search_entry.grab_focus() + self.wallpapers.viewport.show() + self.wallpapers.viewport.set_property("name", "wallpaper-icons") + + elif widget == "emoji": + self.emoji.open_launcher() + self.emoji.search_entry.set_text("") + self.emoji.search_entry.grab_focus() + + elif widget == "cliphist": + self.cliphist.open_launcher() + self.cliphist.search_entry.set_text("") + self.cliphist.search_entry.grab_focus() + + elif widget == "todo": + self.todo.open_launcher() + self.todo.todo_entry.set_text("") + self.todo.todo_entry.grab_focus() + + elif widget == "bluetooth": + self.bluetooth.open_launcher() + self.bluetooth.search_entry.set_text("") + self.bluetooth.search_entry.grab_focus() + self.bluetooth.device_manager.arrange_viewport() + + elif widget == "sh": + self.sh.open_launcher() + self.sh.search_entry.set_text("") + self.sh.search_entry.grab_focus() + else: + if hasattr(self.wallpapers, "viewport"): + self.wallpapers.viewport.hide() + self.wallpapers.viewport.set_property("name", None) diff --git a/config/modus/modules/launcher/launcher (copy 2).py b/config/modus/modules/launcher/launcher (copy 2).py new file mode 100644 index 00000000..21582890 --- /dev/null +++ b/config/modus/modules/launcher/launcher (copy 2).py @@ -0,0 +1,194 @@ +from fabric.widgets.centerbox import CenterBox +from fabric.widgets.stack import Stack +from fabric.widgets.wayland import WaylandWindow as Window +from modules.launcher.components import ( + AppLauncher, + BluetoothManager, + Cliphist, + Emoji, + PowerMenu, + Sh, + TodoManager, + WallpaperSelector, +) + + +class Launcher(Window): + def __init__(self, **kwargs): + super().__init__( + layer="top", + anchor="center", + visible=False, + all_visible=False, + **kwargs, + ) + + self.launcher = AppLauncher() + self.wallpapers = WallpaperSelector() + self.power = PowerMenu() + self.emoji = Emoji() + self.cliphist = Cliphist() + self.todo = TodoManager() + self.bluetooth = BluetoothManager() + self.sh = Sh() + + self._emoji_viewport = None + self._cliphist_viewport = None + self._todo_viewport = None + self._bluetooth_viewport = None + self._sh_viewport = None + + self.stack = Stack( + name="launcher-content", + v_expand=True, + h_expand=True, + transition_type="crossfade", + transition_duration=250, + children=[ + self.launcher, + self.wallpapers, + self.power, + self.emoji, + self.cliphist, + self.todo, + self.bluetooth, + self.sh, + ], + ) + + self.launcher_box = CenterBox( + name="launcher", + orientation="v", + start_children=self.stack, + ) + + self.add(self.launcher_box) + self.show_all() + self.hide() + self.wallpapers.viewport.hide() + self.add_keybinding("Escape", lambda *_: self.close()) + + def close(self): + self.set_keyboard_mode("none") + self.hide() + if self.bluetooth.is_active: + self.bluetooth.stop_device_polling() + + for widget in [ + self.launcher, + self.wallpapers, + self.power, + self.emoji, + self.cliphist, + self.todo, + self.bluetooth, + self.sh, + ]: + widget.remove_style_class("open") + if widget == self.wallpapers: + self.wallpapers.viewport.hide() + self.wallpapers.viewport.set_property("name", None) + + if widget == self.emoji and hasattr(widget, "viewport") and widget.viewport: + widget.viewport.hide() + + if ( + widget == self.cliphist + and hasattr(widget, "viewport") + and widget.viewport + ): + widget.viewport.hide() + + if widget == self.todo and hasattr(widget, "viewport") and widget.viewport: + widget.viewport.hide() + + if widget == self.bluetooth and widget.viewport: + widget.viewport.hide() + widget.viewport.children = [] + widget.is_active = False + + if widget == self.sh and widget.viewport: + widget.viewport.hide() + + for style in [ + "launcher", + "wallpapers", + "power", + "emoji", + "cliphist", + "todo", + "bluetooth", + "sh", + ]: + self.stack.remove_style_class(style) + + self.stack.set_visible_child(self.launcher) + + return True + + def open(self, widget): + self.set_keyboard_mode("exclusive") + self.show() + + widgets = { + "launcher": self.launcher, + "wallpapers": self.wallpapers, + "power": self.power, + "emoji": self.emoji, + "cliphist": self.cliphist, + "todo": self.todo, + "bluetooth": self.bluetooth, + "sh": self.sh, + } + + for style in widgets.keys(): + self.stack.remove_style_class(style) + 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() + self.launcher.search_entry.set_text("") + self.launcher.search_entry.grab_focus() + + elif widget == "wallpapers": + self.wallpapers.search_entry.set_text("") + self.wallpapers.search_entry.grab_focus() + self.wallpapers.viewport.show() + self.wallpapers.viewport.set_property("name", "wallpaper-icons") + + elif widget == "emoji": + self.emoji.open_launcher() + self.emoji.search_entry.set_text("") + self.emoji.search_entry.grab_focus() + + elif widget == "cliphist": + self.cliphist.open_launcher() + self.cliphist.search_entry.set_text("") + self.cliphist.search_entry.grab_focus() + + elif widget == "todo": + self.todo.open_launcher() + self.todo.todo_entry.set_text("") + self.todo.todo_entry.grab_focus() + + elif widget == "bluetooth": + self.bluetooth.open_launcher() + self.bluetooth.search_entry.set_text("") + self.bluetooth.search_entry.grab_focus() + self.bluetooth.device_manager.arrange_viewport() + + elif widget == "sh": + self.sh.open_launcher() + self.sh.search_entry.set_text("") + self.sh.search_entry.grab_focus() + + else: + if hasattr(self.wallpapers, "viewport"): + self.wallpapers.viewport.hide() + self.wallpapers.viewport.set_property("name", None) diff --git a/config/karya/modules/launcher/launcher.py b/config/modus/modules/launcher/launcher.py similarity index 81% rename from config/karya/modules/launcher/launcher.py rename to config/modus/modules/launcher/launcher.py index 010986ed..eb2312b5 100644 --- a/config/karya/modules/launcher/launcher.py +++ b/config/modus/modules/launcher/launcher.py @@ -32,12 +32,6 @@ class Launcher(Window): self.bluetooth = BluetoothManager() self.sh = Sh() - self._emoji_viewport = None - self._cliphist_viewport = None - self._todo_viewport = None - self._bluetooth_viewport = None - self._sh_viewport = None - self.stack = Stack( name="launcher-content", v_expand=True, @@ -59,8 +53,9 @@ class Launcher(Window): self.launcher_box = CenterBox( name="launcher", orientation="v", - start_children=self.stack, + # start_children=self.stack, ) + self.launcher_box.add(self.stack) # Dynamically add only the stack self.add(self.launcher_box) self.show_all() @@ -71,8 +66,6 @@ class Launcher(Window): def close(self): self.set_keyboard_mode("none") self.hide() - if self.bluetooth.is_active: - self.bluetooth.stop_device_polling() for widget in [ self.launcher, @@ -103,13 +96,11 @@ class Launcher(Window): if widget == self.bluetooth and widget.viewport: widget.viewport.hide() - widget.viewport.children = [] - widget.is_active = False if widget == self.sh and widget.viewport: widget.viewport.hide() - style_classes = [ + for style in [ "launcher", "wallpapers", "power", @@ -118,12 +109,8 @@ class Launcher(Window): "todo", "bluetooth", "sh", - ] - 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) - - self.stack.set_visible_child(self.launcher) + ]: + self.stack.remove_style_class(style) return True @@ -142,17 +129,18 @@ 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.hide() + for style in widgets.keys(): + self.stack.remove_style_class(style) if widget in widgets: self.stack.get_style_context().add_class(widget) self.stack.set_visible_child(widgets[widget]) + widgets[widget].show() + + if widget != "launcher": + self.launcher.hide() if widget == "launcher": self.launcher.open_launcher() @@ -190,8 +178,3 @@ class Launcher(Window): self.sh.open_launcher() self.sh.search_entry.set_text("") self.sh.search_entry.grab_focus() - - else: - if hasattr(self.wallpapers, "viewport"): - self.wallpapers.viewport.hide() - self.wallpapers.viewport.set_property("name", None) diff --git a/config/karya/modules/notification_popup.py b/config/modus/modules/notification_popup.py similarity index 100% rename from config/karya/modules/notification_popup.py rename to config/modus/modules/notification_popup.py diff --git a/config/karya/modules/osd.py b/config/modus/modules/osd.py similarity index 100% rename from config/karya/modules/osd.py rename to config/modus/modules/osd.py diff --git a/config/karya/services/__init__.py b/config/modus/services/__init__.py similarity index 100% rename from config/karya/services/__init__.py rename to config/modus/services/__init__.py diff --git a/config/karya/services/brightness.py b/config/modus/services/brightness.py similarity index 100% rename from config/karya/services/brightness.py rename to config/modus/services/brightness.py diff --git a/config/karya/services/screen_record.py b/config/modus/services/screen_record.py similarity index 100% rename from config/karya/services/screen_record.py rename to config/modus/services/screen_record.py diff --git a/config/karya/services/wifi.py b/config/modus/services/wifi.py similarity index 100% rename from config/karya/services/wifi.py rename to config/modus/services/wifi.py diff --git a/config/karya/snippets/__init__.py b/config/modus/snippets/__init__.py similarity index 100% rename from config/karya/snippets/__init__.py rename to config/modus/snippets/__init__.py diff --git a/config/karya/snippets/animator.py b/config/modus/snippets/animator.py similarity index 100% rename from config/karya/snippets/animator.py rename to config/modus/snippets/animator.py diff --git a/config/karya/snippets/config.py b/config/modus/snippets/config.py similarity index 94% rename from config/karya/snippets/config.py rename to config/modus/snippets/config.py index 7780604e..5a5e401e 100644 --- a/config/karya/snippets/config.py +++ b/config/modus/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}/karya/assets/config.json" + config_path = f"{home_dir}/dotfiles/modus/assets/config.json" with open(config_path, "r") as file: # Load JSON data into a Python dictionary diff --git a/config/karya/snippets/custom_image.py b/config/modus/snippets/custom_image.py similarity index 100% rename from config/karya/snippets/custom_image.py rename to config/modus/snippets/custom_image.py diff --git a/config/karya/snippets/icon.py b/config/modus/snippets/icon.py similarity index 100% rename from config/karya/snippets/icon.py rename to config/modus/snippets/icon.py diff --git a/config/modus/styles/applauncher.css b/config/modus/styles/applauncher.css new file mode 100644 index 00000000..30a37c4e --- /dev/null +++ b/config/modus/styles/applauncher.css @@ -0,0 +1,44 @@ +#launcher-app { + border-radius: 16px; + padding: 16px; + transition: padding 0.25s cubic-bezier(0.5, 0.25, 0, 1); + animation: loadSlot 0.5s ease; +} + +@keyframes loadSlot { + 0% { + opacity: 0; + } + + 100% { + opacity: 1; + } +} + +#launcher-app:hover image, +#launcher-app:focus imgae { + -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-icons { + animation: fade-in 0.25s ease-in-out; +} + +@keyframes fade-in { + from { + opacity: 0; + } + + to { + opacity: 1; + } +} diff --git a/config/karya/styles/bar.css b/config/modus/styles/bar.css similarity index 100% rename from config/karya/styles/bar.css rename to config/modus/styles/bar.css diff --git a/config/modus/styles/bluetooth.css b/config/modus/styles/bluetooth.css new file mode 100644 index 00000000..032e880b --- /dev/null +++ b/config/modus/styles/bluetooth.css @@ -0,0 +1,10 @@ +#device-slot { + background-color: @suraceVariant; + border-radius: 5px; + padding: 8px; +} + +#device-slot:hover, +#device-slot:focus { + background-color: mix(@onSurface, @surface, 0.92); +} diff --git a/config/modus/styles/cliphist.css b/config/modus/styles/cliphist.css new file mode 100644 index 00000000..fffb40bc --- /dev/null +++ b/config/modus/styles/cliphist.css @@ -0,0 +1,30 @@ +#cliphist-launcher-box button#clip-img-item { + background-size: cover; + background-position: center; + background-repeat: no-repeat; + border-radius: 8px; + min-width: 70px; + min-height: 70px; +} + +#cliphist-launcher-box button#clip-img-item:hover, +#cliphist-launcher-box button#clip-img-item:focus { + box-shadow: 2px 2px 2px @primary; +} + +#cliphist-launcher-box button#clip-item { + border-radius: 11px; + background-color: transparent; + background-image: none; + box-shadow: none; + padding: 3px; +} + +#cliphist-launcher-box button#clip-item { + font-size: 24px; +} + +#cliphist-launcher-box button#clip-item:hover, +#cliphist-launcher-box button#clip-item:focus { + text-shadow: 2px 2px 2px @primary; +} diff --git a/config/modus/styles/dashboard.css b/config/modus/styles/dashboard.css new file mode 100644 index 00000000..e69de29b diff --git a/config/modus/styles/emoji.css b/config/modus/styles/emoji.css new file mode 100644 index 00000000..146ceec9 --- /dev/null +++ b/config/modus/styles/emoji.css @@ -0,0 +1,16 @@ +#emoji-launcher-box button#emoji-item { + border-radius: 11px; + background-color: transparent; + background-image: none; + box-shadow: none; + padding: 0px; +} + +#emoji-launcher-box button#emoji-item label { + font-size: 24px; +} + +#emoji-launcher-box button#emoji-item:hover, +#emoji-launcher-box button#emoji-item:focus { + text-shadow: 2px 2px 2px @primary; +} diff --git a/config/karya/styles/launcher.css b/config/modus/styles/launcher.css similarity index 100% rename from config/karya/styles/launcher.css rename to config/modus/styles/launcher.css diff --git a/config/karya/styles/main.css b/config/modus/styles/main.css similarity index 95% rename from config/karya/styles/main.css rename to config/modus/styles/main.css index 77fa29cd..06b8be9a 100644 --- a/config/karya/styles/main.css +++ b/config/modus/styles/main.css @@ -1,4 +1,4 @@ -@import url(../../../.cache/material/colors.css); +@import url(../../.cache/material/colors.css); @import "./bar.css"; @import "./notification.css"; @import "./osd.css"; diff --git a/config/karya/styles/notification.css b/config/modus/styles/notification.css similarity index 100% rename from config/karya/styles/notification.css rename to config/modus/styles/notification.css diff --git a/config/karya/styles/osd.css b/config/modus/styles/osd.css similarity index 100% rename from config/karya/styles/osd.css rename to config/modus/styles/osd.css diff --git a/config/modus/styles/powermenu.css b/config/modus/styles/powermenu.css new file mode 100644 index 00000000..ff981805 --- /dev/null +++ b/config/modus/styles/powermenu.css @@ -0,0 +1,26 @@ +#powermenu-button { + border-radius: 20px; + padding: 20px; +} + +#powermenu-button:hover, +#powermenu-button:focus { + background-color: mix(@onSurface, @surface, 0.8); +} + +#powermenu-button:hover label, +#powermenu-button:focus label { + color: @primary; +} + +#powermenu-button:active { + background-image: radial-gradient( + circle, + mix(@onSurfaceVariant, transparent, 0.7) 10%, + transparent 0% + ); +} + +#powermenu-button:active label { + color: @shadow; +} diff --git a/config/modus/styles/sh.css b/config/modus/styles/sh.css new file mode 100644 index 00000000..795fdf4e --- /dev/null +++ b/config/modus/styles/sh.css @@ -0,0 +1,15 @@ +#shell-command-launcher-box button#sh-item { + border-radius: 11px; + background-color: transparent; + background-image: none; + box-shadow: none; + padding: 0px; +} +#shell-command-launcher-box button#sh-item { + font-size: 24px; +} + +#shell-command-launcher-box button#sh-item:hover, +#shell-command-launcher-box button#sh-item:focus { + text-shadow: 2px 2px 2px @primary; +} diff --git a/config/modus/styles/todo.css b/config/modus/styles/todo.css new file mode 100644 index 00000000..b10f5635 --- /dev/null +++ b/config/modus/styles/todo.css @@ -0,0 +1,24 @@ +#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; +} diff --git a/config/modus/styles/wallpapers.css b/config/modus/styles/wallpapers.css new file mode 100644 index 00000000..90caf42b --- /dev/null +++ b/config/modus/styles/wallpapers.css @@ -0,0 +1,40 @@ +#wallpaper-icons { + animation: fade-in 0.25s ease-in-out; +} + +@keyframes fade-in { + from { + opacity: 0; + } + + to { + opacity: 1; + } +} + +#wallpaper-icons:selected { + 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/modus/styles/wifi.css b/config/modus/styles/wifi.css new file mode 100644 index 00000000..e69de29b -- 2.43.0 From 77770d47e252524319500d499d28f811717922c4 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 4 Feb 2025 19:33:35 +0545 Subject: [PATCH 29/38] updates --- .../launcher/components/applauncher.py | 172 +++++++-- .../launcher/components/bluetooth (copy 1).py | 295 -------------- .../modules/launcher/components/bluetooth.py | 360 +++++------------- .../modules/launcher/components/cliphist.py | 4 +- .../modules/launcher/components/emoji.py | 3 +- .../modules/launcher/components/power.py | 4 +- .../modus/modules/launcher/components/sh.py | 3 +- .../modules/launcher/components/wallpapers.py | 123 +++--- .../modus/modules/launcher/components/wifi.py | 0 .../modules/launcher/launcher (copy 1).py | 132 ------- .../modules/launcher/launcher (copy 2).py | 194 ---------- config/modus/modules/launcher/launcher.py | 51 +-- config/modus/styles/bar.css | 1 + config/modus/styles/dashboard.css | 0 config/modus/styles/launcher.css | 54 ++- config/modus/styles/main.css | 2 +- config/modus/styles/wifi.css | 0 17 files changed, 382 insertions(+), 1016 deletions(-) delete mode 100644 config/modus/modules/launcher/components/bluetooth (copy 1).py delete mode 100644 config/modus/modules/launcher/components/wifi.py delete mode 100644 config/modus/modules/launcher/launcher (copy 1).py delete mode 100644 config/modus/modules/launcher/launcher (copy 2).py delete mode 100644 config/modus/styles/dashboard.css delete mode 100644 config/modus/styles/wifi.css diff --git a/config/modus/modules/launcher/components/applauncher.py b/config/modus/modules/launcher/components/applauncher.py index a51bd41e..4e755ae4 100644 --- a/config/modus/modules/launcher/components/applauncher.py +++ b/config/modus/modules/launcher/components/applauncher.py @@ -6,8 +6,8 @@ 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, read_config +from gi.repository import GLib, Gdk +from snippets import read_config from fabric.widgets.image import Image @@ -19,6 +19,10 @@ class AppLauncher(Box): all_visible=False, **kwargs, ) + + self.launcher = kwargs["launcher"] + self.selected_index = -1 + self._arranger_handler: int = 0 self._all_apps = get_desktop_applications() self.config = read_config() @@ -27,10 +31,11 @@ class AppLauncher(Box): self.search_entry = Entry( name="search-entry", h_expand=True, - notify_text=self.handle_search_input, + notify_text=lambda entry, *_: self.arrange_viewport(entry.get_text()), on_activate=lambda entry, *_: self.on_search_entry_activate( entry.get_text() ), + on_key_press_event=self.on_search_entry_key_press, # Handle key presses ) self.scrolled_window = ScrolledWindow( name="scrolled-window", @@ -57,65 +62,58 @@ class AppLauncher(Box): ) self.resize_viewport() + self.add(self.launcher_box) self.show_all() - def open_launcher(self): + def close_launcher(self, *_): self.viewport.children = [] + self.selected_index = -1 # Reset selection + self.launcher.close() + + def open_launcher(self): self._all_apps = get_desktop_applications() self.arrange_viewport() - self.search_entry.grab_focus() - - 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 modus '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 modus '{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 + self.show_all() def arrange_viewport(self, query: str = ""): remove_handler(self._arranger_handler) if self._arranger_handler else None self.viewport.children = [] + self.selected_index = -1 if not query.strip(): return False filtered_apps = iter( - [ - app - for app in self._all_apps - if query.casefold() - in ( - (app.display_name or "") - + (" " + app.name + " ") - + (app.generic_name or "") - ).casefold() - ][:6] + sorted( + [ + app + for app in self._all_apps + if query.casefold() + in ( + (app.display_name or "") + + (" " + app.name + " ") + + (app.generic_name or "") + ).casefold() + ][:6], + key=lambda app: (app.display_name or "").casefold(), + ) ) should_resize = operator.length_hint(filtered_apps) == len(self._all_apps) self._arranger_handler = idle_add( - lambda *args: self.add_next_application(*args) - or (self.resize_viewport() if should_resize else False), + lambda apps_iter: self.add_next_application(apps_iter) + or self.handle_arrange_complete(should_resize, query), filtered_apps, pin=True, ) + def handle_arrange_complete(self, should_resize, query): + if should_resize: + self.resize_viewport() + # Only auto-select first item if query exists + if query.strip() != "" and self.viewport.get_children(): + self.update_selection(0) return False def add_next_application(self, apps_iter: Iterator[DesktopApp]): @@ -125,8 +123,14 @@ class AppLauncher(Box): self.viewport.add(self.bake_application_slot(app)) return True + def resize_viewport(self): + self.scrolled_window.set_min_content_width( + self.viewport.get_allocation().width # type: ignore + ) + return False + def bake_application_slot(self, app: DesktopApp, **kwargs) -> Button: - return Button( + button = Button( name="launcher-app", child=Box( orientation="h", @@ -138,13 +142,99 @@ class AppLauncher(Box): ), 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, ) + return button + + def update_selection(self, new_index: int): + # Unselect current + if self.selected_index != -1 and self.selected_index < len( + self.viewport.get_children() + ): + current_button = self.viewport.get_children()[self.selected_index] + current_button.get_style_context().remove_class("selected") + # Select new + if new_index != -1 and new_index < len(self.viewport.get_children()): + new_button = self.viewport.get_children()[new_index] + new_button.get_style_context().add_class("selected") + self.selected_index = new_index + self.scroll_to_selected(new_button) + else: + self.selected_index = -1 + + def scroll_to_selected(self, button): + def scroll(): + adj = self.scrolled_window.get_vadjustment() + alloc = button.get_allocation() + if alloc.height == 0: + return False # Retry if allocation isn't ready + + y = alloc.y + height = alloc.height + page_size = adj.get_page_size() + current_value = adj.get_value() + + # Calculate visible boundaries + visible_top = current_value + visible_bottom = current_value + page_size + + if y < visible_top: + # Item above viewport - align to top + adj.set_value(y) + elif y + height > visible_bottom: + # Item below viewport - align to bottom + new_value = y + height - page_size + adj.set_value(new_value) + # No action if already fully visible + return False + + GLib.idle_add(scroll) + + def on_search_entry_activate(self, text): + commands = self.config.get("commands", {}) + + if text in commands: + command = commands[text] + eval(command, {"launcher": self.launcher}) # Dynamically execute command + else: + children = self.viewport.get_children() + if children: + # Only activate if we have selection or non-empty query + if text.strip() == "" and self.selected_index == -1: + return # Prevent accidental activation when empty + selected_index = self.selected_index if self.selected_index != -1 else 0 + if 0 <= selected_index < len(children): + children[selected_index].clicked() + + def on_search_entry_key_press(self, widget, event): + keyval = event.keyval + if keyval == Gdk.KEY_Down: + self.move_selection(1) + return True + elif keyval == Gdk.KEY_Up: + self.move_selection(-1) + return True + elif keyval == Gdk.KEY_Escape: + self.close_launcher() + return True + return False + + def move_selection(self, delta: int): + children = self.viewport.get_children() + if not children: + return + # Allow starting selection from nothing when empty + if self.selected_index == -1 and delta == 1: + new_index = 0 + else: + new_index = self.selected_index + delta + new_index = max(0, min(new_index, len(children) - 1)) + self.update_selection(new_index) diff --git a/config/modus/modules/launcher/components/bluetooth (copy 1).py b/config/modus/modules/launcher/components/bluetooth (copy 1).py deleted file mode 100644 index 6578101f..00000000 --- a/config/modus/modules/launcher/components/bluetooth (copy 1).py +++ /dev/null @@ -1,295 +0,0 @@ -from fabric.bluetooth import BluetoothClient, BluetoothDevice -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.label import Label -from fabric.widgets.scrolledwindow import ScrolledWindow -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): - super().__init__( - name="bluetooth-launcher", - all_visible=False, - visible=False, - **kwargs, - ) - - self._arranger_handler = None - self.device_manager = DeviceManager(self) - self.viewport = None - - self.search_entry = Entry( - name="search-entry", - 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( - child=MaterialIcon("sync"), - on_clicked=lambda *_: self.device_manager.bluetooth_client.toggle_scan(), - ), - ], - ) - - self.launcher_box = Box( - name="bluetooth-launcher-box", - spacing=10, - orientation="v", - h_expand=True, - children=[self.header_box], - ) - - self.add(self.launcher_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 - if not self.viewport: - self.viewport = Box(name="viewport", spacing=4, orientation="v") - self.scrolled_window = ScrolledWindow( - name="scrolled-window", - spacing=10, - h_scrollbar_policy="never", - v_scrollbar_policy="never", - child=self.viewport, - ) - self.launcher_box.add(self.scrolled_window) - - self.viewport.children = [] - self.device_manager.arrange_viewport() - - self.viewport.show() - self.search_entry.grab_focus() - - self.start_device_polling() - else: - self.device_manager.arrange_viewport() - - def handle_search_input(self, entry, text: str): - if isinstance(text, str): - self.device_manager.arrange_viewport(text) - - def start_device_polling(self): - if not self.polling_handler and self.is_active: - self.polling_handler = GLib.timeout_add( - 5000, self.device_manager.refresh_devices - ) - - def stop_device_polling(self): - if self.polling_handler: - GLib.source_remove(self.polling_handler) - self.polling_handler = None - - -class DeviceManager: - def __init__(self, launcher): - self.launcher = launcher - self.bluetooth_client = BluetoothClient( - on_device_added=self.on_device_added, - on_device_removed=self.on_device_removed, - ) - self._cached_devices = [] - - 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, *_): - self.bluetooth_client.toggle_power() - self.arrange_viewport() - - def on_device_added(self, client: BluetoothClient, address: str): - if device := client.get_device(address): - self._cached_devices.append(device) - self.refresh_viewport() - - def on_device_removed(self, client: BluetoothClient, address: str): - self._cached_devices = [ - device for device in self._cached_devices if device.address != address - ] - self.refresh_viewport() - - def refresh_viewport(self): - GLib.idle_add(self.arrange_viewport) - - def query_devices(self, query: str = "") -> list: - devices = [] - query = query.lower() - - for device in self._cached_devices: - name = device.name or "Unknown Device" - 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.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=device_slot_children, - ) - - def arrange_viewport(self, query: str = ""): - if not self.launcher.viewport: - return - - ( - remove_handler(self.launcher._arranger_handler) - if self.launcher._arranger_handler - else None - ) - self.launcher.viewport.children = [] - - 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)) - - if paired_devices := [d for d in filtered_devices if d.paired]: - for device in paired_devices: - self.launcher.viewport.add(self.bake_device_slot(device)) - - if not filtered_devices: - self.launcher.viewport.add( - Label( - label="No devices found" if not query else "No matching devices", - name="empty-label", - h_align="center", - ) - ) diff --git a/config/modus/modules/launcher/components/bluetooth.py b/config/modus/modules/launcher/components/bluetooth.py index 6500f897..ae1d18fd 100644 --- a/config/modus/modules/launcher/components/bluetooth.py +++ b/config/modus/modules/launcher/components/bluetooth.py @@ -1,290 +1,124 @@ -from fabric.bluetooth import BluetoothClient, BluetoothDevice 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.image import Image +from fabric.widgets.button import Button +from fabric.widgets.centerbox import CenterBox from fabric.widgets.scrolledwindow import ScrolledWindow -from gi.repository import GLib +from fabric.bluetooth import BluetoothClient, BluetoothDevice 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 BluetoothDeviceSlot(CenterBox): + def __init__(self, device: BluetoothDevice, **kwargs): + super().__init__(name="bluetooth-device", **kwargs) + self.device = device + self.device.connect("changed", self.on_changed) + self.device.connect( + "notify::closed", lambda *_: self.device.closed and self.destroy() + ) + + self.connection_icon = MaterialIcon("bluetooth_disabled", 12) + self.connect_button = Button( + name="bluetooth-connect", + label="Connect", + on_clicked=lambda *_: self.device.set_connecting(not self.device.connected), + ) + + self.start_children = [ + Box( + spacing=8, + children=[ + Image(icon_name=device.icon_name + "-symbolic", size=32), + Label(label=device.name), + self.connection_icon, + ], + ) + ] + self.end_children = self.connect_button + + self.device.emit("changed") # to update display status + + def on_changed(self, *_): + self.connection_icon.set_label( + "bluetooth" if self.device.connected else "bluetooth_disabled" + ) + + if self.device.connecting: + self.connect_button.set_label( + "Connecting..." if not self.device.connecting else "Disconnecting..." + ) + else: + self.connect_button.set_label( + "Connect" if not self.device.connected else "Disconnect" + ) + return -class BluetoothManager(Box): +class BluetoothConnections(Box): def __init__(self, **kwargs): super().__init__( - name="bluetooth-launcher", - all_visible=False, - visible=False, + name="bluetooth", + spacing=8, + orientation="vertical", **kwargs, ) - self._arranger_handler = None - self.device_manager = DeviceManager(self) - self.viewport = None + self.client = BluetoothClient(on_device_added=self.on_device_added) + self.toggle_icon = MaterialIcon("bluetooth_disabled") + self.scan_icon = MaterialIcon("bluetooth_searching") - self.search_entry = Entry( - name="search-entry", - h_expand=True, - notify_text=self.handle_search_input, - on_activate=self.handle_search_input, + self.scan_button = Button( + name="bluetooth-scan", + child=self.scan_icon, + tooltip_text="scan", + on_clicked=lambda *_: self.client.toggle_scan(), ) - self.toggle_button = Button( - on_clicked=lambda *_: self.device_manager.bluetooth_client.toggle_power() + name="bluetooth-toggle", + tooltip_text="bluetooth-toggle", + child=self.toggle_icon, + on_clicked=lambda *_: self.client.toggle_power(), ) - self.device_manager.bluetooth_client.connect( - "notify::enabled", self.update_toggle_button + self.client.connect( + "notify::enabled", + lambda *_: self.toggle_icon.set_label( + "bluetooth" if self.client.enabled else "bluetooth_disabled" + ), + ) + self.client.connect( + "notify::scanning", + lambda *_: self.scan_icon.set_label( + "Stop" if self.client.scanning else "bluetooth_searching" + ), ) - self.header_box = Box( - name="header-box", - spacing=10, - orientation="h", - children=[ - self.search_entry, - self.toggle_button, - Button( - child=MaterialIcon("sync"), - on_clicked=lambda *_: self.device_manager.bluetooth_client.toggle_scan(), - ), - ], - ) + self.paired_box = Box(spacing=2, orientation="vertical") + self.available_box = Box(spacing=2, orientation="vertical") - self.launcher_box = Box( - name="bluetooth-launcher-box", - spacing=10, - orientation="v", - h_expand=True, - children=[self.header_box], - ) + self.children = [ + CenterBox( + start_children=self.scan_button, + center_children=Label(name="bluetooth-text", label="Bluetooth Devices"), + end_children=self.toggle_button, + ), + Label(name="bluetooth-text", label="Paired"), + ScrolledWindow(min_content_size=(-1, -1), child=self.paired_box), + Label(name="bluetooth-text", label="Available"), + ScrolledWindow(min_content_size=(-1, -1), child=self.available_box), + ] - self.add(self.launcher_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.viewport: - self.viewport = Box(name="viewport", spacing=4, orientation="v") - self.scrolled_window = ScrolledWindow( - name="scrolled-window", - spacing=10, - h_scrollbar_policy="never", - child=self.viewport, - ) - self.launcher_box.add(self.scrolled_window) - - self.viewport.children = [] - self.device_manager.arrange_viewport() - - self.viewport.show() - self.search_entry.grab_focus() - - self.start_device_polling() - - def handle_search_input(self, entry, text: str): - if isinstance(text, str): - self.device_manager.arrange_viewport(text) - - def start_device_polling(self): - GLib.timeout_add(5000, self.device_manager.refresh_devices) - - -class DeviceManager: - def __init__(self, launcher): - self.launcher = launcher - self.bluetooth_client = BluetoothClient( - on_device_added=self.on_device_added, - on_device_removed=self.on_device_removed, - ) - self._cached_devices = [] - - def refresh_devices(self, *_): - if not sel.bluetooth_client.enabled: - return True - if self.launcher.viewport: # Only refresh devices if Bluetooth section is open - self.arrange_viewport() - return True - - def toggle_bluetooth(self, *_): - self.bluetooth_client.toggle_power() - self.arrange_viewport() + # to run notify closures thus display the status + # without having to wait until an actual change + self.client.notify("scanning") + self.client.notify("enabled") def on_device_added(self, client: BluetoothClient, address: str): - if device := client.get_device(address): - self._cached_devices.append(device) - self.refresh_viewport() - - def on_device_removed(self, client: BluetoothClient, address: str): - self._cached_devices = [ - device for device in self._cached_devices if device.address != address - ] - self.refresh_viewport() - - def refresh_viewport(self): - GLib.idle_add(self.arrange_viewport) - - def query_devices(self, query: str = "") -> list: - if not self.bluetooth_client.enabled: # Skip querying if Bluetooth is off - return [] # No devices to show when Bluetooth is off - devices = [] - query = query.lower() - - for device in self._cached_devices: - name = device.name or "Unknown Device" - 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.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=device_slot_children, - ) - - def arrange_viewport(self, query: str = ""): - if not self.launcher.viewport: + if not (device := client.get_device(address)): return + slot = BluetoothDeviceSlot(device) - # If Bluetooth is off, show a message that Bluetooth is off - if not self.bluetooth_client.enabled: - self.launcher.viewport.children = [] # Clear any existing content - self.launcher.viewport.add( - Label( - label="Bluetooth is off", # Display "Bluetooth is off" - h_align="center", - ) - ) - return - self.launcher.viewport.children = [] + if device.paired: + return self.paired_box.add(slot) + return self.available_box.add(slot) - 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)) - - if paired_devices := [d for d in filtered_devices if d.paired]: - for device in paired_devices: - self.launcher.viewport.add(self.bake_device_slot(device)) - - if not filtered_devices: - self.launcher.viewport.add( - Label( - label="No devices found" if not query else "No matching devices", - name="empty-label", - h_align="center", - ) - ) diff --git a/config/modus/modules/launcher/components/cliphist.py b/config/modus/modules/launcher/components/cliphist.py index 2d7e8b9c..751369fa 100644 --- a/config/modus/modules/launcher/components/cliphist.py +++ b/config/modus/modules/launcher/components/cliphist.py @@ -25,6 +25,7 @@ class Cliphist(Box): self._arranger_handler = 0 self.cliphist_manager = CliphistManager(self) self.viewport = None + self.launcher = kwargs["launcher"] self.search_entry = Entry( name="search-entry", @@ -80,8 +81,7 @@ class Cliphist(Box): def close_launcher(self): """Closes the clipboard history launcher and clears viewport.""" - self.viewport.children = [] - GLib.spawn_command_line_async("fabric-cli exec modus 'launcher.close()'") + self.launcher.close() def handle_search_input(self, text: str): """Handles search input to filter clipboard history.""" diff --git a/config/modus/modules/launcher/components/emoji.py b/config/modus/modules/launcher/components/emoji.py index 75537968..d7b83edf 100644 --- a/config/modus/modules/launcher/components/emoji.py +++ b/config/modus/modules/launcher/components/emoji.py @@ -22,6 +22,7 @@ class Emoji(Box): **kwargs, ) + self.launcher = kwargs["launcher"] self._arranger_handler: int = 0 self.emoji_manager = EmojiManager(self) self.viewport = None @@ -70,7 +71,7 @@ class Emoji(Box): self.search_entry.grab_focus() def close_launcher(self): - GLib.spawn_command_line_async("fabric-cli exec modus'launcher.close()'") + self.launcher.close() def handle_search_input(self, text: str): self.emoji_manager.arrange_viewport(text) diff --git a/config/modus/modules/launcher/components/power.py b/config/modus/modules/launcher/components/power.py index a2016058..e00efa13 100644 --- a/config/modus/modules/launcher/components/power.py +++ b/config/modus/modules/launcher/components/power.py @@ -19,6 +19,8 @@ class PowerMenu(Box): **kwargs, ) + self.launcher = kwargs["launcher"] + self.btn_lock = Button( name="powermenu-button", child=MaterialIcon("lock", 45), @@ -63,7 +65,7 @@ class PowerMenu(Box): self.show_all() def close_menu(self): - GLib.spawn_command_line_async("fabric-cli exec modus 'launcher.close()'") + self.launcher.close() def lock(self, *_): GLib.spawn_command_line_async("hyprlock --immediate") diff --git a/config/modus/modules/launcher/components/sh.py b/config/modus/modules/launcher/components/sh.py index 627a0ace..f2ca7024 100644 --- a/config/modus/modules/launcher/components/sh.py +++ b/config/modus/modules/launcher/components/sh.py @@ -23,6 +23,7 @@ class Sh(Box): **kwargs, ) + self.launcher = kwargs["launcher"] self._arranger_handler: int = 0 self.shell_command_manager = ShellCommandManager(self) self.viewport = None @@ -127,7 +128,7 @@ class ShellCommandManager: viewport.add(button) def close_menu(self): - GLib.spawn_command_line_async("fabric-cli exec modus 'launcher.close()'") + self.launcher.close() def execute_command(self, cmd: str): try: diff --git a/config/modus/modules/launcher/components/wallpapers.py b/config/modus/modules/launcher/components/wallpapers.py index bf245cce..61820c05 100644 --- a/config/modus/modules/launcher/components/wallpapers.py +++ b/config/modus/modules/launcher/components/wallpapers.py @@ -1,14 +1,16 @@ import hashlib import json import os - +from PIL import Image from fabric.widgets.box import Box from fabric.widgets.button import Button from fabric.widgets.entry import Entry from fabric.widgets.scrolledwindow import ScrolledWindow -from gi.repository import GdkPixbuf, GLib, Gtk +from gi.repository import GdkPixbuf, GLib, Gtk, Gio from snippets import MaterialIcon from fabric.utils import exec_shell_command, get_relative_path +import concurrent.futures +from concurrent.futures import ThreadPoolExecutor class WallpaperSelector(Box): @@ -29,22 +31,16 @@ class WallpaperSelector(Box): def __init__(self, **kwargs): super().__init__(name="wallpapers", spacing=4, orientation="v", **kwargs) + self.launcher = kwargs["launcher"] self.wallpapers_dir = os.path.expanduser("~/Pictures/wallpapers") os.makedirs(self.CACHE_DIR, exist_ok=True) self.files = [f for f in os.listdir(self.wallpapers_dir) if self._is_image(f)] self.thumbnails = [] + self.thumbnail_queue = [] + self.executor = ThreadPoolExecutor(max_workers=4) # Shared executor - self._init_viewport() - self._init_search_entry() - self._init_scheme_dropdown() - self._init_layout() - - self._start_thumbnail_thread() - self.show_all() - - def _init_viewport(self): self.viewport = Gtk.IconView() self.viewport.set_model(Gtk.ListStore(GdkPixbuf.Pixbuf, str)) self.viewport.set_pixbuf_column(0) @@ -60,14 +56,12 @@ class WallpaperSelector(Box): child=self.viewport, ) - def _init_search_entry(self): self.search_entry = Entry( name="search-entry", h_expand=True, notify_text=lambda entry, *_: self.arrange_viewport(entry.get_text()), ) - def _init_scheme_dropdown(self): self.scheme_dropdown = Gtk.ComboBoxText() self.scheme_dropdown.set_name("scheme-dropdown") self.scheme_dropdown.set_tooltip_text("Select color scheme") @@ -94,7 +88,6 @@ class WallpaperSelector(Box): ], ) - def _init_layout(self): self.header_box = Box( name="header-box", spacing=10, @@ -104,6 +97,45 @@ class WallpaperSelector(Box): self.add(self.header_box) self.add(self.scrolled_window) + self._start_thumbnail_thread() + self.setup_file_monitor() + self.show_all() + + def setup_file_monitor(self): + gfile = Gio.File.new_for_path(self.wallpapers_dir) + self.file_monitor = gfile.monitor_directory(Gio.FileMonitorFlags.NONE, None) + self.file_monitor.connect("changed", self.on_directory_changed) + + def on_directory_changed(self, monitor, file, other_file, event_type): + file_name = file.get_basename() + if event_type == Gio.FileMonitorEvent.DELETED: + if file_name in self.files: + self.files.remove(file_name) + cache_path = self._get_cache_path(file_name) + if os.path.exists(cache_path): + try: + os.remove(cache_path) + except Exception as e: + print(f"Error deleting cache {cache_path}: {e}") + self.thumbnails = [(p, n) for p, n in self.thumbnails if n != file_name] + GLib.idle_add(self.arrange_viewport, self.search_entry.get_text()) + elif event_type == Gio.FileMonitorEvent.CREATED: + if self._is_image(file_name) and file_name not in self.files: + self.files.append(file_name) + self.files.sort() + self.executor.submit(self._process_file, file_name) + elif event_type == Gio.FileMonitorEvent.CHANGED: + if self._is_image(file_name) and file_name in self.files: + cache_path = self._get_cache_path(file_name) + if os.path.exists(cache_path): + try: + os.remove(cache_path) + except Exception as e: + print(f"Error deleting cache for changed file {file_name}: {e}") + self.executor.submit(self._process_file, file_name) + + def close_selector(self): + self.launcher.close() def arrange_viewport(self, query: str = ""): self.viewport.get_model().clear() @@ -179,42 +211,41 @@ class WallpaperSelector(Box): thread = GLib.Thread.new("thumbnail-loader", self._preload_thumbnails, None) def _preload_thumbnails(self, _data): - for file_name in sorted(self.files): - full_path = os.path.join(self.wallpapers_dir, file_name) - cache_path = self._get_cache_path(file_name) + futures = [ + self.executor.submit(self._process_file, file_name) + for file_name in self.files + ] + concurrent.futures.wait(futures) + GLib.idle_add(self._process_batch) - if not os.path.exists(cache_path): - pixbuf = self._create_thumbnail(full_path) - if pixbuf: - pixbuf.savev(cache_path, "png", [], []) - else: + def _process_file(self, file_name): + full_path = os.path.join(self.wallpapers_dir, file_name) + cache_path = self._get_cache_path(file_name) + if not os.path.exists(cache_path): + try: + with Image.open(full_path) as img: + img.thumbnail((96, 96), Image.Resampling.BILINEAR) + img.save(cache_path, "PNG") + except Exception as e: + print(f"Error processing {file_name}: {e}") + return + self.thumbnail_queue.append((cache_path, file_name)) + GLib.idle_add(self._process_batch) + + def _process_batch(self): + batch = self.thumbnail_queue[:10] + del self.thumbnail_queue[:10] + for cache_path, file_name in batch: + try: pixbuf = GdkPixbuf.Pixbuf.new_from_file(cache_path) - - if pixbuf: - GLib.idle_add(self._add_thumbnail_to_view, pixbuf, file_name) - - def _add_thumbnail_to_view(self, pixbuf, file_name): - self.thumbnails.append((pixbuf, file_name)) - self.viewport.get_model().append([pixbuf, file_name]) + self.thumbnails.append((pixbuf, file_name)) + self.viewport.get_model().append([pixbuf, file_name]) + except Exception as e: + print(f"Error loading thumbnail {cache_path}: {e}") + if self.thumbnail_queue: + GLib.idle_add(self._process_batch) return False - def _create_thumbnail(self, image_path: str, thumbnail_size=96): - try: - pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_path) - width, height = pixbuf.get_width(), pixbuf.get_height() - if width > height: - new_width = thumbnail_size - new_height = int(height * (thumbnail_size / width)) - else: - new_height = thumbnail_size - new_width = int(width * (thumbnail_size / height)) - return pixbuf.scale_simple( - new_width, new_height, GdkPixbuf.InterpType.BILINEAR - ) - except Exception as e: - print(f"Error creating thumbnail for {image_path}: {e}") - return None - def _get_cache_path(self, file_name: str) -> str: file_hash = hashlib.md5(file_name.encode("utf-8")).hexdigest() return os.path.join(self.CACHE_DIR, f"{file_hash}.png") diff --git a/config/modus/modules/launcher/components/wifi.py b/config/modus/modules/launcher/components/wifi.py deleted file mode 100644 index e69de29b..00000000 diff --git a/config/modus/modules/launcher/launcher (copy 1).py b/config/modus/modules/launcher/launcher (copy 1).py deleted file mode 100644 index fdcbf8c7..00000000 --- a/config/modus/modules/launcher/launcher (copy 1).py +++ /dev/null @@ -1,132 +0,0 @@ -from fabric.widgets.centerbox import CenterBox -from fabric.widgets.wayland import WaylandWindow as Window -from modules.launcher.components import ( - AppLauncher, - BluetoothManager, - Cliphist, - Emoji, - PowerMenu, - Sh, - TodoManager, - WallpaperSelector, -) - - -class Launcher(Window): - def __init__(self, **kwargs): - super().__init__( - layer="top", - anchor="center", - visible=False, - all_visible=False, - **kwargs, - ) - - self.launcher = AppLauncher() - self.wallpapers = WallpaperSelector() - self.power = PowerMenu() - self.emoji = Emoji() - self.cliphist = Cliphist() - self.todo = TodoManager() - self.bluetooth = BluetoothManager() - self.sh = Sh() - - self.widgets = { - "launcher": self.launcher, - "wallpapers": self.wallpapers, - "power": self.power, - "emoji": self.emoji, - "cliphist": self.cliphist, - "todo": self.todo, - "bluetooth": self.bluetooth, - "sh": self.sh, - } - - self.launcher_box = CenterBox( - name="launcher", - orientation="v", - start_children=[ - self.launcher, - self.wallpapers, - self.power, - self.emoji, - self.cliphist, - self.todo, - self.bluetooth, - self.sh, - ], - ) - - self.add(self.launcher_box) - self.show_all() - self.hide() - self.add_keybinding("Escape", lambda *_: self.close()) - - def close(self): - self.set_keyboard_mode("none") - self.hide() - - if self.bluetooth.is_active: - self.bluetooth.stop_device_polling() - - for widget in self.widgets.values(): - widget.hide() - - # if hasattr(widget, "viewport") and widget.viewport: - # widget.viewport.hide() - - return True - - def open(self, widget): - if widget not in self.widgets: - return - - self.set_keyboard_mode("exclusive") - self.show() - - for w in self.widgets.values(): - w.hide() - w.remove_style_class("open") - - self.widgets[widget].show() - - if widget == "launcher": - self.launcher.open_launcher() - self.launcher.search_entry.set_text("") - self.launcher.search_entry.grab_focus() - - elif widget == "wallpapers": - self.wallpapers.search_entry.set_text("") - self.wallpapers.search_entry.grab_focus() - self.wallpapers.viewport.show() - self.wallpapers.viewport.set_property("name", "wallpaper-icons") - - elif widget == "emoji": - self.emoji.open_launcher() - self.emoji.search_entry.set_text("") - self.emoji.search_entry.grab_focus() - - elif widget == "cliphist": - self.cliphist.open_launcher() - self.cliphist.search_entry.set_text("") - self.cliphist.search_entry.grab_focus() - - elif widget == "todo": - self.todo.open_launcher() - self.todo.todo_entry.set_text("") - self.todo.todo_entry.grab_focus() - - elif widget == "bluetooth": - self.bluetooth.open_launcher() - self.bluetooth.search_entry.set_text("") - self.bluetooth.search_entry.grab_focus() - self.bluetooth.device_manager.arrange_viewport() - - elif widget == "sh": - self.sh.open_launcher() - self.sh.search_entry.set_text("") - self.sh.search_entry.grab_focus() - else: - if hasattr(self.wallpapers, "viewport"): - self.wallpapers.viewport.hide() - self.wallpapers.viewport.set_property("name", None) diff --git a/config/modus/modules/launcher/launcher (copy 2).py b/config/modus/modules/launcher/launcher (copy 2).py deleted file mode 100644 index 21582890..00000000 --- a/config/modus/modules/launcher/launcher (copy 2).py +++ /dev/null @@ -1,194 +0,0 @@ -from fabric.widgets.centerbox import CenterBox -from fabric.widgets.stack import Stack -from fabric.widgets.wayland import WaylandWindow as Window -from modules.launcher.components import ( - AppLauncher, - BluetoothManager, - Cliphist, - Emoji, - PowerMenu, - Sh, - TodoManager, - WallpaperSelector, -) - - -class Launcher(Window): - def __init__(self, **kwargs): - super().__init__( - layer="top", - anchor="center", - visible=False, - all_visible=False, - **kwargs, - ) - - self.launcher = AppLauncher() - self.wallpapers = WallpaperSelector() - self.power = PowerMenu() - self.emoji = Emoji() - self.cliphist = Cliphist() - self.todo = TodoManager() - self.bluetooth = BluetoothManager() - self.sh = Sh() - - self._emoji_viewport = None - self._cliphist_viewport = None - self._todo_viewport = None - self._bluetooth_viewport = None - self._sh_viewport = None - - self.stack = Stack( - name="launcher-content", - v_expand=True, - h_expand=True, - transition_type="crossfade", - transition_duration=250, - children=[ - self.launcher, - self.wallpapers, - self.power, - self.emoji, - self.cliphist, - self.todo, - self.bluetooth, - self.sh, - ], - ) - - self.launcher_box = CenterBox( - name="launcher", - orientation="v", - start_children=self.stack, - ) - - self.add(self.launcher_box) - self.show_all() - self.hide() - self.wallpapers.viewport.hide() - self.add_keybinding("Escape", lambda *_: self.close()) - - def close(self): - self.set_keyboard_mode("none") - self.hide() - if self.bluetooth.is_active: - self.bluetooth.stop_device_polling() - - for widget in [ - self.launcher, - self.wallpapers, - self.power, - self.emoji, - self.cliphist, - self.todo, - self.bluetooth, - self.sh, - ]: - widget.remove_style_class("open") - if widget == self.wallpapers: - self.wallpapers.viewport.hide() - self.wallpapers.viewport.set_property("name", None) - - if widget == self.emoji and hasattr(widget, "viewport") and widget.viewport: - widget.viewport.hide() - - if ( - widget == self.cliphist - and hasattr(widget, "viewport") - and widget.viewport - ): - widget.viewport.hide() - - if widget == self.todo and hasattr(widget, "viewport") and widget.viewport: - widget.viewport.hide() - - if widget == self.bluetooth and widget.viewport: - widget.viewport.hide() - widget.viewport.children = [] - widget.is_active = False - - if widget == self.sh and widget.viewport: - widget.viewport.hide() - - for style in [ - "launcher", - "wallpapers", - "power", - "emoji", - "cliphist", - "todo", - "bluetooth", - "sh", - ]: - self.stack.remove_style_class(style) - - self.stack.set_visible_child(self.launcher) - - return True - - def open(self, widget): - self.set_keyboard_mode("exclusive") - self.show() - - widgets = { - "launcher": self.launcher, - "wallpapers": self.wallpapers, - "power": self.power, - "emoji": self.emoji, - "cliphist": self.cliphist, - "todo": self.todo, - "bluetooth": self.bluetooth, - "sh": self.sh, - } - - for style in widgets.keys(): - self.stack.remove_style_class(style) - 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() - self.launcher.search_entry.set_text("") - self.launcher.search_entry.grab_focus() - - elif widget == "wallpapers": - self.wallpapers.search_entry.set_text("") - self.wallpapers.search_entry.grab_focus() - self.wallpapers.viewport.show() - self.wallpapers.viewport.set_property("name", "wallpaper-icons") - - elif widget == "emoji": - self.emoji.open_launcher() - self.emoji.search_entry.set_text("") - self.emoji.search_entry.grab_focus() - - elif widget == "cliphist": - self.cliphist.open_launcher() - self.cliphist.search_entry.set_text("") - self.cliphist.search_entry.grab_focus() - - elif widget == "todo": - self.todo.open_launcher() - self.todo.todo_entry.set_text("") - self.todo.todo_entry.grab_focus() - - elif widget == "bluetooth": - self.bluetooth.open_launcher() - self.bluetooth.search_entry.set_text("") - self.bluetooth.search_entry.grab_focus() - self.bluetooth.device_manager.arrange_viewport() - - elif widget == "sh": - self.sh.open_launcher() - self.sh.search_entry.set_text("") - self.sh.search_entry.grab_focus() - - else: - if hasattr(self.wallpapers, "viewport"): - self.wallpapers.viewport.hide() - self.wallpapers.viewport.set_property("name", None) diff --git a/config/modus/modules/launcher/launcher.py b/config/modus/modules/launcher/launcher.py index eb2312b5..86ee0798 100644 --- a/config/modus/modules/launcher/launcher.py +++ b/config/modus/modules/launcher/launcher.py @@ -3,7 +3,7 @@ from fabric.widgets.stack import Stack from fabric.widgets.wayland import WaylandWindow as Window from modules.launcher.components import ( AppLauncher, - BluetoothManager, + BluetoothConnections, Cliphist, Emoji, PowerMenu, @@ -23,14 +23,14 @@ class Launcher(Window): **kwargs, ) - self.launcher = AppLauncher() - self.wallpapers = WallpaperSelector() - self.power = PowerMenu() - self.emoji = Emoji() - self.cliphist = Cliphist() + self.launcher = AppLauncher(launcher=self) + self.wallpapers = WallpaperSelector(launcher=self) + self.power = PowerMenu(launcher=self) + self.emoji = Emoji(launcher=self) + self.cliphist = Cliphist(launcher=self) self.todo = TodoManager() - self.bluetooth = BluetoothManager() - self.sh = Sh() + self.bluetooth = BluetoothConnections() + self.sh = Sh(launcher=self) self.stack = Stack( name="launcher-content", @@ -53,9 +53,8 @@ class Launcher(Window): self.launcher_box = CenterBox( name="launcher", orientation="v", - # start_children=self.stack, + start_children=self.stack, ) - self.launcher_box.add(self.stack) # Dynamically add only the stack self.add(self.launcher_box) self.show_all() @@ -81,23 +80,7 @@ class Launcher(Window): self.wallpapers.viewport.hide() self.wallpapers.viewport.set_property("name", None) - if widget == self.emoji and hasattr(widget, "viewport") and widget.viewport: - widget.viewport.hide() - - if ( - widget == self.cliphist - and hasattr(widget, "viewport") - and widget.viewport - ): - widget.viewport.hide() - - if widget == self.todo and hasattr(widget, "viewport") and widget.viewport: - widget.viewport.hide() - - if widget == self.bluetooth and widget.viewport: - widget.viewport.hide() - - if widget == self.sh and widget.viewport: + if hasattr(widget, "viewport") and widget.viewport: widget.viewport.hide() for style in [ @@ -139,8 +122,12 @@ class Launcher(Window): self.stack.set_visible_child(widgets[widget]) widgets[widget].show() - if widget != "launcher": - self.launcher.hide() + # if widget != "launcher": + # self.launcher.hide() + + if widget != "wallpapers": + self.wallpapers.viewport.hide() + self.wallpapers.viewport.set_property("name", None) if widget == "launcher": self.launcher.open_launcher() @@ -168,12 +155,6 @@ class Launcher(Window): self.todo.todo_entry.set_text("") self.todo.todo_entry.grab_focus() - elif widget == "bluetooth": - self.bluetooth.open_launcher() - self.bluetooth.search_entry.set_text("") - self.bluetooth.search_entry.grab_focus() - self.bluetooth.device_manager.arrange_viewport() - elif widget == "sh": self.sh.open_launcher() self.sh.search_entry.set_text("") diff --git a/config/modus/styles/bar.css b/config/modus/styles/bar.css index 04f3be6e..361e6866 100644 --- a/config/modus/styles/bar.css +++ b/config/modus/styles/bar.css @@ -27,6 +27,7 @@ opacity: 0; padding: 3px; margin-bottom: -52px; + transition: all 0.5s cubic-bezier(0.5, 0.25, 0, 1); } /* diff --git a/config/modus/styles/dashboard.css b/config/modus/styles/dashboard.css deleted file mode 100644 index e69de29b..00000000 diff --git a/config/modus/styles/launcher.css b/config/modus/styles/launcher.css index 53509a7a..3d65caed 100644 --- a/config/modus/styles/launcher.css +++ b/config/modus/styles/launcher.css @@ -72,11 +72,17 @@ } #launcher-app:hover image, +#launcher-app:active image, +#launcher-app:selected image, +#launcher-app.selected image, #launcher-app:focus image { -gtk-icon-shadow: 2px 2px @primary; } #launcher-app:hover, +#launcher-app:active, +#launcher-app.selected, +#launcher-app:selected, #launcher-app:focus { text-shadow: 2pt 2pt 2pt @primary; } @@ -243,8 +249,48 @@ * ── bluetooth ───────────────────────────────────────────────────────── */ -#device-slot { - background-color: @suraceVariant; - border-radius: 5px; - padding: 8px; +#bluetooth-device { + background-color: @secondaryContainer; + border-radius: 16px; + padding: 4px; + margin-bottom: 4px; +} + +#bluetooth-scan, +#bluetooth-toggle { + background-color: @secondaryContainer; + color: @onSecondaryContainer; + margin: 11px; + margin-left: 0px; + min-width: 44px; + min-height: 44px; + border-radius: 100%; +} + +#bluetooth-scan:hover, +#bluetooth-toggle:hover { + background-color: @surfaceBright; +} + +#bluetooth-scan label, +#bluetooth-toggle label { + font-weight: bold; +} + +#bluetooth-text { + font-weight: bold; +} + +#bluetooth-connection { + font-size: 20px; +} + +#bluetooth-connect { + background-color: @shadow; + border-radius: 16px; + padding: 8px 16px; +} + +#bluetooth-connect:hover { + background-color: @surfaceBright; } diff --git a/config/modus/styles/main.css b/config/modus/styles/main.css index 06b8be9a..77fa29cd 100644 --- a/config/modus/styles/main.css +++ b/config/modus/styles/main.css @@ -1,4 +1,4 @@ -@import url(../../.cache/material/colors.css); +@import url(../../../.cache/material/colors.css); @import "./bar.css"; @import "./notification.css"; @import "./osd.css"; diff --git a/config/modus/styles/wifi.css b/config/modus/styles/wifi.css deleted file mode 100644 index e69de29b..00000000 -- 2.43.0 From 734e267a3a4d8e0f58f2186c0b5763b21248b410 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 4 Feb 2025 19:34:00 +0545 Subject: [PATCH 30/38] updates --- config/modus/assets/config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/modus/assets/config.json b/config/modus/assets/config.json index d03f2218..1a52b6f7 100644 --- a/config/modus/assets/config.json +++ b/config/modus/assets/config.json @@ -5,6 +5,7 @@ ":ch": "launcher.open(\"cliphist\")", ":td": "launcher.open(\"todo\")", ":bt": "launcher.open(\"bluetooth\")", - ":sh": "launcher.open(\"sh\")" + ":sh": "launcher.open(\"sh\")", + ":sh": "launcher.open(\"power\")" } } -- 2.43.0 From 97eb764aced2fc4756776e81a7ae4c96cc12156f Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 4 Feb 2025 19:38:59 +0545 Subject: [PATCH 31/38] fix: cores --- config/modus/styles/applauncher.css | 44 ----------------------------- config/modus/styles/bluetooth.css | 10 ------- config/modus/styles/cliphist.css | 30 -------------------- config/modus/styles/emoji.css | 16 ----------- config/modus/styles/powermenu.css | 26 ----------------- config/modus/styles/sh.css | 15 ---------- config/modus/styles/todo.css | 24 ---------------- config/modus/styles/wallpapers.css | 40 -------------------------- 8 files changed, 205 deletions(-) delete mode 100644 config/modus/styles/applauncher.css delete mode 100644 config/modus/styles/bluetooth.css delete mode 100644 config/modus/styles/cliphist.css delete mode 100644 config/modus/styles/emoji.css delete mode 100644 config/modus/styles/powermenu.css delete mode 100644 config/modus/styles/sh.css delete mode 100644 config/modus/styles/todo.css delete mode 100644 config/modus/styles/wallpapers.css diff --git a/config/modus/styles/applauncher.css b/config/modus/styles/applauncher.css deleted file mode 100644 index 30a37c4e..00000000 --- a/config/modus/styles/applauncher.css +++ /dev/null @@ -1,44 +0,0 @@ -#launcher-app { - border-radius: 16px; - padding: 16px; - transition: padding 0.25s cubic-bezier(0.5, 0.25, 0, 1); - animation: loadSlot 0.5s ease; -} - -@keyframes loadSlot { - 0% { - opacity: 0; - } - - 100% { - opacity: 1; - } -} - -#launcher-app:hover image, -#launcher-app:focus imgae { - -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-icons { - animation: fade-in 0.25s ease-in-out; -} - -@keyframes fade-in { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} diff --git a/config/modus/styles/bluetooth.css b/config/modus/styles/bluetooth.css deleted file mode 100644 index 032e880b..00000000 --- a/config/modus/styles/bluetooth.css +++ /dev/null @@ -1,10 +0,0 @@ -#device-slot { - background-color: @suraceVariant; - border-radius: 5px; - padding: 8px; -} - -#device-slot:hover, -#device-slot:focus { - background-color: mix(@onSurface, @surface, 0.92); -} diff --git a/config/modus/styles/cliphist.css b/config/modus/styles/cliphist.css deleted file mode 100644 index fffb40bc..00000000 --- a/config/modus/styles/cliphist.css +++ /dev/null @@ -1,30 +0,0 @@ -#cliphist-launcher-box button#clip-img-item { - background-size: cover; - background-position: center; - background-repeat: no-repeat; - border-radius: 8px; - min-width: 70px; - min-height: 70px; -} - -#cliphist-launcher-box button#clip-img-item:hover, -#cliphist-launcher-box button#clip-img-item:focus { - box-shadow: 2px 2px 2px @primary; -} - -#cliphist-launcher-box button#clip-item { - border-radius: 11px; - background-color: transparent; - background-image: none; - box-shadow: none; - padding: 3px; -} - -#cliphist-launcher-box button#clip-item { - font-size: 24px; -} - -#cliphist-launcher-box button#clip-item:hover, -#cliphist-launcher-box button#clip-item:focus { - text-shadow: 2px 2px 2px @primary; -} diff --git a/config/modus/styles/emoji.css b/config/modus/styles/emoji.css deleted file mode 100644 index 146ceec9..00000000 --- a/config/modus/styles/emoji.css +++ /dev/null @@ -1,16 +0,0 @@ -#emoji-launcher-box button#emoji-item { - border-radius: 11px; - background-color: transparent; - background-image: none; - box-shadow: none; - padding: 0px; -} - -#emoji-launcher-box button#emoji-item label { - font-size: 24px; -} - -#emoji-launcher-box button#emoji-item:hover, -#emoji-launcher-box button#emoji-item:focus { - text-shadow: 2px 2px 2px @primary; -} diff --git a/config/modus/styles/powermenu.css b/config/modus/styles/powermenu.css deleted file mode 100644 index ff981805..00000000 --- a/config/modus/styles/powermenu.css +++ /dev/null @@ -1,26 +0,0 @@ -#powermenu-button { - border-radius: 20px; - padding: 20px; -} - -#powermenu-button:hover, -#powermenu-button:focus { - background-color: mix(@onSurface, @surface, 0.8); -} - -#powermenu-button:hover label, -#powermenu-button:focus label { - color: @primary; -} - -#powermenu-button:active { - background-image: radial-gradient( - circle, - mix(@onSurfaceVariant, transparent, 0.7) 10%, - transparent 0% - ); -} - -#powermenu-button:active label { - color: @shadow; -} diff --git a/config/modus/styles/sh.css b/config/modus/styles/sh.css deleted file mode 100644 index 795fdf4e..00000000 --- a/config/modus/styles/sh.css +++ /dev/null @@ -1,15 +0,0 @@ -#shell-command-launcher-box button#sh-item { - border-radius: 11px; - background-color: transparent; - background-image: none; - box-shadow: none; - padding: 0px; -} -#shell-command-launcher-box button#sh-item { - font-size: 24px; -} - -#shell-command-launcher-box button#sh-item:hover, -#shell-command-launcher-box button#sh-item:focus { - text-shadow: 2px 2px 2px @primary; -} diff --git a/config/modus/styles/todo.css b/config/modus/styles/todo.css deleted file mode 100644 index b10f5635..00000000 --- a/config/modus/styles/todo.css +++ /dev/null @@ -1,24 +0,0 @@ -#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; -} diff --git a/config/modus/styles/wallpapers.css b/config/modus/styles/wallpapers.css deleted file mode 100644 index 90caf42b..00000000 --- a/config/modus/styles/wallpapers.css +++ /dev/null @@ -1,40 +0,0 @@ -#wallpaper-icons { - animation: fade-in 0.25s ease-in-out; -} - -@keyframes fade-in { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} - -#wallpaper-icons:selected { - 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; -} -- 2.43.0 From 737d712383d2f3dfea5dceb833795b373df76079 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 4 Feb 2025 19:39:50 +0545 Subject: [PATCH 32/38] corner added --- config/modus/main.py | 2 ++ config/modus/modules/corners.py | 64 +++++++++++++++++++++++++++++++++ config/modus/styles/main.css | 12 ++++++- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 config/modus/modules/corners.py diff --git a/config/modus/main.py b/config/modus/main.py index a4cfef51..56baf289 100644 --- a/config/modus/main.py +++ b/config/modus/main.py @@ -9,6 +9,7 @@ from modules.bar.bar import Bar from modules.launcher.launcher import Launcher from modules.notification_popup import NotificationPopup from modules.osd import OSDContainer +from modules.corners import Corners from services import sc for log in [ @@ -43,6 +44,7 @@ if __name__ == "__main__": update_main_css() sc = sc bar = Bar() + corners = Corners() osd = OSDContainer() notif = NotificationPopup() launcher = Launcher() diff --git a/config/modus/modules/corners.py b/config/modus/modules/corners.py new file mode 100644 index 00000000..10ce26d3 --- /dev/null +++ b/config/modus/modules/corners.py @@ -0,0 +1,64 @@ +from fabric.widgets.box import Box +from fabric.widgets.wayland import WaylandWindow as Window +from fabric.widgets.shapes import Corner + + +class MyCorner(Box): + def __init__(self, corner): + super().__init__( + name="corner-container", + children=Corner( + name="corner", + orientation=corner, + size=20, + ), + ) + + +class Corners(Window): + def __init__(self): + super().__init__( + name="corners", + layer="top", + anchor="top bottom left right", + exclusivity="normal", + pass_through=True, + visible=False, + all_visible=False, + ) + + self.all_corners = Box( + name="all-corners", + orientation="v", + h_expand=True, + v_expand=True, + h_align="fill", + v_align="fill", + children=[ + Box( + name="top-corners", + orientation="h", + h_align="fill", + children=[ + MyCorner("top-left"), + Box(h_expand=True), + MyCorner("top-right"), + ], + ), + Box(v_expand=True), + Box( + name="bottom-corners", + orientation="h", + h_align="fill", + children=[ + MyCorner("bottom-left"), + Box(h_expand=True), + MyCorner("bottom-right"), + ], + ), + ], + ) + + self.add(self.all_corners) + + self.show_all() diff --git a/config/modus/styles/main.css b/config/modus/styles/main.css index 77fa29cd..8ce90039 100644 --- a/config/modus/styles/main.css +++ b/config/modus/styles/main.css @@ -1,4 +1,4 @@ -@import url(../../../.cache/material/colors.css); +@import url(../../.cache/material/colors.css); @import "./bar.css"; @import "./notification.css"; @import "./osd.css"; @@ -12,6 +12,16 @@ sans-serif; } +#corner { + background-color: @surface; + border-radius: 0; +} + +#corner-container { + min-width: 20px; + min-height: 20px; +} + /* * ── tooltip ─────────────────────────────────────────────────────────── */ -- 2.43.0 From c9e887f9f113db51a18db9d9ab35c0902fd467bd Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 4 Feb 2025 22:03:22 +0545 Subject: [PATCH 33/38] updates --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7aeb5533..af3a7438 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,12 @@ This repository contains my personal dotfiles and configuration files. It is cur > Please be aware that this repository is in an experimental phase and subject to frequent updates. The structure and configurations may evolve drastically over time. - -#### Build with **[Fabric](https://github.com/Fabric-Development/fabric)** +

A ʜᴀᴄᴋᴀʙʟᴇ ᴀɴᴅ ᴘᴏᴡᴇʀꜰᴜʟ sʜᴇʟʟ ꜰᴏʀ Hʏᴘʀʟᴀɴᴅ, ᴘᴏᴡᴇʀᴇᴅ ʙʏ Fᴀʙʀɪᴄ.

## Packages ```sh -python-setproctitle, python-fabric-git, fabric-cli-git, grimblast, wf-recoder, brightnessctl, gnome-bluetooth-3.0 cliphist, python-psutil python-loguru, adw-gtk-theme, power-profile-daemon, python-materialyoucolor-git, python-pywayland, python-pyxdg, python-pillow, python-numpy, python-requests, +python-setproctitle, python-fabric-git, fabric-cli-git, grimblast, wf-recoder, brightnessctl, gnome-bluetooth-3.0 cliphist, python-psutil python-loguru, adw-gtk-theme, power-profile-daemon, python-materialyoucolor-git, python-pywayland, python-pyxdg, python-pillow, python-numpy, python-requests, toml, pillow ``` **font** @@ -44,9 +43,9 @@ ttf-font-awesome, otf-font-awesome, ttf-material-symbols-variable-git, ttf-googl - [x] Add bluetooth widget - [x] Add shrunner widget - [ ] Add wifi widget -- [ ] Add Dashboard widget - [ ] Add Notification panel - [ ] Improve CSS Styling - [ ] Add Documentation - [ ] maybe calendar with events - [ ] New Screenshot +- [ ] Power Manager -- 2.43.0 From 285d79de1a4d1b8fc06d9ed9cc5a51bbbd31f4fa Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 4 Feb 2025 22:08:17 +0545 Subject: [PATCH 34/38] update: README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index af3a7438..478b3fb1 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ -> [!WARNING] -> This configuration is personal, created specifically for my own preferences and comfort. It is not intended to be universally appealing, but rather customized for my own use. Please note that this project is very much a work in progress (WIP). -
-

Hyprland

+

Modus

+

A ʜᴀᴄᴋᴀʙʟᴇ ᴀɴᴅ ᴘᴏᴡᴇʀꜰᴜʟ sʜᴇʟʟ ꜰᴏʀ Hʏᴘʀʟᴀɴᴅ, ᴘᴏᴡᴇʀᴇᴅ ʙʏ Fᴀʙʀɪᴄ.

Commit Activity @@ -20,11 +18,13 @@ This repository contains my personal dotfiles and configuration files. It is cur

+> [!WARNING] +> This configuration is personal, created specifically for my own preferences and comfort. It is not intended to be universally appealing, but rather customized for my own use. Please note that this project is very much a work in progress (WIP). + > [!NOTE] > Please be aware that this repository is in an experimental phase and subject to frequent updates. The structure and configurations may evolve drastically over time. -

A ʜᴀᴄᴋᴀʙʟᴇ ᴀɴᴅ ᴘᴏᴡᴇʀꜰᴜʟ sʜᴇʟʟ ꜰᴏʀ Hʏᴘʀʟᴀɴᴅ, ᴘᴏᴡᴇʀᴇᴅ ʙʏ Fᴀʙʀɪᴄ.

## Packages -- 2.43.0 From 2c6ac8154b779a05da50e71645af29a5d8b4ecef Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 4 Feb 2025 22:10:49 +0545 Subject: [PATCH 35/38] update: README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 478b3fb1..e413e5e5 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ ttf-font-awesome, otf-font-awesome, ttf-material-symbols-variable-git, ttf-googl - [x] Add bluetooth widget - [x] Add shrunner widget -- [ ] Add wifi widget +- [ ] Add Network widget - [ ] Add Notification panel - [ ] Improve CSS Styling - [ ] Add Documentation -- 2.43.0 From 755ac6584dea58276158421e6c79b2ecb453c5fe Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Wed, 5 Feb 2025 12:46:58 +0545 Subject: [PATCH 36/38] fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e413e5e5..0e9ceb6c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ This repository contains my personal dotfiles and configuration files. It is cur ## Packages ```sh -python-setproctitle, python-fabric-git, fabric-cli-git, grimblast, wf-recoder, brightnessctl, gnome-bluetooth-3.0 cliphist, python-psutil python-loguru, adw-gtk-theme, power-profile-daemon, python-materialyoucolor-git, python-pywayland, python-pyxdg, python-pillow, python-numpy, python-requests, toml, pillow +python-setproctitle, python-fabric-git, fabric-cli-git, grimblast, wf-recoder, brightnessctl, gnome-bluetooth-3.0 cliphist, python-psutil python-loguru, adw-gtk-theme, power-profile-daemon, python-materialyoucolor-git, python-pywayland, python-pyxdg, python-pillow, python-numpy, python-requests, python-toml, python-pillow ``` **font** -- 2.43.0 From 4b21fa5d5305ede0ac185321d204bd1c82c4d4e5 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 7 Feb 2025 12:49:51 +0545 Subject: [PATCH 37/38] updates --- config/modus/modules/bar/bar.py | 1 + .../modus/modules/bar/components/battery.py | 2 +- config/modus/modules/bar/components/stats.py | 39 +++++----- config/modus/snippets/__init__.py | 13 +++- config/modus/snippets/config.py | 43 ----------- config/modus/styles/launcher.css | 71 +++++++++++++++++-- 6 files changed, 103 insertions(+), 66 deletions(-) delete mode 100644 config/modus/snippets/config.py diff --git a/config/modus/modules/bar/bar.py b/config/modus/modules/bar/bar.py index d75e4ff1..9842b2a6 100644 --- a/config/modus/modules/bar/bar.py +++ b/config/modus/modules/bar/bar.py @@ -109,6 +109,7 @@ class Bar(Window): super().__init__( layer="top", anchor="left bottom right", + # anchor="left top right", exclusivity="auto", visible=True, child=self.bar, diff --git a/config/modus/modules/bar/components/battery.py b/config/modus/modules/bar/components/battery.py index ea82395a..0d298202 100644 --- a/config/modus/modules/bar/components/battery.py +++ b/config/modus/modules/bar/components/battery.py @@ -43,7 +43,7 @@ class BatteryLabel(Box): self.hide() return - battery_percent = round(battery.percent) if battery else 0.0 + battery_percent = round(battery.percent) battery_label = Label(label=f"{battery_percent}%") is_charging = battery.power_plugged if battery else False diff --git a/config/modus/modules/bar/components/stats.py b/config/modus/modules/bar/components/stats.py index 063d318f..8ab3cf4b 100644 --- a/config/modus/modules/bar/components/stats.py +++ b/config/modus/modules/bar/components/stats.py @@ -1,3 +1,4 @@ +from time import sleep import psutil from fabric import Fabricator from fabric.widgets.box import Box @@ -18,7 +19,12 @@ class SystemInfo(Button): def __init__(self): super().__init__(child=self._initialize_content()) - self.fabricator = Fabricator(poll_from=self._refresh_system_info, interval=1000) + + Fabricator( + poll_from=self._refresh_system_info, + stream=True, + on_changed=lambda fab, data: self._update_ui(data), + ) def _initialize_content(self): self.box = Box(orientation="h", name="tray") @@ -36,7 +42,9 @@ class SystemInfo(Button): self.labels[system] = self._create_label() self.icons[system] = self._create_icon(icon_name) - overlay = Overlay(child=self.progress_bars[system], overlays=self.icons[system]) + overlay = Overlay( + child=self.progress_bars[system], overlays=[self.icons[system]] + ) self.box.pack_start(overlay, False, False, 0) self.box.pack_start(self.labels[system], False, False, 0) @@ -51,32 +59,29 @@ class SystemInfo(Button): def _create_icon(self, icon_name): return MaterialIcon(icon_name, size=16) - def _refresh_system_info(self, *_): - usages = self._retrieve_system_data() - self._update_tooltip(usages) - return True + def _refresh_system_info(self, fab: Fabricator): + while True: + yield { + "CPU": round(psutil.cpu_percent()), + "RAM": round(psutil.virtual_memory().percent), + "Swap": round(psutil.swap_memory().percent), + "Temp": self._get_device_temperature(), + } + sleep(1) @staticmethod def _get_device_temperature(): try: temps = psutil.sensors_temperatures() if "coretemp" in temps: - return temps["coretemp"][0].current + return round(temps["coretemp"][0].current, 1) elif "cpu_thermal" in temps: - return temps["cpu_thermal"][0].current + return round(temps["cpu_thermal"][0].current, 1) return None except Exception: return None - def _retrieve_system_data(self): - return { - "CPU": round(psutil.cpu_percent()), - "RAM": round(psutil.virtual_memory().percent), - "Swap": round(psutil.swap_memory().percent), - "Temp": self._get_device_temperature(), - } - - def _update_tooltip(self, usages): + def _update_ui(self, usages): for system, usage in usages.items(): if usage is None: usage = 0 diff --git a/config/modus/snippets/__init__.py b/config/modus/snippets/__init__.py index e95877aa..04d199ed 100644 --- a/config/modus/snippets/__init__.py +++ b/config/modus/snippets/__init__.py @@ -1,4 +1,15 @@ from .animator import * from .custom_image import * -from .config import * from .icon import * +import json +from gi.repository import GLib + + +def read_config(): + home_dir = GLib.get_home_dir() + config_path = f"{home_dir}/dotfiles/modus/assets/config.json" + + with open(config_path, "r") as file: + # Load JSON data into a Python dictionary + data = json.load(file) + return data diff --git a/config/modus/snippets/config.py b/config/modus/snippets/config.py deleted file mode 100644 index 5a5e401e..00000000 --- a/config/modus/snippets/config.py +++ /dev/null @@ -1,43 +0,0 @@ -import json -import os -import time - -import psutil -from gi.repository import GLib -from loguru import logger - - -def read_config(): - home_dir = GLib.get_home_dir() - config_path = f"{home_dir}/dotfiles/modus/assets/config.json" - - with open(config_path, "r") as file: - # Load JSON data into a Python dictionary - data = json.load(file) - return data - - -def get_current_uptime(): - uptime = time.time() - psutil.boot_time() - uptime_hours, remainder = divmod(uptime, 3600) - uptime_minutes, _ = divmod(remainder, 60) - return ( - f"Up: {int(uptime_hours)} {'hours' if uptime_hours != 1 else 'hour'}, " - f"{int(uptime_minutes)} {'minutes' if uptime_minutes != 1 else 'minute'}" - ) - - -def get_profile_picture_path() -> str | None: - path = os.path.expanduser("~/Pictures/Other/face.jpg") - if not os.path.exists(path): - path = os.path.expanduser("~/.face") - if not os.path.exists(path): - logger.warning( - "can't fetch a user profile picture, add a profile picture image at ~/.face or at ~/Pictures/Other/profile.jpg" - ) - path = None - return path - - -def username(): - return os.getlogin().title() diff --git a/config/modus/styles/launcher.css b/config/modus/styles/launcher.css index 3d65caed..77fd4e2c 100644 --- a/config/modus/styles/launcher.css +++ b/config/modus/styles/launcher.css @@ -1,3 +1,42 @@ +#switcher { + background-color: @background; + border: solid 1px @surfaceVariant; + padding: 12px; + border-radius: 16px; +} + +.switcher-button { + border-radius: 16px; + border: 1px solid @surfaceVariant; + padding: 4px; + margin: 4px; +} + +.switcher-button button:active { + background-color: @primaryContainer; + border-radius: 11px; + box-shadow: inset 0 0 0 1px rgba(158, 142, 130, 0.04); +} + +.switcher-button:hover, +.switcher-button:focus { + background-color: mix(@onSurface, @surface, 0.85); +} + +.switcher-button:hover image, +.switcher-button:focus image { + -gtk-icon-shadow: 2px 2px @primary; +} + +.switcher-button:hover #title, +.switcher-button:focus #title { + color: @primary; +} + +/* + * ── launcher ────────────────────────────────────────────────────────── +*/ + #launcher { margin: 18px; border: 1px solid @outlineVariant; @@ -21,10 +60,18 @@ min-width: 620px; } -#launcher-content.bluetooth { +#launcer-content.cliphist { min-height: 420px; } +#launcher-content.bluetooth { + min-height: 464px; +} + +#launcher-content.power { + min-height: 52px; +} + #launcher-content { min-width: 420px; } @@ -163,6 +210,9 @@ /* * ── cliphist ────────────────────────────────────────────────────────── */ +#cliphist-history { + min-height: 420px; +} #launcher button#clip-img-item { background-size: cover; @@ -183,11 +233,11 @@ background-color: transparent; background-image: none; box-shadow: none; - padding: 0px; + padding: 6px; } #launcher button#clip-item { - font-size: 24px; + font-size: 30px; } #launcher button#clip-item:hover, @@ -198,6 +248,9 @@ /* * ── todo ────────────────────────────────────────────────────────────── */ +#todo-content { + min-height: 250px; +} #todo-launcher { background-color: @surface; @@ -256,6 +309,10 @@ margin-bottom: 4px; } +#bluetooth-header { + padding: 4px; +} + #bluetooth-scan, #bluetooth-toggle { background-color: @secondaryContainer; @@ -277,7 +334,8 @@ font-weight: bold; } -#bluetooth-text { +#bluetooth-text, +#bluetooth-section { font-weight: bold; } @@ -294,3 +352,8 @@ #bluetooth-connect:hover { background-color: @surfaceBright; } + +#bluetooth-paired, +#bluetooth-available { + padding: 4px; +} -- 2.43.0 From c80ce028e49d288a7e9ac5cbf5e92e0929f2908d Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 7 Feb 2025 12:50:50 +0545 Subject: [PATCH 38/38] updates --- .../modules/launcher/components/__init__.py | 1 + .../modules/launcher/components/bluetooth.py | 14 +- .../modules/launcher/components/cliphist.py | 23 +- .../modules/launcher/components/dashboard.py | 242 ------------------ .../modules/launcher/components/emoji.py | 2 +- .../modus/modules/launcher/components/sh.py | 2 - .../modus/modules/launcher/components/todo.py | 4 +- config/modus/modules/launcher/launcher.py | 5 +- 8 files changed, 17 insertions(+), 276 deletions(-) delete mode 100644 config/modus/modules/launcher/components/dashboard.py diff --git a/config/modus/modules/launcher/components/__init__.py b/config/modus/modules/launcher/components/__init__.py index 24ba7fe1..d2a8f85c 100644 --- a/config/modus/modules/launcher/components/__init__.py +++ b/config/modus/modules/launcher/components/__init__.py @@ -7,3 +7,4 @@ from .power import * from .sh import * from .todo import * from .wallpapers import * +# from .window_switcher import * diff --git a/config/modus/modules/launcher/components/bluetooth.py b/config/modus/modules/launcher/components/bluetooth.py index ae1d18fd..6a3adc7f 100644 --- a/config/modus/modules/launcher/components/bluetooth.py +++ b/config/modus/modules/launcher/components/bluetooth.py @@ -98,14 +98,19 @@ class BluetoothConnections(Box): self.children = [ CenterBox( + name="bluetooth-header", start_children=self.scan_button, center_children=Label(name="bluetooth-text", label="Bluetooth Devices"), end_children=self.toggle_button, ), - Label(name="bluetooth-text", label="Paired"), - ScrolledWindow(min_content_size=(-1, -1), child=self.paired_box), - Label(name="bluetooth-text", label="Available"), - ScrolledWindow(min_content_size=(-1, -1), child=self.available_box), + Label(name="bluetooth-section", label="Paired"), + ScrolledWindow( + name="bluetooth-paired", v_expand=True, child=self.paired_box + ), + Label(name="bluetooth-section", label="Available"), + ScrolledWindow( + name="bluetooth-paired", v_expand=True, child=self.available_box + ), ] # to run notify closures thus display the status @@ -121,4 +126,3 @@ class BluetoothConnections(Box): if device.paired: return self.paired_box.add(slot) return self.available_box.add(slot) - diff --git a/config/modus/modules/launcher/components/cliphist.py b/config/modus/modules/launcher/components/cliphist.py index 751369fa..6ccf8630 100644 --- a/config/modus/modules/launcher/components/cliphist.py +++ b/config/modus/modules/launcher/components/cliphist.py @@ -59,16 +59,15 @@ class Cliphist(Box): def on_button_clicked(self, *_): GLib.spawn_command_line_async("cliphist wipe") + self.cliphist_manager.update_cliphist_history() 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( - name="scrolled-window", + name="cliphist-history", spacing=10, h_scrollbar_policy="never", - v_scrollbar_policy="never", child=self.viewport, ) self.launcher_box.add(self.scrolled_window) @@ -80,11 +79,9 @@ class Cliphist(Box): self.search_entry.grab_focus() def close_launcher(self): - """Closes the clipboard history launcher and clears viewport.""" self.launcher.close() def handle_search_input(self, text: str): - """Handles search input to filter clipboard history.""" self.cliphist_manager.arrange_viewport(text) @@ -100,7 +97,6 @@ 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 @@ -111,7 +107,6 @@ 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(): @@ -121,7 +116,6 @@ class CliphistManager: 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 @@ -132,7 +126,6 @@ class CliphistManager: print(f"Error copying clip {clip_id}: {e}") 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) @@ -150,24 +143,19 @@ class CliphistManager: return "" def query_clips(self, query: str = "") -> List[dict]: - """Filters clipboard history based on the search query.""" history = self.get_clip_history() if not query.strip(): - return history[:16] + return history - return [item for item in history if query.lower() in item["content"].lower()][ - :16 - ] + return [item for item in history if query.lower() in item["content"].lower()] def bake_clip_slot(self, item: dict) -> Button: - """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: - """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( @@ -184,7 +172,6 @@ class CliphistManager: return None def _create_text_button(self, item: dict) -> Button: - """Creates a button for text clips.""" return Button( child=Label( label=item["content"][:55] @@ -198,13 +185,11 @@ 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: 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/modus/modules/launcher/components/dashboard.py b/config/modus/modules/launcher/components/dashboard.py deleted file mode 100644 index d266e0e1..00000000 --- a/config/modus/modules/launcher/components/dashboard.py +++ /dev/null @@ -1,242 +0,0 @@ -from fabric.widgets.box import Box -from fabric.widgets.button import Button -from fabric.widgets.label import Label -from snippets import MaterialIcon - - -class Buttons(Box): - def __init__(self, **kwargs): - super().__init__( - name="buttons", - spacing=4, - h_align="center", - v_align="start", - h_expand=True, - v_expand=True, - visible=True, - all_visible=True, - ) - - self.network_status_button = Button( - name="network-status-button", - h_expand=True, - child=Box( - h_align="start", - v_align="center", - spacing=10, - children=[ - MaterialIcon("wifi"), - Box( - name="network-text", - orientation="v", - h_align="start", - v_align="center", - children=[ - Box( - children=[ - Label( - name="network-label", - label="Wi-Fi", - justification="left", - ), - Box(h_expand=True), - ] - ), - Box( - children=[ - Label( - name="network-ssid", - label="ARGOS_5GHz", - justification="left", - ), - Box(h_expand=True), - ] - ), - ], - ), - ], - ), - ) - - self.network_menu_button = Button( - name="network-menu-button", - child=MaterialIcon("chevron_right"), - ) - - self.network_button = Box( - name="network-button", - orientation="h", - h_align="fill", - v_align="center", - h_expand=True, - v_expand=True, - children=[ - self.network_status_button, - self.network_menu_button, - ], - ) - - self.bluetooth_status_button = Button( - name="bluetooth-status-button", - h_expand=True, - child=Box( - h_align="start", - v_align="center", - spacing=10, - children=[ - MaterialIcon("bluetooth"), - Box( - name="bluetooth-text", - orientation="v", - h_align="start", - v_align="center", - children=[ - Box( - children=[ - Label( - name="bluetooth-label", - label="Bluetooth", - justification="left", - ), - Box(h_expand=True), - ] - ), - Box( - children=[ - Label( - name="bluetooth-status", - label="Connected", - justification="left", - ), - Box(h_expand=True), - ] - ), - ], - ), - ], - ), - ) - - self.bluetooth_menu_button = Button( - name="bluetooth-menu-button", - child=MaterialIcon("chevron_right"), - ) - - self.bluetooth_button = Box( - name="bluetooth-button", - orientation="h", - h_align="fill", - v_align="center", - h_expand=True, - v_expand=True, - children=[ - self.bluetooth_status_button, - self.bluetooth_menu_button, - ], - ) - - self.night_mode_button = Button( - name="night-mode-button", - child=Box( - h_align="start", - v_align="center", - spacing=10, - children=[ - MaterialIcon("nightlight"), - Box( - name="night-mode-text", - orientation="v", - h_align="start", - v_align="center", - children=[ - Box( - children=[ - Label( - name="night-mode-label", - label="Night Mode", - justification="left", - ), - Box(h_expand=True), - ] - ), - Box( - children=[ - Label( - name="night-mode-status", - label="Enabled", - justification="left", - ), - Box(h_expand=True), - ] - ), - ], - ), - ], - ), - ) - - self.caffeine_button = Button( - name="caffeine-button", - child=Box( - h_align="start", - v_align="center", - spacing=10, - children=[ - MaterialIcon("coffee"), - Box( - name="caffeine-text", - orientation="v", - h_align="start", - v_align="center", - children=[ - Box( - children=[ - Label( - name="caffeine-label", - label="Caffeine", - justification="left", - ), - Box(h_expand=True), - ] - ), - Box( - children=[ - Label( - name="caffeine-status", - label="Enabled", - justification="left", - ), - Box(h_expand=True), - ] - ), - ], - ), - ], - ), - ) - - self.add(self.network_button) - self.add(self.bluetooth_button) - self.add(self.night_mode_button) - self.add(self.caffeine_button) - - self.show_all() - - -class Dashboard(Box): - def __init__(self, **kwargs): - super().__init__( - name="dashboard", - h_align="center", - v_align="start", - h_expand=True, - v_expand=True, - visible=True, - all_visible=True, - ) - - self.buttons = Buttons() - - self.add(self.buttons) - - self.show_all() diff --git a/config/modus/modules/launcher/components/emoji.py b/config/modus/modules/launcher/components/emoji.py index d7b83edf..0f4d49a2 100644 --- a/config/modus/modules/launcher/components/emoji.py +++ b/config/modus/modules/launcher/components/emoji.py @@ -80,7 +80,7 @@ class Emoji(Box): class EmojiManager: def __init__(self, launcher): self.launcher = launcher - self.emoji_file_path = os.path.expanduser("~/dotfiles/modus/assets/emoji.json") + self.emoji_file_path = os.path.expanduser("~/modus/assets/emoji.json") def load_emojis(self) -> Generator[tuple, None, None]: if not os.path.exists(self.emoji_file_path): diff --git a/config/modus/modules/launcher/components/sh.py b/config/modus/modules/launcher/components/sh.py index f2ca7024..5992ec8f 100644 --- a/config/modus/modules/launcher/components/sh.py +++ b/config/modus/modules/launcher/components/sh.py @@ -1,7 +1,6 @@ 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 @@ -54,7 +53,6 @@ class Sh(Box): if not self.viewport: self.viewport = Box(name="viewport", spacing=10, orientation="v") self.scrolled_window = ScrolledWindow( - name="scrolled-window", spacing=10, h_scrollbar_policy="never", v_scrollbar_policy="never", diff --git a/config/modus/modules/launcher/components/todo.py b/config/modus/modules/launcher/components/todo.py index d6e5ec74..7cc569b4 100644 --- a/config/modus/modules/launcher/components/todo.py +++ b/config/modus/modules/launcher/components/todo.py @@ -6,7 +6,6 @@ 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 @@ -60,10 +59,9 @@ class TodoManager(Box): if not self.viewport: self.viewport = Box(name="viewport", spacing=4, orientation="v") self.scrolled_window = ScrolledWindow( - name="scrolled-window", + name="todo-content", spacing=10, h_scrollbar_policy="never", - v_scrollbar_policy="never", child=self.viewport, ) self.launcher_box.add(self.scrolled_window) diff --git a/config/modus/modules/launcher/launcher.py b/config/modus/modules/launcher/launcher.py index 86ee0798..409d1ea9 100644 --- a/config/modus/modules/launcher/launcher.py +++ b/config/modus/modules/launcher/launcher.py @@ -37,7 +37,7 @@ class Launcher(Window): v_expand=True, h_expand=True, transition_type="crossfade", - transition_duration=250, + transition_duration=100, children=[ self.launcher, self.wallpapers, @@ -122,9 +122,6 @@ class Launcher(Window): self.stack.set_visible_child(widgets[widget]) widgets[widget].show() - # if widget != "launcher": - # self.launcher.hide() - if widget != "wallpapers": self.wallpapers.viewport.hide() self.wallpapers.viewport.set_property("name", None) -- 2.43.0