From 07650089c57e6284f070c557a5ef81cb1d4a2707 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 3 Dec 2024 13:54:59 +0545 Subject: [PATCH 01/19] set bar name --- config/fabric/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/fabric/main.py b/config/fabric/main.py index ae81ed08..af9100a9 100644 --- a/config/fabric/main.py +++ b/config/fabric/main.py @@ -24,7 +24,7 @@ if __name__ == "__main__": launcher.hide() osd = OSDContainer() notif = NotificationPopup() - app = Application("fabric-bar", bar, launcher, osd) + app = Application("quickbar", bar, launcher, osd) setproctitle.setproctitle("quickbar") css_file = monitor_file(get_relative_path("styles")) -- 2.43.0 From 10e406c9e7200bb62214e4a011b62dc5b36103ca Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 3 Dec 2024 16:05:59 +0545 Subject: [PATCH 02/19] fix launcher --- config/fabric/modules/launcher/launcher.py | 10 +-- config/fabric/modules/launcher/widgets/app.py | 82 ++++++++++--------- 2 files changed, 45 insertions(+), 47 deletions(-) diff --git a/config/fabric/modules/launcher/launcher.py b/config/fabric/modules/launcher/launcher.py index 37636106..5c7574f4 100644 --- a/config/fabric/modules/launcher/launcher.py +++ b/config/fabric/modules/launcher/launcher.py @@ -149,14 +149,13 @@ class Launcher(Window): def arrange_viewport(self, query: str = ""): self.get_viewport().children = [] - dynamic_buttons = [] 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 - + self.scrolled_revealer.unreveal() if query.startswith(":"): self.additional_box.set_visible(False) self.update_dynamic_button([self.default_button]) @@ -225,25 +224,21 @@ class Launcher(Window): 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() 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() 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() 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() def show_shell_commands(self, query: str): if not query: @@ -254,7 +249,6 @@ class Launcher(Window): 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() def show_wallpapers(self, query: str): if query == "random": @@ -263,10 +257,8 @@ class Launcher(Window): 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() 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() diff --git a/config/fabric/modules/launcher/widgets/app.py b/config/fabric/modules/launcher/widgets/app.py index 40c92df9..c97aaeb8 100644 --- a/config/fabric/modules/launcher/widgets/app.py +++ b/config/fabric/modules/launcher/widgets/app.py @@ -5,59 +5,65 @@ from fabric.widgets.label import Label def handle_application_search(launcher, query: str): - query = query.strip() - # Reveal the full app list if the query is empty - if not query: - launcher.additional_box.set_visible(True) + if not query.strip(): launcher.scrolled_revealer.unreveal() + launcher.additional_box.set_visible(True) return - # Hide full app list and search through the available apps - launcher.additional_box.set_visible(False) filtered_apps = [ app for app in launcher.all_apps if query.casefold() in ( - " ".join(filter(None, [app.display_name, app.name, app.generic_name])) + (app.display_name or "") + + " " + + (app.name or "") + + " " + + (app.generic_name or "") ).casefold() ] - # Display filtered apps or hide the search results view if no matches if filtered_apps: launcher.viewport.children = [ - Button( - child=Box( - orientation="h", + bake_application_slot(launcher, app) for app in filtered_apps[:6] + ] + launcher.scrolled_revealer.reveal() + launcher.additional_box.set_visible(False) + 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=[ - Image(pixbuf=app.get_icon_pixbuf(), h_align="start", size=68), - Box( - orientation="v", - spacing=10, - children=[ - Label( - name="title", - label=app.display_name or "Unknown", - h_align="start", - v_align="center", - ), - Label( - name="description", - label=app.description or "", - justification="left", - line_wrap="char", - v_align="center", - ), - ], + 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)), - ) - for app in filtered_apps[:6] # Limit to 6 apps - ] - launcher.scrolled_revealer.reveal() - else: - launcher.scrolled_revealer.unreveal() + ], + ), + name="app-item", + on_clicked=lambda *_: (app.launch(), launcher.set_visible(False)), + **kwargs, + ) -- 2.43.0 From 1b6f9ceaf7e3b397aba7f05bc21596f681409c7c Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Wed, 4 Dec 2024 14:25:04 +0545 Subject: [PATCH 03/19] border-radius for image on notification --- config/fabric/modules/notifications.py | 28 ++++++++++++------ config/fabric/snippets/__init__.py | 2 ++ config/fabric/snippets/custom_image.py | 39 ++++++++++++++++++++++++++ config/fabric/styles/notification.css | 4 +++ 4 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 config/fabric/snippets/custom_image.py diff --git a/config/fabric/modules/notifications.py b/config/fabric/modules/notifications.py index 948b68e6..24143c3c 100644 --- a/config/fabric/modules/notifications.py +++ b/config/fabric/modules/notifications.py @@ -2,6 +2,8 @@ import gi gi.require_version("GdkPixbuf", "2.0") +from gi.repository import GdkPixbuf, GLib + from fabric.notifications import ( Notification, NotificationAction, @@ -15,7 +17,7 @@ from fabric.widgets.image import Image from fabric.widgets.label import Label from fabric.widgets.revealer import Revealer from fabric.widgets.wayland import WaylandWindow as Window -from gi.repository import GdkPixbuf, GLib +from snippets import CustomImage class ActionButton(Button): @@ -95,11 +97,16 @@ class NotificationWidget(Box): # Use provided image if available, otherwise use "notification-symbolic" icon if image_pixbuf := self._notification.image_pixbuf: body_container.add( - Image( - pixbuf=image_pixbuf.scale_simple( - 64, 64, GdkPixbuf.InterpType.BILINEAR - ) - ), + Box( + v_expand=True, + v_align="center", + children=CustomImage( + pixbuf=image_pixbuf.scale_simple( + 64, 64, GdkPixbuf.InterpType.BILINEAR + ), + style_classes="image", + ), + ) ) body_container.add( @@ -143,7 +150,12 @@ class NotificationWidget(Box): ) 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("/"): @@ -164,8 +176,6 @@ class NotificationWidget(Box): else: icon_name = "dialog-information-symbolic" - print(f"DEBUG: icon_name={icon_name}") - # Return a symbolic icon as fallback return Image(name="notification-icon", icon_name=icon_name, icon_size=size) diff --git a/config/fabric/snippets/__init__.py b/config/fabric/snippets/__init__.py index d6986d37..86892477 100644 --- a/config/fabric/snippets/__init__.py +++ b/config/fabric/snippets/__init__.py @@ -1,4 +1,5 @@ from .animator import Animator +from .custom_image import CustomImage from .functions import ( get_current_uptime, get_profile_picture_path, @@ -16,4 +17,5 @@ __all__ = [ "username", "IconResolver", "get_current_uptime", + "CustomImage", ] diff --git a/config/fabric/snippets/custom_image.py b/config/fabric/snippets/custom_image.py new file mode 100644 index 00000000..1aae7f6a --- /dev/null +++ b/config/fabric/snippets/custom_image.py @@ -0,0 +1,39 @@ +import math +from typing import cast + +import cairo +from gi.repository import Gtk + +from fabric.widgets.image import Image + + +class CustomImage(Image): + def do_render_rectangle( + self, cr: cairo.Context, width: int, height: int, radius: int = 0 + ): + cr.move_to(radius, 0) + cr.line_to(width - radius, 0) + cr.arc(width - radius, radius, radius, -(math.pi / 2), 0) + cr.line_to(width, height - radius) + cr.arc(width - radius, height - radius, radius, 0, (math.pi / 2)) + cr.line_to(radius, height) + cr.arc(radius, height - radius, radius, (math.pi / 2), math.pi) + cr.line_to(0, radius) + cr.arc(radius, radius, radius, math.pi, (3 * (math.pi / 2))) + cr.close_path() + + def do_draw(self, cr: cairo.Context): + context = self.get_style_context() + width, height = self.get_allocated_width(), self.get_allocated_height() + cr.save() + + self.do_render_rectangle( + cr, + width, + height, + cast(int, context.get_property("border-radius", Gtk.StateFlags.NORMAL)), + ) + cr.clip() + Image.do_draw(self, cr) + + cr.restore() diff --git a/config/fabric/styles/notification.css b/config/fabric/styles/notification.css index 88d79b72..ff185f70 100644 --- a/config/fabric/styles/notification.css +++ b/config/fabric/styles/notification.css @@ -45,3 +45,7 @@ #notification-icon { margin-right: 5px; } + +.image { + border-radius: 30px; +} -- 2.43.0 From 2a0de33f40a30058656a583b0c049fafa9ab89f0 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Wed, 4 Dec 2024 21:54:49 +0545 Subject: [PATCH 04/19] fixes --- config/fabric/fabric_send | 3 - config/fabric/main.py | 3 - .../modules/launcher/widgets/clipboard.py | 2 +- .../fabric/modules/launcher/widgets/emoji.py | 67 ++--- .../modules/launcher/widgets/wallpaper.py | 77 ++--- config/fabric/start | 5 - config/hypr/UserConfigs/ENVariables.conf | 2 + config/hypr/UserConfigs/Laptops.conf | 20 +- config/hypr/UserConfigs/Monitors.conf | 29 +- config/hypr/UserConfigs/Startup_Apps.conf | 7 +- .../UserConfigs/UserDecorationAnimations.conf | 69 +++++ config/hypr/UserConfigs/UserKeybinds.conf | 72 ++--- config/hypr/UserConfigs/UserSettings.conf | 70 +---- config/hypr/UserConfigs/WindowRules.conf | 16 +- config/hypr/UserConfigs/WorkspaceRules.conf | 24 ++ config/hypr/hyprland.conf | 3 +- config/material-colors/generate.py | 270 ++++++++++-------- .../templates/alacritty-dark.toml | 72 ----- .../templates/alacritty-light.toml | 72 ----- .../material-colors/templates/alacritty.toml | 9 - .../templates/colors-kitty.conf | 27 ++ .../material-colors/templates/hyprlock.conf | 263 ++++++++++------- .../templates/material-discord.scss | 10 +- 23 files changed, 583 insertions(+), 609 deletions(-) delete mode 100755 config/fabric/fabric_send delete mode 100755 config/fabric/start create mode 100644 config/hypr/UserConfigs/UserDecorationAnimations.conf create mode 100644 config/hypr/UserConfigs/WorkspaceRules.conf delete mode 100644 config/material-colors/templates/alacritty-dark.toml delete mode 100644 config/material-colors/templates/alacritty-light.toml delete mode 100644 config/material-colors/templates/alacritty.toml create mode 100644 config/material-colors/templates/colors-kitty.conf diff --git a/config/fabric/fabric_send b/config/fabric/fabric_send deleted file mode 100755 index 0cb5641d..00000000 --- a/config/fabric/fabric_send +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -dbus-send --session --print-reply --dest=org.Fabric.fabric.fabric-bar /org/Fabric/fabric org.Fabric.fabric.Evaluate string:"$1" >/dev/null 2>&1 diff --git a/config/fabric/main.py b/config/fabric/main.py index af9100a9..41a27955 100644 --- a/config/fabric/main.py +++ b/config/fabric/main.py @@ -35,7 +35,4 @@ if __name__ == "__main__": apply_style(app) - def quit_fabric(): - app.quit() - app.run() diff --git a/config/fabric/modules/launcher/widgets/clipboard.py b/config/fabric/modules/launcher/widgets/clipboard.py index 4b7b5cb2..29e4eb52 100644 --- a/config/fabric/modules/launcher/widgets/clipboard.py +++ b/config/fabric/modules/launcher/widgets/clipboard.py @@ -119,7 +119,7 @@ class ClipboardManager: def _add_text_button(self, viewport, item): label_button = Button( child=Label( - label=item["content"][:55], # Truncate text for display + label=item["content"][:35], # Truncate text for display h_expand=True, v_align="center", h_align="start", diff --git a/config/fabric/modules/launcher/widgets/emoji.py b/config/fabric/modules/launcher/widgets/emoji.py index f73e7feb..10d869d2 100644 --- a/config/fabric/modules/launcher/widgets/emoji.py +++ b/config/fabric/modules/launcher/widgets/emoji.py @@ -1,73 +1,46 @@ -import json import os import subprocess from typing import Generator, List +import ijson from fabric.widgets.box import Box from fabric.widgets.button import Button from fabric.widgets.label import Label from snippets import MaterialIcon -class EmojiItem: - def __init__(self, emoji_str: str, name: str, slug: str, group: str): - self.str = emoji_str - self.name = name - self.slug = slug - self.group = group - - class EmojiManager: def __init__(self, launcher): self.launcher = launcher - self.emojis: List[EmojiItem] = [] - self.query_cache: dict = {} + self.emoji_file_path = os.path.expanduser("~/fabric/assets/emoji.json") - def load_emojis(self) -> Generator[EmojiItem, None, None]: - emoji_path = os.path.expanduser("~/fabric/assets/emoji.json") - if not os.path.exists(emoji_path): + def load_emojis(self) -> Generator[tuple, None, None]: + if not os.path.exists(self.emoji_file_path): return - try: - with open(emoji_path, "r") as file: - data = json.load(file) - for emoji_str, item in data.items(): - yield EmojiItem( - emoji_str, item["name"], item["slug"], item["group"] - ) - except (json.JSONDecodeError, OSError): + 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): return - def get_emojis(self) -> List[EmojiItem]: - if not self.emojis: - self.emojis = list(self.load_emojis()) - return self.emojis - - def query_emojis(self, query: str) -> List[EmojiItem]: - if query in self.query_cache: - return self.query_cache[query] - - emojis = self.get_emojis() - filtered_emojis = [ - emoji - for emoji in emojis - if query.lower() in emoji.name.lower() - or query.lower() in emoji.slug.lower() - or query.lower() in emoji.group.lower() + def query_emojis(self, query: str) -> List[tuple]: + query = query.lower() + return [ + (emoji_str, name, slug, group) + for emoji_str, name, slug, group in self.load_emojis() + if query in name.lower() or query in slug.lower() or query in group.lower() ][:48] - self.query_cache[query] = filtered_emojis - return filtered_emojis - - def copy_emoji(self, emoji: EmojiItem): - subprocess.run(["wl-copy"], input=emoji.str.encode(), check=True) + def copy_emoji(self, emoji: tuple): + subprocess.run(["wl-copy"], input=emoji[0].encode(), check=True) self.launcher.set_visible(False) 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[EmojiItem]): + 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) @@ -80,10 +53,10 @@ class EmojiManager: if row.children: viewport.add(row) - def _create_emoji_button(self, emoji: EmojiItem) -> Button: + def _create_emoji_button(self, emoji: tuple) -> Button: return Button( - child=Label(label=emoji.str, h_pack="start"), - tooltip_text=f"Copy {emoji.name}", + child=Label(label=emoji[0], h_pack="start"), + tooltip_text=f"Copy {emoji[1]}", on_clicked=lambda *_: self.copy_emoji(emoji), name="emoji-item", ) diff --git a/config/fabric/modules/launcher/widgets/wallpaper.py b/config/fabric/modules/launcher/widgets/wallpaper.py index a0e99000..ee03d514 100644 --- a/config/fabric/modules/launcher/widgets/wallpaper.py +++ b/config/fabric/modules/launcher/widgets/wallpaper.py @@ -21,20 +21,20 @@ class WallpaperManager: Path.home() / ".cache" / "fabric" / "thumbnails" / "wallpapers" ) self.thumbnail_dir.mkdir(parents=True, exist_ok=True) - self.theme_toggle_button = self.create_theme_toggle_button() + self.theme_toggle_button = self._create_theme_toggle_button() self._update_button_style() - def create_theme_toggle_button(self): - button = Button( + def _create_theme_toggle_button(self): + return Button( child=MaterialIcon("contrast"), v_align="center", on_clicked=self.toggle_dark_mode, ) - return button def toggle_dark_mode(self, *_): - command = os.path.expanduser("~/fabric/assets/scripts/dark-theme.sh --toggle") - exec_shell_command(command) + exec_shell_command( + os.path.expanduser("~/fabric/assets/scripts/dark-theme.sh --toggle") + ) self._update_button_style() def check_dark_mode_state(self): @@ -44,47 +44,57 @@ class WallpaperManager: 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 self.check_dark_mode_state() + if dark_mode else "background-color: transparent; border-radius:100px;" ) self.theme_toggle_button.set_style(style) def show_wallpaper_thumbnails(self, viewport, search_term: str = ""): - wallpapers = self._get_wallpapers(search_term) - self._populate_viewport(viewport, wallpapers) + wallpapers = list(self._get_wallpapers(search_term))[:24] + if not wallpapers: + self._show_no_wallpapers_message(viewport) + return - def _get_wallpapers(self, search_term: str): - return [ - f - for f in self.wallpaper_dir.iterdir() - if f.is_file() - and f.suffix.lower() in self.IMAGE_EXTENSIONS - and self._matches_search(f, search_term) - ] + self._display_thumbnails(viewport, wallpapers) - def _matches_search(self, file, search_term: str): - return not search_term or search_term.lower() in file.name.lower() + 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 _populate_viewport(self, viewport, wallpapers): - viewport.children.clear() + def _display_thumbnails(self, viewport, wallpapers): row = Box(orientation="h", spacing=10, style="margin:5px;") - for i, wallpaper in enumerate(wallpapers[:24]): # Limit to 24 wallpapers + for index, wallpaper in enumerate(wallpapers, 1): thumbnail_path = self._generate_thumbnail(wallpaper) - thumbnail_button = self._create_wallpaper_thumbnail( - thumbnail_path, wallpaper - ) - row.add(thumbnail_button) + row.add(self._create_wallpaper_thumbnail(thumbnail_path, wallpaper)) - if (i + 1) % 6 == 0: + 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 ( + f + for f in self.wallpaper_dir.iterdir() + if f.is_file() + and f.suffix.lower() in self.IMAGE_EXTENSIONS + and self._matches_search(f, search_term) + ) + + def _matches_search(self, file, search_term: str): + return not search_term or search_term.lower() in file.name.lower() + def _generate_thumbnail(self, wallpaper_path): thumbnail_path = self.thumbnail_dir / wallpaper_path.name if not thumbnail_path.exists(): @@ -113,12 +123,13 @@ class WallpaperManager: ) def _create_wallpaper_thumbnail(self, thumbnail_path, wallpaper_path): - thumbnail_style = self._thumbnail_style(thumbnail_path) - thumbnail_box = Box( - orientation="h", h_align="center", v_align="center", style=thumbnail_style - ) return Button( - child=thumbnail_box, + 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", @@ -127,7 +138,7 @@ class WallpaperManager: def _thumbnail_style(self, thumbnail_path): return ( - f"background-image: url('{thumbnail_path }'); " + f"background-image: url('{thumbnail_path}'); " "min-width: 64px; min-height: 64px; " "background-repeat: no-repeat; " "background-size: cover; background-position: center;" diff --git a/config/fabric/start b/config/fabric/start deleted file mode 100755 index ee1249e0..00000000 --- a/config/fabric/start +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -cd ~/dotfiles/fabric/ - -python main.py diff --git a/config/hypr/UserConfigs/ENVariables.conf b/config/hypr/UserConfigs/ENVariables.conf index c60f3001..e9199da9 100644 --- a/config/hypr/UserConfigs/ENVariables.conf +++ b/config/hypr/UserConfigs/ENVariables.conf @@ -1,3 +1,5 @@ +# Environment variables. See https://wiki.hyprland.org/Configuring/Environment-variables/ + #environment-variables env = CLUTTER_BACKEND,wayland env = GDK_BACKEND,wayland,x11 diff --git a/config/hypr/UserConfigs/Laptops.conf b/config/hypr/UserConfigs/Laptops.conf index e3a500f6..f1b42582 100644 --- a/config/hypr/UserConfigs/Laptops.conf +++ b/config/hypr/UserConfigs/Laptops.conf @@ -3,18 +3,16 @@ # These configs are mostly for laptops. This is addemdum to Keybinds.conf $mainMod = SUPER -$fabric_send = ~/fabric/fabric_send #VolumeControl -bindle = ,XF86MonBrightnessUp, exec, ags -r 'brightness.screen_value += 0.1;' -bindle = ,XF86MonBrightnessDown, exec, ags -r 'brightness.screen_value -= 0.1;' -# bindle=,XF86MonBrightnessUp, exec, brightnessctl s 5%+ && $fabric_send 'systemOverlay.enable_popup("brightness")' -# bindle=,XF86MonBrightnessDown, exec, brightnessctl s 5%- && $fabric_send 'systemOverlay.enable_popup("brightness")' -bind = ,XF86AudioRaiseVolume, exec, pamixer -i 5 # Volume Higher key -bind = ,XF86AudioLowerVolume, exec, pamixer -d 5 # Volume lower key -bind = ,XF86AudioMute, exec, pamixer -t # Speaker Mute -# bindle=,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ && $fabric_send 'systemOverlay.enable_popup("sound")' -# bindle=,XF86AudioLowerVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%- && $fabric_send 'systemOverlay.enable_popup("sound")' -# bind =, XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle +bindle=,XF86MonBrightnessUp, exec, brightnessctl s 5%+ +bindle=,XF86MonBrightnessDown, exec, brightnessctl s 5%- + + + +bind =, XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle +bind = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ +bind = ,XF86AudioLowerVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%- + bind = ,XF86AudioMicMute, exec, pamixer --default-source -t # Mic mute key bind = ,XF86AudioNext, exec, playerctl next bind = ,XF86AudioPrev, exec, playerctl previous diff --git a/config/hypr/UserConfigs/Monitors.conf b/config/hypr/UserConfigs/Monitors.conf index e05c1e46..74531c73 100644 --- a/config/hypr/UserConfigs/Monitors.conf +++ b/config/hypr/UserConfigs/Monitors.conf @@ -10,16 +10,17 @@ monitor=,preferred,auto,1 # Created this inorder for the monitor display to not wake up if not intended. # See here: https://github.com/hyprwm/Hyprland/issues/4090 +# Some examples #monitor = eDP-1, preferred, auto, 1 -#monitor = eDP-1, 2560x1440@165, 0x0, 1 -#monitor = DP-3, preferred, auto, 1 +#monitor = eDP-1, 2560x1440@165, 0x0, 1 #own screen +#monitor = DP-3, 1920x1080@240, auto, 1 #monitor = DP-1, preferred, auto, 1 #monitor = HDMI-A-1, preferred,auto,1 -# QEMU-KVM or any virtual box +# QEMU-KVM, virtual box or vmware #monitor = Virtual-1, 1920x1080@60,auto,1 -# Hi Refresh Rate +# High Refresh Rate #monitor=,highrr,auto,1 # High Resolution @@ -28,17 +29,19 @@ monitor=,preferred,auto,1 # to disable a monitor #monitor=name,disable -# Mirror +# Mirror samples #monitor=DP-3,1920x1080@60,0x0,1,mirror,DP-2 -# monitor=,preferred,auto,1,mirror,eDP-1 - - -# Example : -#monitor=eDP-1,2560x1440@165,0x0,1 -#workspace=HDMI-A-1,1 +#monitor=,preferred,auto,1,mirror,eDP-1 #monitor=HDMI-A-1,2560x1440@144,0x0,1,mirror,eDP-1 -#workspace=HDMI-A-2,2 + +# 10 bit monitor support - See wiki https://wiki.hyprland.org/Configuring/Monitors/#10-bit-support - See NOTES below +# NOTE: Colors registered in Hyprland (e.g. the border color) do not support 10 bit. +# NOTE: Some applications do not support screen capture with 10 bit enabled. (Screen captures like OBS may render black screen) +# monitor=,preferred,auto,1,bitdepth,10 #monitor=eDP-1,transform,0 #monitor=eDP-1,addreserved,10,10,10,49 -#workspace=eDP-1,1 + +# workspaces - Monitor rules +# https://wiki.hyprland.org/Configuring/Workspace-Rules/ +# See ~/.config/hypr/UserConfigs/WorkspaceRules.conf diff --git a/config/hypr/UserConfigs/Startup_Apps.conf b/config/hypr/UserConfigs/Startup_Apps.conf index afe0de3c..0ecd3d48 100644 --- a/config/hypr/UserConfigs/Startup_Apps.conf +++ b/config/hypr/UserConfigs/Startup_Apps.conf @@ -12,10 +12,11 @@ exec-once = systemctl --user import-environment QT_QPA_PLATFORMTHEME # Polkit (Polkit Gnome / KDE) exec-once = $scriptsDir/Polkit.sh -# starup apps +# startup apps #exec-once = waybar & -#exec-once = ags & -exec-once = ~/dotfiles/fabric/start & +# exec-once = ~/fabric/start & +# exec-once = ags & +exec-once = cd ~/fabric && python main.py exec-once = wl-gammarelay-rs & exec-once = blueman-applet & exec-once = nm-applet --indicator & diff --git a/config/hypr/UserConfigs/UserDecorationAnimations.conf b/config/hypr/UserConfigs/UserDecorationAnimations.conf new file mode 100644 index 00000000..a8867c03 --- /dev/null +++ b/config/hypr/UserConfigs/UserDecorationAnimations.conf @@ -0,0 +1,69 @@ +# Decoration and Animations Settings + +# Hyprland Wiki Links +# Animation - https://wiki.hyprland.org/Configuring/Animations/ +# Decoration - https://wiki.hyprland.org/Configuring/Variables/#decoration + +decoration { + rounding = 20 + + active_opacity = 1 + inactive_opacity = 1 + fullscreen_opacity = 1 + + dim_inactive = true + dim_strength = 0.1 + dim_special = 0.8 + + +shadow { + enabled = false + range = 6 + render_power = 1 + color = 0x66000000 + } + + blur { + enabled = false + size = 4 + passes = 3 + ignore_opacity = true + new_optimizations = true + } +} + +animations { + enabled = true + # Animation curves + + bezier = linear, 0, 0, 1, 1 + bezier = md3_standard, 0.2, 0, 0, 1 + bezier = md3_decel, 0.05, 0.7, 0.1, 1 + bezier = md3_accel, 0.3, 0, 0.8, 0.15 + bezier = overshot, 0.05, 0.9, 0.1, 1.1 + bezier = crazyshot, 0.1, 1.5, 0.76, 0.92 + bezier = hyprnostretch, 0.05, 0.9, 0.1, 1.0 + bezier = menu_decel, 0.1, 1, 0, 1 + bezier = menu_accel, 0.38, 0.04, 1, 0.07 + bezier = easeInOutCirc, 0.85, 0, 0.15, 1 + bezier = easeOutCirc, 0, 0.55, 0.45, 1 + bezier = easeOutExpo, 0.16, 1, 0.3, 1 + bezier = softAcDecel, 0.26, 0.26, 0.15, 1 + bezier = md2, 0.4, 0, 0.2, 1 # use with .2s duration + # Animation configs + animation = windows, 1, 3, md3_decel, popin 60% + animation = windowsIn, 1, 3, md3_decel, popin 60% + animation = windowsOut, 1, 3, md3_accel, popin 60% + animation = border, 1, 10, default + animation = fade, 1, 3, md3_decel + animation = layers, 1, 2, md3_decel, slide + animation = layersIn, 1, 3, menu_decel, slide + animation = layersOut, 1, 1.6, menu_accel + animation = fadeLayersIn, 1, 2, menu_decel + animation = fadeLayersOut, 1, 4.5, menu_accel + animation = workspaces, 1, 7, menu_decel, slide + # animation = workspaces, 1, 2.5, softAcDecel, slide + # animation = workspaces, 1, 7, menu_decel, slidefade 15% + # animation = specialWorkspace, 1, 3, md3_decel, slidefadevert 15% + animation = specialWorkspace, 1, 3, md3_decel, slidevert +} diff --git a/config/hypr/UserConfigs/UserKeybinds.conf b/config/hypr/UserConfigs/UserKeybinds.conf index bf0aa8ee..980c3c20 100644 --- a/config/hypr/UserConfigs/UserKeybinds.conf +++ b/config/hypr/UserConfigs/UserKeybinds.conf @@ -7,55 +7,37 @@ $mainMod = SUPER $scriptsDir = $HOME/dotfiles/hypr/scripts $RunCMD = $scriptsDir/RunCMD.sh -$fabric = $HOME/dotfiles/fabric/fabric_send - -# Lock indicators -bindlni = , Caps_Lock, exec, ags -r 'updateCapsLock();' -bindlnri = , Caps_Lock, exec, ags -r 'updateCapsLock();' -bindlni = , Num_Lock, exec, ags -r 'updateNumLock();' -bindlnri = , Num_Lock, exec, ags -r 'updateNumLock();' - -# Categories (for script) -#! @actions: Actions -#! @tools: Tools -#! @apps: Applications -#! @windows: Windows -#! @workspaces: Workspaces -#! @misc: Misc +$fabric = python -m fabric execute quickbar # 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 'Shell' -A "Test1=I got it!" -A "Test2=Another action" -bind = Alt, Equal, exec, notify-send 'hmm' ${SLURP_ARGS} -bindr = ALT, R, exec, ags -r 'ReloadCSS();' +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" +bind = Alt, Equal, exec, notify-send 'hmm' ${SLURP_ARGS} # Applications -bind = ALT SHIFT,Return, exec, kitty --title Kitty --single-instance #! @description: "Terminal Float"; @apps; -bind = $mainMod, Return, exec, $scriptsDir/apps.sh terminal #! @description: "Terminal"; @apps; -bind = $mainMod, E, exec, $scriptsDir/apps.sh filemanager #! @description: "File Manager"; @apps; -bind = $mainMod, B, exec, $scriptsDir/apps.sh browser #! @description: "Browser"; @apps; -bind = $mainMod, T, exec, materialgram #! @description: "Telegram", @apps; +bind = ALT SHIFT,Return, exec, kitty --title Kitty --single-instance +bind = $mainMod, Return, exec, kitty +bind = $mainMod, E, exec, thunar +bind = $mainMod, B, exec, firefox +bind = $mainMod, T, exec, materialgram # Actions -bind = $mainMod SHIFT, G, exec, $RunCMD gamemode #! @description: "Toggle animations"; @actions; -bind = $mainMod, F3, exec, $RunCMD kb_changer #! @description: "Change Keyboard Layout"; @actions; -bind = $mainMod, space, exec, $RunCMD change_layout #! @description: "Change Layout(master/dwindle)"; @actions; -bind = SHIFT ALT,W, exec, python -O $scriptsDir/wallpaper.py -R #! @description: "Random wallpaper"; @actions; -bind = $mainMod CTRL, L, exec, pidof hyprlock || hyprlock -q #! @description: "Lock screen"; @actions; -bind = $mainMod CTRL, P, exec, systemctl poweroff #! @description: "ShutDown"; @actions; -bind = $mainMod CTRL, R, exec, systemctl reboot #! @description: "Restart"; @actions; -bind = $mainMod, o, exec, $scriptsDir/ScreenShot.sh #! @description: "Screenshot"; @actions; -# bind = ALT SHIFT, S, exec, $scriptsDir/ScreenShot.sh --window #! @description: "Window screenshot"; @actions; -# bind = ,Print, exec, $scriptsDir/ScreenShot.sh --active #! @description: "Active screen screenshot"; @actions; -bind = $mainMod,Z, exec, $fabric_send 'sc.screenshot()' -bind = , Print, exec, $fabric_send 'sc.screenshot(True)' -bind = $mainMod, R, exec, $fabric_send 'sc.screencast_start(True)' -bind = Super, y, exec, XDG_CURRENT_DESKTOP="gnome" gnome-control-center -# Tools -# bind = $mainMod, D, exec, $fabric_send 'launcher.toggle()' -bind=CTRL SHIFT, R, exec, $fabric_send 'quit_fabric()' || sleep 0.5 && $fabric +bind = $mainMod SHIFT, G, exec, $RunCMD gamemode +bind = $mainMod, F3, exec, $RunCMD kb_changer +bind = $mainMod, space, exec, $RunCMD change_layout +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 = $mainMod, R, exec, $fabric 'sc.screencast_start(True)' +bind = $mainMod_SHIFT, R, exec, $fabric 'sc.screencast_stop()' + +bind=$mainMod,Z, exec, $fabric 'sc.screenshot()' +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()' + -# Misc -bind = $mainMod ALT, P, submap, passthru #! @description: "Passthrough mainMod key to Virtual Machine"; @misc; -submap = passthru -bind = $mainMod ALT, Escape, submap, reset #! @description: "Cancel passthrough"; @misc; -submap = reset diff --git a/config/hypr/UserConfigs/UserSettings.conf b/config/hypr/UserConfigs/UserSettings.conf index fe332ca2..8fc85202 100644 --- a/config/hypr/UserConfigs/UserSettings.conf +++ b/config/hypr/UserConfigs/UserSettings.conf @@ -15,80 +15,16 @@ master { } general { - # sensitivity = 1.00 - # apply_sens_to_raw = 1 - gaps_in = 6 + gaps_in = 5 gaps_out = 8 border_size = 0 col.active_border = $border_color_active col.inactive_border = $border_color_inactive - layout = master + layout = dwindle } -decoration { - rounding = 20 - - active_opacity = 1 - inactive_opacity = 1 - fullscreen_opacity = 1 - - dim_inactive = true - dim_strength = 0.1 - dim_special = 0.8 - - drop_shadow = false - shadow_range = 10 - shadow_render_power = 3 - col.shadow = 0x66000000 - - blur { - enabled = false - size = 4 - passes = 3 - ignore_opacity = true - new_optimizations = true - } -} - -animations { - enabled = true - # Animation curves - - bezier = linear, 0, 0, 1, 1 - bezier = md3_standard, 0.2, 0, 0, 1 - bezier = md3_decel, 0.05, 0.7, 0.1, 1 - bezier = md3_accel, 0.3, 0, 0.8, 0.15 - bezier = overshot, 0.05, 0.9, 0.1, 1.1 - bezier = crazyshot, 0.1, 1.5, 0.76, 0.92 - bezier = hyprnostretch, 0.05, 0.9, 0.1, 1.0 - bezier = menu_decel, 0.1, 1, 0, 1 - bezier = menu_accel, 0.38, 0.04, 1, 0.07 - bezier = easeInOutCirc, 0.85, 0, 0.15, 1 - bezier = easeOutCirc, 0, 0.55, 0.45, 1 - bezier = easeOutExpo, 0.16, 1, 0.3, 1 - bezier = softAcDecel, 0.26, 0.26, 0.15, 1 - bezier = md2, 0.4, 0, 0.2, 1 # use with .2s duration - # Animation configs - animation = windows, 1, 3, md3_decel, popin 60% - animation = windowsIn, 1, 3, md3_decel, popin 60% - animation = windowsOut, 1, 3, md3_accel, popin 60% - animation = border, 1, 10, default - animation = fade, 1, 3, md3_decel - animation = layers, 1, 2, md3_decel, slide - animation = layersIn, 1, 3, menu_decel, slide - animation = layersOut, 1, 1.6, menu_accel - animation = fadeLayersIn, 1, 2, menu_decel - animation = fadeLayersOut, 1, 4.5, menu_accel - animation = workspaces, 1, 7, menu_decel, slide - # animation = workspaces, 1, 2.5, softAcDecel, slide - # animation = workspaces, 1, 7, menu_decel, slidefade 15% - # animation = specialWorkspace, 1, 3, md3_decel, slidefadevert 15% - animation = specialWorkspace, 1, 3, md3_decel, slidevert -} - - input { kb_layout = us,np kb_variant = @@ -127,7 +63,6 @@ misc { disable_hyprland_logo = true disable_splash_rendering = true mouse_move_enables_dpms = true - #vrr = 0 vfr = 1 mouse_move_enables_dpms = true enable_swallow = true @@ -143,6 +78,7 @@ binds { } xwayland { + enabled = true force_zero_scaling = true } diff --git a/config/hypr/UserConfigs/WindowRules.conf b/config/hypr/UserConfigs/WindowRules.conf index 95aa93e2..00b41a78 100644 --- a/config/hypr/UserConfigs/WindowRules.conf +++ b/config/hypr/UserConfigs/WindowRules.conf @@ -38,6 +38,9 @@ windowrulev2 = size 35% 90%, $zathura windowrulev2 = center 1, $zathura +# Do not lose focus when gnome polkit is opened +windowrulev2 = stayfocused, class:(polkit-gnome-authentication-agent-1) + # OBS # Main window / Profile screen @@ -128,8 +131,6 @@ windowrule = size 800 500, title:^(Kitty)$ windowrule = move center, title:^(Kitty)$ windowrule = animation slide, title:^(Kitty)$ windowrule = float, title:^(Kitty)$ -windowrule = float, kitty_float - # Bluetooth applet windowrulev2 = float, class:(blueman) @@ -173,24 +174,21 @@ windowrulev2 = center, title:(File Operation Progress) +windowrulev2 = stayfocused, class:(launcher) # Layer Rules -layerrule = noanim, popup.* +# layerrule = noanim, popup.* layerrule = noanim, hyprpicker layerrule = noanim, selection layerrule = noanim, noanim -layerrule = blur, gtk-layer-shell layerrule = ignorezero, gtk-layer-shell -layerrule = blur, launcher -layerrule = ignorealpha 0.5, launcher layerrule = blur, notifications layerrule = ignorealpha 0.69, notifications layerrule = noanim,selection layerrule = noanim, notifications -# layerrule = animation fade, launcher +layerrule = animation slide, launcher # fabric -layerrule = noanim, fabric +# layerrule = noanim, fabric # layerrule = ignorezero, fabric - diff --git a/config/hypr/UserConfigs/WorkspaceRules.conf b/config/hypr/UserConfigs/WorkspaceRules.conf new file mode 100644 index 00000000..59e5309d --- /dev/null +++ b/config/hypr/UserConfigs/WorkspaceRules.conf @@ -0,0 +1,24 @@ +# You can set workspace rules to achieve workspace-specific behaviors. +# For instance, you can define a workspace where all windows are drawn without borders or gaps. + +# https://wiki.hyprland.org/Configuring/Workspace-Rules/ + +# Assigning workspace to a certain monitor. Below are just examples +# workspace = 1, monitor:eDP-1 +# workspace = 2, monitor:eDP-1 +# workspace = 3, monitor:eDP-1 +# workspace = 4, monitor:eDP-1 +# workspace = 5, monitor:DP-2 +# workspace = 6, monitor:DP-2 +# workspace = 7, monitor:DP-2 +# workspace = 8, monitor:DP-2 + + +# example rules (from wiki) +# workspace = 3, rounding:false, decorate:false +# workspace = name:coding, rounding:false, decorate:false, gapsin:0, gapsout:0, border:false, decorate:false, monitor:DP-1 +# workspace = 8,bordersize:8 +# workspace = name:Hello, monitor:DP-1, default:true +# workspace = name:gaming, monitor:desc:Chimei Innolux Corporation 0x150C, default:true +# workspace = 5, on-created-empty:[float] firefox +# workspace = special:scratchpad, on-created-empty:foot diff --git a/config/hypr/hyprland.conf b/config/hypr/hyprland.conf index 0a3a5197..f5245ec2 100644 --- a/config/hypr/hyprland.conf +++ b/config/hypr/hyprland.conf @@ -17,7 +17,8 @@ source= $UserConfigs/LaptopDisplay.conf source= $UserConfigs/WindowRules.conf source= $UserConfigs/UserKeybinds.conf source= $UserConfigs/UserSettings.conf - +source = $UserConfigs/UserDecorationAnimations.conf +source = $UserConfigs/WorkspaceRules.conf # Material colors source = ~/.cache/material/colors-hyprland.conf diff --git a/config/material-colors/generate.py b/config/material-colors/generate.py index c389c686..5bd382be 100644 --- a/config/material-colors/generate.py +++ b/config/material-colors/generate.py @@ -1,28 +1,40 @@ -import os -import random -import subprocess -import json -from PIL import Image import argparse -from materialyoucolor.quantize import QuantizeCelebi # type: ignore -from materialyoucolor.score.score import Score # type: ignore -from materialyoucolor.hct import Hct # type: ignore -from materialyoucolor.dynamiccolor.material_dynamic_colors import MaterialDynamicColors # type: ignore # noqa -from materialyoucolor.scheme.dynamic_scheme import DynamicScheme # type: ignore # noqa -from materialyoucolor.scheme.scheme_tonal_spot import SchemeTonalSpot # type: ignore # noqa -from materialyoucolor.scheme.scheme_expressive import SchemeExpressive # type: ignore # noqa -from materialyoucolor.scheme.scheme_fruit_salad import SchemeFruitSalad # type: ignore # noqa -from materialyoucolor.scheme.scheme_monochrome import SchemeMonochrome # type: ignore # noqa -from materialyoucolor.scheme.scheme_rainbow import SchemeRainbow # type: ignore # noqa -from materialyoucolor.scheme.scheme_vibrant import SchemeVibrant # type: ignore # noqa -from materialyoucolor.scheme.scheme_neutral import SchemeNeutral # type: ignore # noqa -from materialyoucolor.scheme.scheme_fidelity import SchemeFidelity # type: ignore # noqa -from materialyoucolor.scheme.scheme_content import SchemeContent # type: ignore # noqa import hashlib +import json +import os import pickle -import numpy as np +import random import re +import subprocess +import numpy as np +from materialyoucolor.dynamiccolor.material_dynamic_colors import ( + MaterialDynamicColors, +) # type: ignore # noqa +from materialyoucolor.hct import Hct # type: ignore +from materialyoucolor.quantize import QuantizeCelebi # type: ignore +from materialyoucolor.scheme.dynamic_scheme import DynamicScheme # type: ignore # noqa +from materialyoucolor.scheme.scheme_content import SchemeContent # type: ignore # noqa +from materialyoucolor.scheme.scheme_expressive import ( + SchemeExpressive, +) # type: ignore # noqa +from materialyoucolor.scheme.scheme_fidelity import ( + SchemeFidelity, +) # type: ignore # noqa +from materialyoucolor.scheme.scheme_fruit_salad import ( + SchemeFruitSalad, +) # type: ignore # noqa +from materialyoucolor.scheme.scheme_monochrome import ( + SchemeMonochrome, +) # type: ignore # noqa +from materialyoucolor.scheme.scheme_neutral import SchemeNeutral # type: ignore # noqa +from materialyoucolor.scheme.scheme_rainbow import SchemeRainbow # type: ignore # noqa +from materialyoucolor.scheme.scheme_tonal_spot import ( + SchemeTonalSpot, +) # type: ignore # noqa +from materialyoucolor.scheme.scheme_vibrant import SchemeVibrant # type: ignore # noqa +from materialyoucolor.score.score import Score # type: ignore +from PIL import Image schemes = { "tonalSpot": SchemeTonalSpot, @@ -33,7 +45,7 @@ schemes = { "vibrant": SchemeVibrant, "neutral": SchemeNeutral, "fidelity": SchemeFidelity, - "content": SchemeContent + "content": SchemeContent, } @@ -41,7 +53,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 +61,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,11 +82,18 @@ class Color(): class ColorsCache: def __init__( - self, colors: DynamicScheme | dict, wallpaper: str, original_color: int + self, + colors: DynamicScheme | dict, + wallpaper: str, + original_color: int, + contrast_level: int, + scheme_name: str, ) -> None: self.colors: dict[str, str] = {} self.wallpaper = wallpaper self.original_color = original_color + self.contrast_level = contrast_level + self.scheme_name = scheme_name if isinstance(colors, DynamicScheme): for color in vars(MaterialDynamicColors).keys(): color_name = getattr(MaterialDynamicColors, color) @@ -90,7 +109,9 @@ def colors_dict(cache: ColorsCache): dict = { "wallpaper": cache.wallpaper, "colors": cache.colors, - "original_color": cache.original_color + "original_color": cache.original_color, + "contrast_level": cache.contrast_level, + "scheme_name": cache.scheme_name, } return dict @@ -101,7 +122,9 @@ def get_cache_object(object: dict | str): colors = object["colors"] wallpaper = object["wallpaper"] original_color = object["original_color"] - return ColorsCache(colors, wallpaper, 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) def get_file_list(folder_path): @@ -114,11 +137,9 @@ def get_file_list(folder_path): ready_templates = { "colors.css": "@define-color {name} {hex};\n", - "colors.scss": "${name}: {hex};\n" -} -additional = { - "onBackground": "foreground" + "colors.scss": "${name}: {hex};\n", } +additional = {"onBackground": "foreground"} def generate_color_map(scheme: DynamicScheme): @@ -137,25 +158,23 @@ 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) @@ -165,24 +184,22 @@ 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: @@ -193,7 +210,7 @@ class ColorFormatter: return result def format(self, text): - pattern = r'(<(\w+)(?:\.(.+))?>)' + pattern = r"(<(\w+)(?:\.(.+))?>)" matches = re.findall(pattern, text) result = [] last_end = 0 @@ -201,27 +218,30 @@ 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): @@ -234,13 +254,12 @@ def generate_templates(folder: str, output_folder: str, scheme: DynamicScheme, 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: @@ -252,21 +271,17 @@ def generate_templates(folder: str, output_folder: str, scheme: DynamicScheme, 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) @@ -277,9 +292,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): @@ -287,18 +302,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) @@ -307,7 +322,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) @@ -322,9 +337,14 @@ def process_image(image_path, quality=2, num_colors=128): def main( - color_scheme: str, image_path: str, use_color: int | None = None, - scheme: DynamicScheme = schemes["tonalSpot"] + 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] is_dark = True if color_scheme == "dark" else False if use_color is None: color = process_image(image_path, 4, 1024) @@ -332,32 +352,31 @@ def main( else: color = use_color - scheme = scheme( - Hct.from_int(color), - is_dark, - 0.0, - ) + 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) + 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")) @@ -365,26 +384,27 @@ 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( - "-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" + "-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( "--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="tonalSpot", - 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() @@ -396,51 +416,71 @@ 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() - scheme = schemes[_scheme] + if not scheme: + scheme = None if use_color is not None: try: 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=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=scheme + color_scheme, + image_path="/dev/null", + use_color=int(use_color.lstrip("#"), 16), + scheme_name=scheme, ) elif restore_palette: with open(join(cache_path, "colors.json")) as f: content = get_cache_object(f.read()) main( - color_scheme, image_path=content.wallpaper, - use_color=content.original_color, scheme=scheme + color_scheme, + image_path=content.wallpaper, + use_color=content.original_color, + scheme_name=scheme or content.scheme_name, + contrast_level=content.contrast_level, ) elif use_last_used_wallpaper: with open(join(cache_path, "colors.json")) as f: - content = get_cache_object(f.read()).wallpaper - main(color_scheme, image_path=content, scheme=scheme) + content = get_cache_object(f.read()) + main( + color_scheme, + image_path=content.wallpaper, + scheme_name=scheme or content.scheme_name, + 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)) - main(color_scheme, image_path=image, scheme=scheme) + main(color_scheme, image_path=image, scheme_name=scheme) if __name__ == "__main__": diff --git a/config/material-colors/templates/alacritty-dark.toml b/config/material-colors/templates/alacritty-dark.toml deleted file mode 100644 index f870c92f..00000000 --- a/config/material-colors/templates/alacritty-dark.toml +++ /dev/null @@ -1,72 +0,0 @@ -[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' \ No newline at end of file diff --git a/config/material-colors/templates/alacritty-light.toml b/config/material-colors/templates/alacritty-light.toml deleted file mode 100644 index 533fecf0..00000000 --- a/config/material-colors/templates/alacritty-light.toml +++ /dev/null @@ -1,72 +0,0 @@ -[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' \ No newline at end of file diff --git a/config/material-colors/templates/alacritty.toml b/config/material-colors/templates/alacritty.toml deleted file mode 100644 index ea81e141..00000000 --- a/config/material-colors/templates/alacritty.toml +++ /dev/null @@ -1,9 +0,0 @@ -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/colors-kitty.conf b/config/material-colors/templates/colors-kitty.conf new file mode 100644 index 00000000..eeebd865 --- /dev/null +++ b/config/material-colors/templates/colors-kitty.conf @@ -0,0 +1,27 @@ +foreground +background +cursor + +color0 +color8 + +color1 +color9 + +color2 +color10 + +color3 +color11 + +color4 +color12 + +color5 +color13 + +color6 +color14 + +color7 +color15 \ No newline at end of file diff --git a/config/material-colors/templates/hyprlock.conf b/config/material-colors/templates/hyprlock.conf index e7a518f5..c4c20a41 100644 --- a/config/material-colors/templates/hyprlock.conf +++ b/config/material-colors/templates/hyprlock.conf @@ -1,103 +1,172 @@ -general { - grace = 5 - hide_cursor = true - ignore_empty_input = true - text_trim = true -} +# Configuration + # (general settings) + general { + grace = 2 + hide_cursor = true + ignore_empty_input = true + text_trim = true + } + # (background config) + background { + monitor = + path = ~/.cache/current_wallpaper.png # only png supported for now + color = rgba(, 1.0) + blur_passes = 3 # 0 disables blurring + blur_size = 1 + noise = 0.01 + contrast = 0.8916 + brightness = 0.7 + vibrancy = 0.1696 + vibrancy_darkness = 0.0 + } +# -background { - monitor = - path = ~/.cache/current_wallpaper.png # only png supported for now - color = rgba(, 1.0) - blur_passes = 3 # 0 disables blurring - blur_size = 1 - noise = 0.01 - contrast = 0.8916 - brightness = 0.7 - vibrancy = 0.1696 - vibrancy_darkness = 0.0 -} +# Password input + input-field { + monitor = + size = 225, 50 + outline_thickness = 3 + dots_size = 0.33 + dots_spacing = 0.45 + dots_center = true + dots_rounding = -1 + outer_color = rgba(0,0,0,0) + inner_color = rgba(0,0,0,0) + font_color = rgba(, 1.0) + fade_on_empty = false + fade_timeout = 1000 + font_family = Product Sans + placeholder_text = + hide_input = false + rounding = 4 + check_color = rgba(0,0,0,0) + fail_color = rgba(0,0,0,0) + fail_text = $FAIL ($ATTEMPTS) + fail_transition = 200 + capslock_color = -1 + numlock_color = -1 + bothlock_color = -1 + invert_numlock = false + swap_font_color = false + position = 0, 150 + halign = center + valign = bottom + } +# -input-field { - monitor = - size = 200, 50 - outline_thickness = 3 - dots_size = 0.33 - dots_spacing = 0.15 - dots_center = true - dots_rounding = -1 - outer_color = rgb() - inner_color = rgb() - font_color = rgb() - fade_on_empty = false - fade_timeout = 1000 - font_family = Product Sans - placeholder_text = $USER - hide_input = false - rounding = 4 - check_color = rgb() - fail_color = rgb() - fail_text = $FAIL ($ATTEMPTS) - fail_transition = 200 - capslock_color = -1 - numlock_color = -1 - bothlock_color = -1 - invert_numlock = false - swap_font_color = false - position = 0, 70 - halign = center - valign = bottom -} -# DATE -label { - monitor = - text = cmd[update:1000] echo -e "$(date +"%d %b %A")" - color = rgba(, 1.0) - font_size = 14 - font_family = JetBrains Mono Nerd Font Mono ExtraBold - position = 0, -130 - halign = center - valign = center -} +# Time + # (hours) + label { + monitor = + text = cmd[update:1000] echo -e "$(date +"%H")" + color = rgba(, 1.0) + shadow_pass = 2 + shadow_size = 3 + shadow_color = rgb(0,0,0) + shadow_boost = 1.2 + font_size = 150 + font_family = Product Sans Light + position = 0, 90 + halign = center + valign = center + } + # (minutes) + label { + monitor = + text = cmd[update:1000] echo -e "$(date +"%M")" + color = rgba(, 1.0) + font_size = 150 + font_family = Product Sans Light + position = 0, -90 + halign = center + valign = center + } +# -# TIME HR -label { - monitor = - text = cmd[update:1000] echo -e "$(date +"%H")" - color = rgba(, 1.0) - shadow_pass = 2 - shadow_size = 3 - shadow_color = rgb(0,0,0) - shadow_boost = 1.2 - font_size = 150 - font_family = Product Sans Semibold - position = 0, -250 - halign = center - valign = top -} +# Date + # (label) + label { + monitor = + text = cmd[update:1000] echo -e "$(date +"%A, %B %d")" + color = rgba(, 1.0) + font_size = 15 + font_family = Product Sans Medium + position = 100, -75 + shadow_passes = 5 + shadow_size = 10 + halign = left + valign = top + } + # (icon) + label { + monitor = + text = calendar_today + color = rgba(, 1.0) + font_size = 15 + font_family = Material Symbols Outlined + position = 75, -75 + shadow_passes = 5 + shadow_size = 10 + halign = left + valign = top + } +# -# TIME -label { - monitor = - text = cmd[update:1000] echo -e "$(date +"%M")" - color = rgba(, 1.0) - font_size = 150 - font_family = Product Sans Semibold - position = 0, -420 - halign = center - valign = top -} +# Input layout + # (label) + label { + monitor = + text = $LAYOUT + color = rgba(, 1.0) + font_size = 15 + font_family = Product Sans Medium + position = 100, -110 + shadow_passes = 5 + shadow_size = 10 + halign = left + valign = top + } + # (icon) + label { + monitor = + text = keyboard + color = rgba(, 1.0) + font_size = 15 + font_family = Material Symbols Outlined + position = 75, -112 + shadow_passes = 5 + shadow_size = 10 + halign = left + valign = top + } +# -label { - monitor = - text = $LAYOUT - color = rgba(, 1.0) - font_size = 10 - font_family = Product Sans Semibold - position = 0, 130 - halign = center - valign = bottom - shadow_passes = 5 - shadow_size = 10 -} +# Battery + # (label) + label { + monitor = + text = cmd[update:1000] . ~/dotfiles/hypr/scripts/battery.sh status + color = rgba(, 1.0) + font_size = 15 + font_family = Product Sans Medium + position = 100, -145 + shadow_passes = 5 + shadow_size = 10 + halign = left + valign = top + } + # (icon) + label { + monitor = + text = cmd[update:1000] . ~/dotfiles/hypr/scripts/battery.sh icon + color = rgba(, 1.0) + font_size = 15 + font_family = Material Symbols Outlined + position = 78, -145 + shadow_passes = 5 + shadow_size = 10 + halign = left + valign = top + } +# diff --git a/config/material-colors/templates/material-discord.scss b/config/material-colors/templates/material-discord.scss index 7c8d1131..ca6cc513 100644 --- a/config/material-colors/templates/material-discord.scss +++ b/config/material-colors/templates/material-discord.scss @@ -1,11 +1,14 @@ +@use "sass:color"; + @import url(https://capnkitten.github.io/BetterDiscord/Themes/Material-Discord/css/source.css); @import "/colors.scss"; + $color-scheme: ; -$hue: round(hue($primary)); -$saturation: round(saturation($primary)); -$lightness: round(lightness($primary)); +$hue: round(color.channel($primary, "hue", $space: hsl)); +$saturation: round(color.channel($primary, "saturation", $space: hsl)); +$lightness: round(color.channel($primary, "lightness", $space: hsl)); * { transition: color 0.2s ease-in-out; @@ -50,3 +53,4 @@ $lightness: round(lightness($primary)); [class*="userPopoutOuter_"] { border-radius: 16px !important; } + -- 2.43.0 From ac61c18a097691fe765abc3f4c8b6532793f7bec Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Mon, 9 Dec 2024 21:30:10 +0545 Subject: [PATCH 05/19] feat: clipboard --- .../fabric/modules/launcher/widgets/clipboard.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/config/fabric/modules/launcher/widgets/clipboard.py b/config/fabric/modules/launcher/widgets/clipboard.py index 29e4eb52..0dbc85b7 100644 --- a/config/fabric/modules/launcher/widgets/clipboard.py +++ b/config/fabric/modules/launcher/widgets/clipboard.py @@ -2,6 +2,7 @@ import os import subprocess from fabric import Fabricator +from fabric.utils import exec_shell_command from fabric.widgets.button import Button from fabric.widgets.image import Image from fabric.widgets.label import Label @@ -24,13 +25,7 @@ class ClipboardManager: ) 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 [] + exec_shell_command("cliphist list") def _parse_clip_history(self, output): return [ @@ -41,7 +36,7 @@ class ClipboardManager: def update_clipboard_history(self): new_history = self.get_clip_history() - if new_history != self.clipboard_history: + if isinstance(new_history, list) and new_history != self.clipboard_history: self.clipboard_history = new_history self.refresh_ui() @@ -94,7 +89,10 @@ class ClipboardManager: 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"]: -- 2.43.0 From c73a600cda863748946a5501daaabb537435379f Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Mon, 9 Dec 2024 21:32:53 +0545 Subject: [PATCH 06/19] feat: clipboard --- config/fabric/modules/launcher/widgets/clipboard.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/config/fabric/modules/launcher/widgets/clipboard.py b/config/fabric/modules/launcher/widgets/clipboard.py index 0dbc85b7..7722633b 100644 --- a/config/fabric/modules/launcher/widgets/clipboard.py +++ b/config/fabric/modules/launcher/widgets/clipboard.py @@ -2,7 +2,6 @@ import os import subprocess from fabric import Fabricator -from fabric.utils import exec_shell_command from fabric.widgets.button import Button from fabric.widgets.image import Image from fabric.widgets.label import Label @@ -25,7 +24,13 @@ class ClipboardManager: ) def get_clip_history(self): - exec_shell_command("cliphist list") + 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 [ -- 2.43.0 From 9b81fdb6406c64d7b2d5dc413cdcba8f08188dd6 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Mon, 9 Dec 2024 21:52:06 +0545 Subject: [PATCH 07/19] feat: wallpaper --- .../modules/launcher/widgets/wallpaper.py | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/config/fabric/modules/launcher/widgets/wallpaper.py b/config/fabric/modules/launcher/widgets/wallpaper.py index ee03d514..c08eeec6 100644 --- a/config/fabric/modules/launcher/widgets/wallpaper.py +++ b/config/fabric/modules/launcher/widgets/wallpaper.py @@ -1,26 +1,23 @@ +import hashlib import os -import threading from pathlib import Path 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"} - THUMBNAIL_SIZE = "x64" - THUMBNAIL_ASPECT_RATIO = "1:1" + 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 = Path.home() / "Pictures" / "wallpapers" - self.thumbnail_dir = ( - Path.home() / ".cache" / "fabric" / "thumbnails" / "wallpapers" - ) - self.thumbnail_dir.mkdir(parents=True, exist_ok=True) + os.makedirs(self.CACHE_DIR, exist_ok=True) self.theme_toggle_button = self._create_theme_toggle_button() self._update_button_style() @@ -52,6 +49,37 @@ class WallpaperManager: ) 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): + """Generate or load a cached thumbnail.""" + cache_path = self.get_cache_path(wallpaper_path.name) + + if not os.path.exists(cache_path): + pixbuf = self.create_thumbnail(str(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: @@ -73,7 +101,7 @@ class WallpaperManager: row = Box(orientation="h", spacing=10, style="margin:5px;") for index, wallpaper in enumerate(wallpapers, 1): - thumbnail_path = self._generate_thumbnail(wallpaper) + thumbnail_path = self.generate_or_load_thumbnail(wallpaper) row.add(self._create_wallpaper_thumbnail(thumbnail_path, wallpaper)) if index % 6 == 0: @@ -95,33 +123,6 @@ class WallpaperManager: def _matches_search(self, file, search_term: str): return not search_term or search_term.lower() in file.name.lower() - def _generate_thumbnail(self, wallpaper_path): - thumbnail_path = self.thumbnail_dir / wallpaper_path.name - if not thumbnail_path.exists(): - threading.Thread( - target=self._create_thumbnail, - args=(wallpaper_path, thumbnail_path), - daemon=True, - ).start() - return thumbnail_path - - def _create_thumbnail(self, wallpaper_path, thumbnail_path): - logger.debug(f"Generating thumbnail for {wallpaper_path}") - exec_shell_command_async( - [ - "magick", - str(wallpaper_path), - "-resize", - self.THUMBNAIL_SIZE, - "-gravity", - "Center", - "-extent", - self.THUMBNAIL_ASPECT_RATIO, - str(thumbnail_path), - ], - lambda *args: logger.debug(args), - ) - def _create_wallpaper_thumbnail(self, thumbnail_path, wallpaper_path): return Button( child=Box( -- 2.43.0 From a38a68d0733e0191cfa08d6e094a1298f0ce1063 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 10 Dec 2024 23:03:17 +0545 Subject: [PATCH 08/19] feat: screenrecorder --- config/fabric/services/screen_record.py | 79 ++++++++++++++++++------- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/config/fabric/services/screen_record.py b/config/fabric/services/screen_record.py index 6a1fc993..2d59621d 100644 --- a/config/fabric/services/screen_record.py +++ b/config/fabric/services/screen_record.py @@ -1,31 +1,20 @@ import datetime import subprocess -from fabric.core.service import Service -from fabric.utils import exec_shell_command +from fabric.core.service import Property, Service, Signal +from fabric.utils import exec_shell_command, exec_shell_command_async from gi.repository import Gio, GLib from loguru import logger -def exec_shell_command_async(cmd: str) -> bool: - if isinstance(cmd, str): - try: - GLib.spawn_command_line_async(cmd) - return True - except ValueError: - return False - else: - return False - - class ScreenRecorder(Service): - # __gsignals__ = SignalContainer( + @Signal + def recording(self, value: bool) -> None: ... - # ) def __init__(self, **kwargs): self.screenshot_path = GLib.get_home_dir() + "/Pictures/Screenshots/" self.screenrecord_path = GLib.get_home_dir() + "/Videos/Screencasting/" - self.recording = False + super().__init__(**kwargs) def screenshot(self, fullscreen=False, save_copy=True): @@ -47,18 +36,64 @@ class ScreenRecorder(Service): logger.error(f"[SCREENSHOT] Failed to run command: {command}") def screencast_start(self, fullscreen=False): + if self.is_recording: + logger.error( + "[SCREENRECORD] Another instance of wf-recorder is already running" + ) + 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: - area = exec_shell_command("slurp") - command = f"wf-recorder -g {area} -f {file_path}" - + f"-g '{exec_shell_command('slurp')}'" + command = f"wf-recorder --file={file_path} --pixel-format yuv420p {area}" exec_shell_command_async(command) + self.emit("recording", True) def screencast_stop(self): exec_shell_command_async("killall -INT wf-recorder") - self.recording = False + self.emit("recording", False) + 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( + [ + "-A", + "files=Show in Files", + "-A", + "view=View", + "-i", + "camera-video-symbolic", + "-a", + "Fabric Screenshot Utility", + "Screencast Saved", + f"Saved Screencast at {file_path}", + ] + ) + + proc: Gio.Subprocess = Gio.Subprocess.new(cmd, Gio.SubprocessFlags.STDOUT_PIPE) + + def do_callback(process: Gio.Subprocess, task: Gio.Task): + try: + _, stdout, stderr = process.communicate_utf8_finish(task) + except Exception: + logger.error( + f"[SCREENCAST] Failed read notification action with error {stderr}" + ) + return + + match stdout.strip("\n"): + case "files": + exec_shell_command_async(f"xdg-open {self.screenrecord_path}") + case "view": + exec_shell_command_async(f"xdg-open {file_path}") + + proc.communicate_utf8_async(None, None, do_callback) def send_screenshot_notification(self, file_path=None): cmd = ["notify-send"] @@ -103,3 +138,7 @@ class ScreenRecorder(Service): exec_shell_command_async(f"swappy -f {file_path}") proc.communicate_utf8_async(None, None, do_callback) + + @Property(bool, "readable", default_value=False) + def is_recording(self): + return False if len(exec_shell_command("pidof wf-recorder")) == 0 else True -- 2.43.0 From 300e790ef1a671b9d9b0d7f14590ecdf925529db Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 10 Dec 2024 23:28:50 +0545 Subject: [PATCH 09/19] fix --- config/fabric/services/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/fabric/services/__init__.py b/config/fabric/services/__init__.py index 1df3d07e..66757f24 100644 --- a/config/fabric/services/__init__.py +++ b/config/fabric/services/__init__.py @@ -1,12 +1,10 @@ from .brightness import Brightness from .screen_record import ScreenRecorder -from .weather import WeatherInfo from .wifi import NetworkClient, Wifi __all__ = [ "Brightness", "ScreenRecorder", - "WeatherInfo", "NetworkClient", "Wifi", ] -- 2.43.0 From d42c0b7684f2572d20da9248095570c1b6187857 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 12 Dec 2024 13:49:33 +0545 Subject: [PATCH 10/19] huge update --- config/fabric/assets/scripts/cliphist.sh | 44 +++ config/fabric/main.py | 28 +- config/fabric/modules/__init__.py | 11 - config/fabric/modules/bar/bar.py | 56 ++-- config/fabric/modules/bar/style.css | 203 ++++++++++++ config/fabric/modules/bar/widgets/__init__.py | 34 +- .../fabric/modules/bar/widgets/bluetooth.py | 4 +- config/fabric/modules/bar/widgets/icon.py | 16 + config/fabric/modules/bar/widgets/idle.py | 29 ++ .../modules/bar/widgets/idle_indicator.py | 38 --- config/fabric/modules/bar/widgets/info.py | 6 +- .../fabric/modules/bar/widgets/microphone.py | 6 +- config/fabric/modules/bar/widgets/network.py | 11 +- .../modules/bar/widgets/powerprofile.py | 4 +- config/fabric/modules/bar/widgets/tray.py | 76 +++++ config/fabric/modules/launcher/launcher.py | 18 +- .../modules/launcher/widgets/__init__.py | 27 +- config/fabric/modules/launcher/widgets/app.py | 3 +- .../modules/launcher/widgets/bluetooth.py | 2 +- .../fabric/modules/launcher/widgets/noti.py | 96 ++++++ .../modules/launcher/widgets/wallpaper.py | 2 +- .../modules/launcher/widgets/wallpaper1.py | 166 ++++++++++ config/fabric/modules/notifications.py | 3 +- config/fabric/services/__init__.py | 13 +- config/fabric/services/screen_record.py | 26 +- config/fabric/snippets/__init__.py | 26 +- config/fabric/snippets/popup.py | 313 ++++++++++++++++++ config/fabric/styles/activelinux.css | 8 + config/fabric/styles/bar.css | 68 ++-- config/fabric/styles/main.css | 2 +- 30 files changed, 1143 insertions(+), 196 deletions(-) create mode 100755 config/fabric/assets/scripts/cliphist.sh delete mode 100644 config/fabric/modules/__init__.py create mode 100644 config/fabric/modules/bar/style.css create mode 100644 config/fabric/modules/bar/widgets/icon.py create mode 100644 config/fabric/modules/bar/widgets/idle.py delete mode 100644 config/fabric/modules/bar/widgets/idle_indicator.py create mode 100644 config/fabric/modules/bar/widgets/tray.py create mode 100644 config/fabric/modules/launcher/widgets/noti.py create mode 100644 config/fabric/modules/launcher/widgets/wallpaper1.py create mode 100644 config/fabric/snippets/popup.py create mode 100644 config/fabric/styles/activelinux.css diff --git a/config/fabric/assets/scripts/cliphist.sh b/config/fabric/assets/scripts/cliphist.sh new file mode 100755 index 00000000..3c6ae6ca --- /dev/null +++ b/config/fabric/assets/scripts/cliphist.sh @@ -0,0 +1,44 @@ +#!/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/fabric/main.py b/config/fabric/main.py index 41a27955..2cd4f4d6 100644 --- a/config/fabric/main.py +++ b/config/fabric/main.py @@ -1,12 +1,17 @@ import os import setproctitle -from loguru import logger - from fabric import Application from fabric.utils import get_relative_path, monitor_file -from modules import Bar, Launcher, NotificationPopup, OSDContainer -from services import Brightness, ScreenRecorder +from loguru import logger + +from modules.bar.bar import Bar +from modules.launcher.launcher import Launcher +from modules.notifications import NotificationPopup +from modules.osd import OSDContainer +from services import ScreenRecorder + +logger.disable("fabric.hyprland.widgets") def apply_style(app: Application): @@ -16,15 +21,18 @@ def apply_style(app: Application): if __name__ == "__main__": sc = ScreenRecorder() - brightness = Brightness() - - logger.disable("fabric.hyprland.widgets") bar = Bar() - launcher = Launcher() - launcher.hide() osd = OSDContainer() notif = NotificationPopup() - app = Application("quickbar", bar, launcher, osd) + launcher = Launcher() + launcher.hide() + + app = Application( + "quickbar", + bar, + launcher, + osd, + ) setproctitle.setproctitle("quickbar") css_file = monitor_file(get_relative_path("styles")) diff --git a/config/fabric/modules/__init__.py b/config/fabric/modules/__init__.py deleted file mode 100644 index 04a9493a..00000000 --- a/config/fabric/modules/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -from .bar.bar import Bar -from .launcher.launcher import Launcher -from .notifications import NotificationPopup -from .osd import OSDContainer - -__all__ = [ - "NotificationPopup", - "OSDContainer", - "Bar", - "Launcher", -] diff --git a/config/fabric/modules/bar/bar.py b/config/fabric/modules/bar/bar.py index eb46622a..76df8c85 100644 --- a/config/fabric/modules/bar/bar.py +++ b/config/fabric/modules/bar/bar.py @@ -6,24 +6,26 @@ 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 ( BatteryLabel, - Bluetooth, + BluetoothIndicator, IdleIndicator, MicrophoneIndicator, - Network, - PowerProfile, + NetworkIndicator, + PowerProfileIndicator, SystemInfo, + SystemTray, TaskBar, VolumeIndicator, workspace, ) +from services import ScreenRecorder +from snippets import MaterialIcon class Bar(Window): - def __init__( - self, - ): + def __init__(self): super().__init__( layer="top", anchor="left bottom right", @@ -31,6 +33,8 @@ class Bar(Window): visible=False, all_visible=False, ) + self.screen_recorder = ScreenRecorder() + self.workspaces = Button(child=workspace, name="workspaces") self.language = Language( formatter=FormattedString( "{replace_lang(language)}", @@ -42,25 +46,38 @@ class Bar(Window): ), ), ) - self.date_time = DateTime(formatters=["%-I:%M 󰧞 %a %d %b"], name="datetime") - self.system_tray = SystemTray(name="tray", spacing=4, icon_size=18) - self.taskbar = TaskBar() - self.volume = VolumeIndicator() - self.network = Network() - self.bluetooth = Bluetooth() + + self.recording_indicator = Button( + name="bar-button", + child=MaterialIcon("screen_record", size="16px"), + visible=False, + on_clicked=lambda *_: self.screen_recorder.screencast_stop(), + ) + + self.screen_recorder.connect( + "recording", + lambda _, status: self.recording_indicator.set_visible(status), + ) + self.battery = BatteryLabel(name="battery") + self.volume = VolumeIndicator() + self.bluetooth = BluetoothIndicator() + self.network = NetworkIndicator() self.microphone = MicrophoneIndicator() - self.power = PowerProfile() - self.workspaces = Button(child=workspace, name="workspaces") - self.info = SystemInfo() self.idle = IdleIndicator() + self.taskbar = TaskBar() + self.info = SystemInfo() + self.powerindicator = PowerProfileIndicator() + self.tray = SystemTray() + self.applets = Box( name="applets", spacing=4, + orientation="h", children=[ self.language, - self.power, + self.powerindicator, self.bluetooth, self.network, self.volume, @@ -84,16 +101,15 @@ class Bar(Window): name="center-container", spacing=8, orientation="h", - children=[ - self.taskbar, - ], + children=self.taskbar, ), end_children=Box( name="end-container", spacing=8, orientation="h", children=[ - self.system_tray, + # self.recording_indicator, + self.tray, self.battery, self.applets, self.date_time, diff --git a/config/fabric/modules/bar/style.css b/config/fabric/modules/bar/style.css new file mode 100644 index 00000000..1610c7ec --- /dev/null +++ b/config/fabric/modules/bar/style.css @@ -0,0 +1,203 @@ +/* we can use webcss variables, fabric compiles that to gtk css. + global variables can be stored in :vars */ +:vars { + --background: #150d16; + --foreground: #f5dbc4; + --color0: #150d16; + --color1: #72448d; + --color2: #9c5995; + --color3: #d5719f; + --color4: #9a62f3; + --color5: #e075df; + --color6: #f98f9f; + --color7: #f5dbc4; + --color8: #ab9989; + --color9: #72448d; + --color10: #9c5995; + --color11: #d5719f; + --color12: #9a62f3; + --color13: #e075df; + --color14: #f98f9f; + --color15: #f5dbc4; + --window-bg: alpha(var(--background), 0.6); + --module-bg: alpha(var(--background), 0.4); + --border-color: var(--color11); + --ws-active: var(--color9); + --ws-inactive: var(--color3); + --ws-empty: var(--color8); + --ws-hover: var(--color1); + --ws-urgent: var(--color12); +} + +@import url(../../../.cache/material/colors.css); + +#bar { + background-color: @surface; + padding: 3px; +} + +#bar label { + font-weight: bold; +} + +#start-container, +#center-container, +#end-container { + padding-top: 6px; + padding-bottom: 6px; + margin-left: 12px; + margin-right: 12px; +} + +#battery { + background-color: @surfaceContainer; + border-radius: 100px; + padding: 2px 10px 2px 10px; +} + +#workspaces { + border-radius: 100px; + font-style: normal; + background: @surfaceContainer; + padding: 0px 10px 0px 10px; +} + +#datetime { + background-color: @surfaceContainer; + border-radius: 100px; + padding: 8px; +} + +#applets { + background-color: @surfaceContainer; + border-radius: 100px; + padding: 2px 10px 2px 10px; + margin: 0px; +} + +#applets .icon { + color: @onSurface; + font-weight: 900; +} + +#applets > button { + color: @onSurface; + margin: 0px; + padding: 0px; +} + +#taskbar { + border-radius: 100px; + font-weight: bold; + font-style: normal; + color: @onSurface; + background: @surfaceContainer; + padding-left: 4px; + padding-right: 4px; +} + +#taskbar .activated { + border-radius: 100px; + background: @surfaceVariant; +} + +#taskbar > button { + padding: 0px 4px; + margin: 4px 0px; + border-radius: 100px; + border: 0px; +} +#taskbar > button:last-child { + margin-right: 0px; +} + +#info { + background-color: @surfaceContainer; + border-radius: 100px; + padding: 2px 10px 0px 10px; +} + +#info > button { + margin: 0px; + padding: 0px; +} + +#info .progress { + color: lighter(@outlineVariant); + border: 2px solid @onSecondaryContainer; +} + +#material_icon, +#material_icon * { + all: unset; + font-family: "Material Symbols Outlined", "Material Symbols Sharp"; +} + +/* unset so we can style everything from the ground up. */ +* { + all: unset; + color: @foreground; + font-size: 16px; + font-family: "Product Sans", Roboto, "Font Awesome 6 Free", Helvetica, Arial, + sans-serif; +} + +button { + background-size: 400% 400%; +} + +menu > menuitem > label { + font-weight: 900; +} + +/* system tray */ +#system-tray { + padding: 2px 4px; + background-color: var(--module-bg); +} + +/* menu and menu items (written for the system tray) */ +menu { + border: solid 2px; + border-radius: 10px; + border-color: var(--border-color); + background-color: var(--window-bg); +} + +menu > menuitem { + border-radius: 0px; + background-color: var(--module-bg); + padding: 6px; + margin-left: 2px; + margin-right: 2px; +} + +menu > menuitem:first-child { + margin-top: 1px; + border-radius: 8px 8px 0px 0px; +} + +menu > menuitem:last-child { + margin-bottom: 1px; + border-radius: 0px 0px 8px 8px; +} + +menu > menuitem:hover { + background-color: var(--border-color); +} + +tooltip { + background-color: @surfaceContainer; + border-radius: 11px; + outline: none; + border: none; + box-shadow: none; +} + +tooltip label { + color: @onSurface; + outline: none; + border: none; + box-shadow: none; + font-weight: normal; +} diff --git a/config/fabric/modules/bar/widgets/__init__.py b/config/fabric/modules/bar/widgets/__init__.py index 27ff16e8..a2f39b03 100644 --- a/config/fabric/modules/bar/widgets/__init__.py +++ b/config/fabric/modules/bar/widgets/__init__.py @@ -1,23 +1,11 @@ -from .battery import BatteryLabel -from .bluetooth import Bluetooth -from .idle_indicator import IdleIndicator -from .info import SystemInfo -from .microphone import MicrophoneIndicator -from .network import Network -from .powerprofile import PowerProfile -from .taskbar import TaskBar -from .volume import VolumeIndicator -from .workspace import workspace - -__all__ = [ - "BatteryLabel", - "Bluetooth", - "IdleIndicator", - "SystemInfo", - "MicrophoneIndicator", - "Network", - "PowerProfile", - "VolumeIndicator", - "workspace", - "TaskBar", -] +from .battery import * +from .bluetooth import * +from .idle import * +from .info import * +from .microphone import * +from .network import * +from .powerprofile import * +from .taskbar import * +from .tray import * +from .volume import * +from .workspace import * diff --git a/config/fabric/modules/bar/widgets/bluetooth.py b/config/fabric/modules/bar/widgets/bluetooth.py index a91dd160..0252385a 100644 --- a/config/fabric/modules/bar/widgets/bluetooth.py +++ b/config/fabric/modules/bar/widgets/bluetooth.py @@ -3,7 +3,7 @@ from fabric.widgets.box import Box from snippets import MaterialIcon -class Bluetooth(Box): +class BluetoothIndicator(Box): ICON_ENABLED = "bluetooth" ICON_DISABLED = "bluetooth_disabled" @@ -17,7 +17,7 @@ class Bluetooth(Box): self.update_bluetooth_status() - def update_bluetooth_status(self, *args): + def update_bluetooth_status(self, *_): icon_label = ( self.ICON_ENABLED if self.bluetooth_client.enabled else self.ICON_DISABLED ) diff --git a/config/fabric/modules/bar/widgets/icon.py b/config/fabric/modules/bar/widgets/icon.py new file mode 100644 index 00000000..7bf8e7ac --- /dev/null +++ b/config/fabric/modules/bar/widgets/icon.py @@ -0,0 +1,16 @@ +from fabric.widgets.label import Label + + +def MaterialIcon(icon_name: str, size: str = "24px", props: dict = None): + label_props = { + "label": icon_name, # Directly use the provided icon name + "name": "material_icon", + "style": f"font-size: {size}; ", # Set font family for Material Icons + "h_align": "center", # Align horizontally + "v_align": "center", # Align vertically + } + + if props: + label_props.update(props) + + return Label(**label_props) diff --git a/config/fabric/modules/bar/widgets/idle.py b/config/fabric/modules/bar/widgets/idle.py new file mode 100644 index 00000000..e93d44a1 --- /dev/null +++ b/config/fabric/modules/bar/widgets/idle.py @@ -0,0 +1,29 @@ +from fabric import Fabricator +from fabric.utils import exec_shell_command +from fabric.widgets.box import Box +from snippets import MaterialIcon + + +class IdleIndicator(Box): + + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.idle_icon = self.create_idle_icon() + self.fabricator = Fabricator(interval=1000, poll_from=self.check_idle_status) + + self.children = [self.idle_icon] + + def create_idle_icon(self): + return MaterialIcon("schedule", size="16px") + + 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) + + def update_idle_status(self, is_idle): + if is_idle: + self.idle_icon.set_visible(True) + else: + self.idle_icon.set_visible(False) diff --git a/config/fabric/modules/bar/widgets/idle_indicator.py b/config/fabric/modules/bar/widgets/idle_indicator.py deleted file mode 100644 index 886afd14..00000000 --- a/config/fabric/modules/bar/widgets/idle_indicator.py +++ /dev/null @@ -1,38 +0,0 @@ -from fabric import Fabricator -from fabric.utils import exec_shell_command -from fabric.widgets.box import Box -from snippets import MaterialIcon - - -class IdleIndicator(Box): - ICON_IDLE = "schedule" - - def __init__(self, **kwargs): - super().__init__(**kwargs) - self.idle_icon = self.create_idle_icon() - self.check_idle_status() - Fabricator(interval=1000, poll_from=self.check_idle_status) - self.children = (self.idle_icon,) - - def create_idle_icon(self): - return MaterialIcon(self.ICON_IDLE, size="16px") - - def check_idle_status(self, *_): - try: - output = exec_shell_command("pidof wayland-idle-inhibitor.py") - output_str = str(output) if output is not None else "" - is_idle = bool(output_str.strip()) - - self.update_idle_status(is_idle) - except Exception as e: - print(f"Error checking idle status: {e}") - self.update_idle_status(False) - - return True - - def update_idle_status(self, is_idle): - if is_idle: - self.idle_icon.set_label(self.ICON_IDLE) - self.idle_icon.set_visible(True) - else: - self.idle_icon.set_visible(False) diff --git a/config/fabric/modules/bar/widgets/info.py b/config/fabric/modules/bar/widgets/info.py index 9e16fbcd..fdebc438 100644 --- a/config/fabric/modules/bar/widgets/info.py +++ b/config/fabric/modules/bar/widgets/info.py @@ -18,10 +18,10 @@ class SystemInfo(Button): def __init__(self): super().__init__(child=self._initialize_content()) - Fabricator(poll_from=self._refresh_system_info, interval=1000) + self.fabricator = Fabricator(poll_from=self._refresh_system_info, interval=1000) def _initialize_content(self): - self.box = Box(orientation="h", name="tray") + self.box = Box(orientation="h", name="info") self.progress_bars = {} self.labels = {} self.icons = {} @@ -42,7 +42,7 @@ class SystemInfo(Button): def _create_progress_bar(self): return CircularProgressBar( - name="progress", line_style="round", line_width=1, size=30 + style_classes="progress", line_style="round", line_width=1, size=30 ) def _create_label(self): diff --git a/config/fabric/modules/bar/widgets/microphone.py b/config/fabric/modules/bar/widgets/microphone.py index d84a6dad..cc0d3a67 100644 --- a/config/fabric/modules/bar/widgets/microphone.py +++ b/config/fabric/modules/bar/widgets/microphone.py @@ -4,8 +4,6 @@ from snippets import MaterialIcon class MicrophoneIndicator(Box): - ICON_MUTED = "mic_off" - ICON_UNMUTED = "mic" def __init__(self, **kwargs): super().__init__(**kwargs) @@ -18,14 +16,14 @@ class MicrophoneIndicator(Box): self.children = (self.microphone_icon,) def create_microphone_icon(self): - return MaterialIcon(self.ICON_MUTED, size="16px") + return MaterialIcon("mic_off", size="16px") def update_microphone_status(self, *args): current_microphone = self.audio_service.microphone if current_microphone: is_muted = current_microphone.muted - icon_name = self.ICON_MUTED if is_muted else self.ICON_UNMUTED + icon_name = "mic_off" if is_muted else "mic" self.microphone_icon.set_label(icon_name) self.microphone_icon.set_visible(is_muted) diff --git a/config/fabric/modules/bar/widgets/network.py b/config/fabric/modules/bar/widgets/network.py index 565ec884..457d86d9 100644 --- a/config/fabric/modules/bar/widgets/network.py +++ b/config/fabric/modules/bar/widgets/network.py @@ -6,12 +6,13 @@ from fabric.widgets.box import Box from snippets import MaterialIcon -class Network(Box): +class NetworkIndicator(Box): def __init__(self, **kwargs): super().__init__(**kwargs) - self.update_interval = 1000 + self.update_interval = 5000 # Increased interval to 5 seconds self.last_status = None - Fabricator( + self.wifi_strength_cache = None + self.fabricator = Fabricator( interval=self.update_interval, poll_from=self.update_network_status, ) @@ -36,6 +37,10 @@ class Network(Box): def get_wifi_strength_icon(self): wifi_strength = self.check_wifi_strength() + if wifi_strength is not None: + self.wifi_strength_cache = wifi_strength # Cache the result + else: + wifi_strength = self.wifi_strength_cache # Use cached value if available return self.wifi_signal_icon(wifi_strength) diff --git a/config/fabric/modules/bar/widgets/powerprofile.py b/config/fabric/modules/bar/widgets/powerprofile.py index c59f2b01..e7cc93e0 100644 --- a/config/fabric/modules/bar/widgets/powerprofile.py +++ b/config/fabric/modules/bar/widgets/powerprofile.py @@ -10,13 +10,13 @@ PROFILE_ICONS = { } -class PowerProfile(Box): +class PowerProfileIndicator(Box): def __init__(self, **kwargs): super().__init__(**kwargs) self.profile_icon = None - Fabricator(interval=1000, poll_from=self.update_power_profile) + self.fabricator = Fabricator(interval=1000, poll_from=self.update_power_profile) def update_power_profile(self, *_): profile = self.get_power_profile() diff --git a/config/fabric/modules/bar/widgets/tray.py b/config/fabric/modules/bar/widgets/tray.py new file mode 100644 index 00000000..7fb3128b --- /dev/null +++ b/config/fabric/modules/bar/widgets/tray.py @@ -0,0 +1,76 @@ +import gi +from fabric.widgets.box import Box +from fabric.widgets.button import Button +from fabric.widgets.image import Image +from gi.repository import Gdk, GdkPixbuf, Gray, Gtk +from loguru import logger + +gi.require_version("Gray", "0.1") +gi.require_version("Gtk", "3.0") + + +class SystemTray(Box): + def __init__(self, pixel_size: int = 16, **kwargs) -> None: + super().__init__(name="system-tray", **kwargs) + self.pixel_size = pixel_size + self.watcher = Gray.Watcher() + self.watcher.connect("item-added", self.on_item_added) + + def on_item_added(self, _, identifier: str): + item = self.watcher.get_item_for_identifier(identifier) + item_button = self.do_bake_item_button(item) + item.connect("removed", lambda *args: item_button.destroy()) + item.connect( + "icon-changed", + lambda icon_item: self.do_update_item_button(icon_item, item_button), + ) + item_button.show_all() + self.add(item_button) + + def do_bake_item_button(self, item: Gray.Item) -> Button: + button = Button() + # context menu handler + button.connect( + "button-press-event", + lambda button, event: self.on_button_click(button, item, event), + ) + self.do_update_item_button(item, button) + + return button + + def do_update_item_button(self, item: Gray.Item, item_button: Button): + pixmap = Gray.get_pixmap_for_pixmaps(item.get_icon_pixmaps(), 24) + + # convert the pixmap to a pixbuf + pixbuf: GdkPixbuf.Pixbuf = ( + pixmap.as_pixbuf(self.config["icon_size"], GdkPixbuf.InterpType.HYPER) + if pixmap is not None + else Gtk.IconTheme() + .get_default() + .load_icon( + item.get_icon_name(), + self.pixel_size, + Gtk.IconLookupFlags.FORCE_SIZE, + ) + ) + item_button.set_image(Image(pixbuf=pixbuf, pixel_size=self.pixel_size)) + + def on_button_click(self, button, item: Gray.Item, event): + match event.button: + case 1: + try: + item.activate(event.x, event.y) + except Exception as e: + logger.error(e) + case 3: + menu = item.get_property("menu") + menu.set_name("system-tray-menu") + if menu: + menu.popup_at_widget( + button, + Gdk.Gravity.SOUTH, + Gdk.Gravity.NORTH, + event, + ) + else: + item.context_menu(event.x, event.y) diff --git a/config/fabric/modules/launcher/launcher.py b/config/fabric/modules/launcher/launcher.py index 5c7574f4..9d66db49 100644 --- a/config/fabric/modules/launcher/launcher.py +++ b/config/fabric/modules/launcher/launcher.py @@ -1,5 +1,7 @@ +from fabric import Application from fabric.utils import ( get_desktop_applications, + get_relative_path, idle_add, invoke_repeater, remove_handler, @@ -155,7 +157,7 @@ class Launcher(Window): if handler: handler(query[len(command) :].strip()) return - self.scrolled_revealer.unreveal() + if query.startswith(":"): self.additional_box.set_visible(False) self.update_dynamic_button([self.default_button]) @@ -224,21 +226,25 @@ class Launcher(Window): 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() 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() 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() 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() def show_shell_commands(self, query: str): if not query: @@ -249,6 +255,7 @@ class Launcher(Window): 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() def show_wallpapers(self, query: str): if query == "random": @@ -257,8 +264,17 @@ class Launcher(Window): 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() 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() + + +# if __name__ == "__main__": +# launcher = Launcher() +# app = Application("launcher", launcher) +# app.set_stylesheet_from_file(get_relative_path("./styles/main.css")) +# app.run() diff --git a/config/fabric/modules/launcher/widgets/__init__.py b/config/fabric/modules/launcher/widgets/__init__.py index 81e42e29..59567757 100644 --- a/config/fabric/modules/launcher/widgets/__init__.py +++ b/config/fabric/modules/launcher/widgets/__init__.py @@ -1,19 +1,8 @@ -from .app import handle_application_search -from .bluetooth import BluetoothMenu -from .clipboard import ClipboardManager -from .emoji import EmojiManager -from .power_menu import PowerMenu -from .shell import ShellCommandManager -from .wallpaper import WallpaperManager -from .wifi import WifiMenu - -__all__ = [ - "handle_application_search", - "ClipboardManager", - "EmojiManager", - "ShellCommandManager", - "WallpaperManager", - "WifiMenu", - "BluetoothMenu", - "PowerMenu", -] +from .app import * +from .bluetooth import * +from .clipboard import * +from .emoji import * +from .power_menu import * +from .shell import * +from .wallpaper import * +from .wifi import * diff --git a/config/fabric/modules/launcher/widgets/app.py b/config/fabric/modules/launcher/widgets/app.py index c97aaeb8..32d8aaca 100644 --- a/config/fabric/modules/launcher/widgets/app.py +++ b/config/fabric/modules/launcher/widgets/app.py @@ -6,10 +6,10 @@ from fabric.widgets.label import Label def handle_application_search(launcher, query: str): if not query.strip(): - launcher.scrolled_revealer.unreveal() launcher.additional_box.set_visible(True) return + launcher.additional_box.set_visible(False) filtered_apps = [ app for app in launcher.all_apps @@ -28,7 +28,6 @@ def handle_application_search(launcher, query: str): bake_application_slot(launcher, app) for app in filtered_apps[:6] ] launcher.scrolled_revealer.reveal() - launcher.additional_box.set_visible(False) else: launcher.scrolled_revealer.unreveal() diff --git a/config/fabric/modules/launcher/widgets/bluetooth.py b/config/fabric/modules/launcher/widgets/bluetooth.py index 03cd0523..56f54099 100644 --- a/config/fabric/modules/launcher/widgets/bluetooth.py +++ b/config/fabric/modules/launcher/widgets/bluetooth.py @@ -42,7 +42,7 @@ class BluetoothMenu: style = ( "background-color: transparent;" if self.client.enabled - else "background-color: @surfaceVariant; min-height: 50px; min-width: 50px;" + else "background-color: @surfaceVariant; border-radius:100px; min-height: 50px; min-width: 50px;" ) self.bt_button.set_style(style) diff --git a/config/fabric/modules/launcher/widgets/noti.py b/config/fabric/modules/launcher/widgets/noti.py new file mode 100644 index 00000000..dd5900a8 --- /dev/null +++ b/config/fabric/modules/launcher/widgets/noti.py @@ -0,0 +1,96 @@ +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 NotificationManager: + def __init__(self, launcher): + self.launcher = launcher + self.notifications = [] + + self.notification_button = self.create_notification_button() + self.update_notification_button_style() + + def create_notification_button(self): + button = Button( + child=MaterialIcon("notifications"), + h_align="center", + v_align="center", + on_clicked=self.show_notification_menu, + ) + return button + + def add_notification(self, title, message, icon_name="notifications"): + """Add a new notification.""" + notification = { + "title": title, + "message": message, + "icon_name": icon_name, + } + self.notifications.append(notification) + self.update_notification_button_style() + + def remove_notification(self, index): + """Remove a notification by index.""" + if 0 <= index < len(self.notifications): + del self.notifications[index] + self.update_notification_button_style() + + def clear_notifications(self): + """Clear all notifications.""" + self.notifications.clear() + self.update_notification_button_style() + + def update_notification_button_style(self): + """Update the notification button style based on the notification count.""" + count = len(self.notifications) + if count > 0: + style = "background-color: @surfaceVariant; border-radius: 50%;" + self.notification_button.set_style(style) + self.notification_button.set_label(str(count)) + else: + style = "background-color: transparent;" + self.notification_button.set_style(style) + self.notification_button.set_label("") + + def show_notification_menu(self, *_): + """Display the notification menu.""" + viewport = self.launcher.viewport + viewport.children = [] + notifications_box = Box(orientation="v", spacing=5) + + for index, notification in enumerate(self.notifications): + notification_button = self.create_notification_button_item( + notification, index + ) + notifications_box.add(notification_button) + + viewport.add(notifications_box) + + def create_notification_button_item(self, notification, index): + """Create a button for an individual notification.""" + return Button( + child=Box( + orientation="h", + spacing=10, + children=[ + Image(icon_name=notification["icon_name"], size=32), + Box( + orientation="v", + spacing=2, + children=[ + Label(label=notification["title"], bold=True), + Label(label=notification["message"]), + ], + ), + ], + ), + on_clicked=lambda _, idx=index: self.remove_notification(idx), + name="notification-item", + ) + + def get_notification_button(self): + """Get the notification button for the UI.""" + return self.notification_button diff --git a/config/fabric/modules/launcher/widgets/wallpaper.py b/config/fabric/modules/launcher/widgets/wallpaper.py index c08eeec6..c44d2121 100644 --- a/config/fabric/modules/launcher/widgets/wallpaper.py +++ b/config/fabric/modules/launcher/widgets/wallpaper.py @@ -12,7 +12,7 @@ from snippets import MaterialIcon class WallpaperManager: IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".webp"} - CACHE_DIR = os.path.expanduser("~/.cache/fabric/thumbnails/wallpapers") + CACHE_DIR = os.path.expanduser("~/.cache/fabric/wall") WALLPAPER_SCRIPT_PATH = os.path.expanduser("~/dotfiles/hypr/scripts/wallpaper.py") def __init__(self): diff --git a/config/fabric/modules/launcher/widgets/wallpaper1.py b/config/fabric/modules/launcher/widgets/wallpaper1.py new file mode 100644 index 00000000..ee03d514 --- /dev/null +++ b/config/fabric/modules/launcher/widgets/wallpaper1.py @@ -0,0 +1,166 @@ +import os +import threading +from pathlib import Path + +from fabric.utils import exec_shell_command, exec_shell_command_async +from fabric.widgets.box import Box +from fabric.widgets.button import Button +from loguru import logger +from snippets import MaterialIcon + + +class WallpaperManager: + IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".webp"} + THUMBNAIL_SIZE = "x64" + THUMBNAIL_ASPECT_RATIO = "1:1" + WALLPAPER_SCRIPT_PATH = os.path.expanduser("~/dotfiles/hypr/scripts/wallpaper.py") + + def __init__(self): + self.wallpaper_dir = Path.home() / "Pictures" / "wallpapers" + self.thumbnail_dir = ( + Path.home() / ".cache" / "fabric" / "thumbnails" / "wallpapers" + ) + self.thumbnail_dir.mkdir(parents=True, exist_ok=True) + 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 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_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 ( + f + for f in self.wallpaper_dir.iterdir() + if f.is_file() + and f.suffix.lower() in self.IMAGE_EXTENSIONS + and self._matches_search(f, search_term) + ) + + def _matches_search(self, file, search_term: str): + return not search_term or search_term.lower() in file.name.lower() + + def _generate_thumbnail(self, wallpaper_path): + thumbnail_path = self.thumbnail_dir / wallpaper_path.name + if not thumbnail_path.exists(): + threading.Thread( + target=self._create_thumbnail, + args=(wallpaper_path, thumbnail_path), + daemon=True, + ).start() + return thumbnail_path + + def _create_thumbnail(self, wallpaper_path, thumbnail_path): + logger.debug(f"Generating thumbnail for {wallpaper_path}") + exec_shell_command_async( + [ + "magick", + str(wallpaper_path), + "-resize", + self.THUMBNAIL_SIZE, + "-gravity", + "Center", + "-extent", + self.THUMBNAIL_ASPECT_RATIO, + str(thumbnail_path), + ], + lambda *args: logger.debug(args), + ) + + 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 _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 _select_wallpaper(self, wallpaper_path): + self._apply_wallpaper(wallpaper_path) + + def _apply_wallpaper(self, wallpaper_path): + self._execute_wallpaper_script("--image", str(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/notifications.py b/config/fabric/modules/notifications.py index 24143c3c..f878268a 100644 --- a/config/fabric/modules/notifications.py +++ b/config/fabric/modules/notifications.py @@ -2,8 +2,6 @@ import gi gi.require_version("GdkPixbuf", "2.0") -from gi.repository import GdkPixbuf, GLib - from fabric.notifications import ( Notification, NotificationAction, @@ -17,6 +15,7 @@ from fabric.widgets.image import Image from fabric.widgets.label import Label from fabric.widgets.revealer import Revealer from fabric.widgets.wayland import WaylandWindow as Window +from gi.repository import GdkPixbuf from snippets import CustomImage diff --git a/config/fabric/services/__init__.py b/config/fabric/services/__init__.py index 66757f24..7373da1a 100644 --- a/config/fabric/services/__init__.py +++ b/config/fabric/services/__init__.py @@ -1,10 +1,3 @@ -from .brightness import Brightness -from .screen_record import ScreenRecorder -from .wifi import NetworkClient, Wifi - -__all__ = [ - "Brightness", - "ScreenRecorder", - "NetworkClient", - "Wifi", -] +from .brightness import * +from .screen_record import * +from .wifi import * diff --git a/config/fabric/services/screen_record.py b/config/fabric/services/screen_record.py index 2d59621d..20f23869 100644 --- a/config/fabric/services/screen_record.py +++ b/config/fabric/services/screen_record.py @@ -11,11 +11,22 @@ class ScreenRecorder(Service): @Signal def recording(self, value: bool) -> None: ... + _instance = None + def __init__(self, **kwargs): + if hasattr(self, "_initialized") and self._initialized: + return self.screenshot_path = GLib.get_home_dir() + "/Pictures/Screenshots/" self.screenrecord_path = GLib.get_home_dir() + "/Videos/Screencasting/" + self._current_screencast_path = None super().__init__(**kwargs) + self._initialized = True + + def __new__(cls, *args, **kwargs): + if not cls._instance: + cls._instance = super(ScreenRecorder, cls).__new__(cls, *args, **kwargs) + return cls._instance def screenshot(self, fullscreen=False, save_copy=True): time = datetime.datetime.today().strftime("%Y-%m-%d_%H-%M-%S") @@ -44,18 +55,27 @@ class ScreenRecorder(Service): 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: - f"-g '{exec_shell_command('slurp')}'" + area = "" if fullscreen else f"-g '{exec_shell_command('slurp')}'" command = f"wf-recorder --file={file_path} --pixel-format yuv420p {area}" exec_shell_command_async(command) self.emit("recording", True) def screencast_stop(self): + if not self.is_recording: + logger.error("[SCREENRECORD] No active recording to stop") + return exec_shell_command_async("killall -INT wf-recorder") self.emit("recording", False) self.send_screencast_notification(self._current_screencast_path) + # def screencast_stop(self): + # exec_shell_command_async("killall -INT wf-recorder") + # self.emit("recording", False) + # if hasattr(self, "_current_screencast_path") and self._current_screencast_path: + # self.send_screencast_notification(self._current_screencast_path) + # else: + # logger.error("[SCREENRECORD] No active screencast to stop") + # def send_screencast_notification(self, file_path): # TODO: Generate a thumbnail # exec_shell_command_async(f"totem-video-thumbnailer {file_path} {FABRIC_CACHE}") diff --git a/config/fabric/snippets/__init__.py b/config/fabric/snippets/__init__.py index 86892477..add4b114 100644 --- a/config/fabric/snippets/__init__.py +++ b/config/fabric/snippets/__init__.py @@ -1,21 +1,5 @@ -from .animator import Animator -from .custom_image import CustomImage -from .functions import ( - get_current_uptime, - get_profile_picture_path, - read_config, - username, -) -from .icon import MaterialIcon -from .icon_resolver import IconResolver - -__all__ = [ - "Animator", - "MaterialIcon", - "read_config", - "get_profile_picture_path", - "username", - "IconResolver", - "get_current_uptime", - "CustomImage", -] +from .animator import * +from .custom_image import * +from .functions import * +from .icon import * +from .icon_resolver import * diff --git a/config/fabric/snippets/popup.py b/config/fabric/snippets/popup.py new file mode 100644 index 00000000..cfcc3e7a --- /dev/null +++ b/config/fabric/snippets/popup.py @@ -0,0 +1,313 @@ +from typing import Literal + +from fabric.widgets.box import Box +from fabric.widgets.eventbox import EventBox +from fabric.widgets.revealer import Revealer +from fabric.widgets.wayland import WaylandWindow +from fabric.widgets.widget import Widget +from gi.repository import GLib + + +class Padding(EventBox): + def __init__(self, name: str | None = None, style: str = "", **kwargs): + super().__init__( + name=name, + h_expand=True, + v_expand=True, + child=Box(style=style, h_expand=True, v_expand=True), + events=["button-press"], + **kwargs, + ) + self.set_can_focus(False) + + +class PopupRevealer(Box): + def __init__( + self, + popup_window: WaylandWindow, + decorations: str = "padding: 1px;", + name: str | None = None, + child: Widget | None = None, + transition_type: Literal[ + "none", + "crossfade", + "slide-right", + "slide-left", + "slide-up", + "slide-down", + ] = "slide-down", + transition_duration: int = 400, + ): + self.revealer: Revealer = Revealer( + name=name, + child=child, + transition_type=transition_type, + transition_duration=transition_duration, + notify_child_revealed=lambda revealer, _: ( + [ + revealer.hide(), + popup_window.set_visible(False), + ] + if not revealer.fully_revealed + else None + ), + notify_reveal_child=lambda revealer, _: ( + [ + popup_window.set_visible(True), + ] + if revealer.child_revealed + else None + ), + ) + super().__init__( + style=decorations, + children=self.revealer, + ) + + +def make_layout(anchor: str, name: str, popup: PopupRevealer, **kwargs) -> Box: + match anchor: + case "center-left": + return Box( + children=[ + Box( + orientation="vertical", + children=[ + Padding(name=name, **kwargs), + popup, + Padding(name=name, **kwargs), + ], + ), + Padding(name=name, **kwargs), + ] + ) + + case "center": + return Box( + children=[ + Padding(name=name, **kwargs), + Box( + orientation="vertical", + children=[ + Padding(name=name, **kwargs), + popup, + Padding(name=name, **kwargs), + ], + ), + Padding(name=name, **kwargs), + ] + ) + case "center-right": + return Box( + children=[ + Padding(name=name, **kwargs), + Box( + orientation="vertical", + children=[ + Padding(name=name, **kwargs), + popup, + Padding(name=name, **kwargs), + ], + ), + ] + ) + case "top": + return Box( + children=[ + Padding(name=name, **kwargs), + Box( + orientation="vertical", + children=[popup, Padding(name=name, **kwargs)], + ), + Padding(name=name, **kwargs), + ] + ) + case "top-right": + return Box( + children=[ + Padding(name=name, **kwargs), + Box( + h_expand=False, + orientation="vertical", + children=[popup, Padding(name=name, **kwargs)], + ), + ] + ) + case "top-center": + return Box( + children=[ + Padding(name=name, **kwargs), + Box( + h_expand=False, + orientation="vertical", + children=[popup, Padding(name=name, **kwargs)], + ), + Padding(name=name, **kwargs), + ] + ) + case "top-left": + return Box( + children=[ + Box( + h_expand=False, + orientation="vertical", + children=[popup, Padding(name=name, **kwargs)], + ), + Padding(name=name, **kwargs), + ] + ) + case "bottom-left": + return Box( + children=[ + Box( + h_expand=False, + orientation="vertical", + children=[Padding(name=name, **kwargs), popup], + ), + Padding(name=name, **kwargs), + ] + ) + case "bottom-center": + return Box( + children=[ + Padding(name=name, **kwargs), + Box( + h_expand=False, + orientation="vertical", + children=[Padding(name=name, **kwargs), popup], + ), + Padding(name=name, **kwargs), + ] + ) + case "bottom-right": + return Box( + children=[ + Padding(name=name, **kwargs), + Box( + h_expand=True, + orientation="vertical", + children=[Padding(name=name, **kwargs), popup], + ), + ] + ) + case _: + return None + + +class PopupWindow(WaylandWindow): + def __init__( + self, + name: str = "popup-window", + decorations: str = "padding: 1px;", + child: Widget | None = None, + transition_type: ( + Literal[ + "none", + "crossfade", + "slide-right", + "slide-left", + "slide-up", + "slide-down", + ] + | None + ) = None, + transition_duration: int = 100, + popup_visible: bool = False, + anchor: Literal[ + "center-left", + "center", + "center-right", + "top", + "top-right", + "top-center", + "top-left", + "bottom-left", + "bottom-center", + "bottom-right", + ] = "top-right", + enable_inhibitor: bool = False, + keyboard_mode: Literal["none", "exclusive", "on-demand"] = "on-demand", + timeout: int = 1000, + **kwargs, + ): + self.timeout = timeout + self.currtimeout = 0 + self.popup_running = False + + self.popup_visible = popup_visible + + self.enable_inhibitor = enable_inhibitor + + self.monitor_number: int | None = None + + self.reveal_child = PopupRevealer( + name=name, + popup_window=self, + child=child, + transition_type=transition_type, + transition_duration=transition_duration, + decorations=decorations, + ) + + super().__init__( + layer="top", + keyboard_mode=keyboard_mode, + visible=False, + exclusivity="normal", + anchor="top bottom right left", + child=make_layout( + anchor=anchor, + name=name, + popup=self.reveal_child, + on_button_press_event=self.on_inhibit_click, + ), + on_key_release_event=self.on_key_release, + ) + + def on_key_release(self, _, event_key): + if event_key.get_keycode()[1] == 9: + self.popup_visible = False + self.reveal_child.revealer.set_reveal_child(self.popup_visible) + + def on_inhibit_click(self, *_): + self.popup_visible = False + self.reveal_child.revealer.set_reveal_child(self.popup_visible) + + def toggle_popup(self, monitor: bool = False): + if monitor: + curr_monitor = self.hyprland_monitor.get_current_gdk_monitor_id() + self.monitor = curr_monitor + if self.monitor_number != curr_monitor and self.popup_visible: + self.monitor_number = curr_monitor + return + + self.monitor_number = curr_monitor + + if not self.popup_visible: + self.reveal_child.revealer.show() + + self.popup_visible = not self.popup_visible + self.reveal_child.revealer.set_reveal_child(self.popup_visible) + + def popup_timeout(self): + + if not self.popup_visible: + self.reveal_child.revealer.show() + if self.popup_running: + self.currtimeout = 0 + return + self.popup_visible = True + self.reveal_child.revealer.set_reveal_child(self.popup_visible) + self.popup_running = True + + def popup_func(): + if self.currtimeout >= self.timeout: + self.popup_visible = False + self.reveal_child.revealer.set_reveal_child(self.popup_visible) + self.currtimeout = 0 + self.popup_running = False + return False + self.currtimeout += 500 + return True + + GLib.timeout_add(500, popup_func) diff --git a/config/fabric/styles/activelinux.css b/config/fabric/styles/activelinux.css new file mode 100644 index 00000000..47d66faf --- /dev/null +++ b/config/fabric/styles/activelinux.css @@ -0,0 +1,8 @@ +#big { + font-weight: 500; + font-size: 18px; +} +#small { + font-weight: 400; + font-size: 14px; +} diff --git a/config/fabric/styles/bar.css b/config/fabric/styles/bar.css index 6d8af42b..07ce3eaa 100644 --- a/config/fabric/styles/bar.css +++ b/config/fabric/styles/bar.css @@ -7,6 +7,10 @@ font-weight: bold; } +#corner { + background-color: @surface; +} + /* * ── bar moudles ─────────────────────────────────────────────────────── */ @@ -71,33 +75,23 @@ } /* - * ── tray ────────────────────────────────────────────────────────────── +* ─── info ────────────────────────────────────────────────────────────── */ -#tray { +#info { background-color: @surfaceContainer; border-radius: 100px; padding: 2px 10px 0px 10px; } -#tray > button { +#info > button { margin: 0px; padding: 0px; } -menu { - background-color: @surfaceContainer; -} - -menu > menuitem { - border-radius: 12px; - padding: 10px; - margin-left: 2px; - margin-right: 2px; -} - -menu > menuitem:hover { - background-color: mix(@onSurface, @surface, 0.85); +#info .progress { + color: lighter(@outlineVariant); + border: 2px solid @onSecondaryContainer; } /* @@ -151,7 +145,43 @@ menu > menuitem:hover { margin-right: 0px; } -#progress { - color: lighter(@outlineVariant); - border: 2px solid @onSecondaryContainer; +/* systemtray */ + +#system-tray { + padding: 0.125em 0.25em; + background-color: @surfaceContainer; + border-radius: 100px; +} + +#system-tray > button { + margin: 0 0.1em; + padding: 0 0.15em; + border-radius: 100px; +} + +#system-tray-menu > menuitem menu, +#system-tray-menu { + background-color: @surfaceContainer; + border-radius: 1em; + padding: 10px; + min-width: 100px; +} + +#system-tray-menu > menuitem menu > menuitem, +#system-tray-menu > menuitem { + margin: 5px 0px; + background-color: @surfaceContainer; + padding: 0.3em 0.5em; + border-radius: 10px; +} + +#system-tray-menu > menuitem menu > menuitem:disabled, +#system-tray-menu > menuitem:disabled { + background-color: transparent; +} + +#system-tray-menu > menuitem menu > menuitem:hover, +#system-tray-menu > menuitem:hover, +#submenu-button:hover { + background-color: @surface; } diff --git a/config/fabric/styles/main.css b/config/fabric/styles/main.css index 79ebe208..0242029a 100644 --- a/config/fabric/styles/main.css +++ b/config/fabric/styles/main.css @@ -1,4 +1,4 @@ -@import url(../../.cache/material/colors.css); +@import url(../../../.cache/material/colors.css); @import "launcher.css"; @import "bar.css"; @import "notification.css"; -- 2.43.0 From fab594a1a71b619279d89bc34b166e10a2b647f9 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 12 Dec 2024 13:49:50 +0545 Subject: [PATCH 11/19] huge update --- config/fabric/styles/activelinux.css | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 config/fabric/styles/activelinux.css diff --git a/config/fabric/styles/activelinux.css b/config/fabric/styles/activelinux.css deleted file mode 100644 index 47d66faf..00000000 --- a/config/fabric/styles/activelinux.css +++ /dev/null @@ -1,8 +0,0 @@ -#big { - font-weight: 500; - font-size: 18px; -} -#small { - font-weight: 400; - font-size: 14px; -} -- 2.43.0 From 40274dcab2036d36a1fbf7c3701484c0fdb2bcad Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 12 Dec 2024 16:26:10 +0545 Subject: [PATCH 12/19] fix --- .../fabric/modules/launcher/widgets/noti.py | 96 ------ config/fabric/snippets/icon.py | 4 +- config/fabric/snippets/popup.py | 313 ------------------ 3 files changed, 2 insertions(+), 411 deletions(-) delete mode 100644 config/fabric/modules/launcher/widgets/noti.py delete mode 100644 config/fabric/snippets/popup.py diff --git a/config/fabric/modules/launcher/widgets/noti.py b/config/fabric/modules/launcher/widgets/noti.py deleted file mode 100644 index dd5900a8..00000000 --- a/config/fabric/modules/launcher/widgets/noti.py +++ /dev/null @@ -1,96 +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 snippets import MaterialIcon - - -class NotificationManager: - def __init__(self, launcher): - self.launcher = launcher - self.notifications = [] - - self.notification_button = self.create_notification_button() - self.update_notification_button_style() - - def create_notification_button(self): - button = Button( - child=MaterialIcon("notifications"), - h_align="center", - v_align="center", - on_clicked=self.show_notification_menu, - ) - return button - - def add_notification(self, title, message, icon_name="notifications"): - """Add a new notification.""" - notification = { - "title": title, - "message": message, - "icon_name": icon_name, - } - self.notifications.append(notification) - self.update_notification_button_style() - - def remove_notification(self, index): - """Remove a notification by index.""" - if 0 <= index < len(self.notifications): - del self.notifications[index] - self.update_notification_button_style() - - def clear_notifications(self): - """Clear all notifications.""" - self.notifications.clear() - self.update_notification_button_style() - - def update_notification_button_style(self): - """Update the notification button style based on the notification count.""" - count = len(self.notifications) - if count > 0: - style = "background-color: @surfaceVariant; border-radius: 50%;" - self.notification_button.set_style(style) - self.notification_button.set_label(str(count)) - else: - style = "background-color: transparent;" - self.notification_button.set_style(style) - self.notification_button.set_label("") - - def show_notification_menu(self, *_): - """Display the notification menu.""" - viewport = self.launcher.viewport - viewport.children = [] - notifications_box = Box(orientation="v", spacing=5) - - for index, notification in enumerate(self.notifications): - notification_button = self.create_notification_button_item( - notification, index - ) - notifications_box.add(notification_button) - - viewport.add(notifications_box) - - def create_notification_button_item(self, notification, index): - """Create a button for an individual notification.""" - return Button( - child=Box( - orientation="h", - spacing=10, - children=[ - Image(icon_name=notification["icon_name"], size=32), - Box( - orientation="v", - spacing=2, - children=[ - Label(label=notification["title"], bold=True), - Label(label=notification["message"]), - ], - ), - ], - ), - on_clicked=lambda _, idx=index: self.remove_notification(idx), - name="notification-item", - ) - - def get_notification_button(self): - """Get the notification button for the UI.""" - return self.notification_button diff --git a/config/fabric/snippets/icon.py b/config/fabric/snippets/icon.py index 7bf8e7ac..99027003 100644 --- a/config/fabric/snippets/icon.py +++ b/config/fabric/snippets/icon.py @@ -1,9 +1,9 @@ from fabric.widgets.label import Label -def MaterialIcon(icon_name: str, size: str = "24px", props: dict = None): +def MaterialIcon(icon_name: str, size: str = "24px", props=None): label_props = { - "label": icon_name, # Directly use the provided icon name + "label": str(icon_name), # Directly use the provided icon name "name": "material_icon", "style": f"font-size: {size}; ", # Set font family for Material Icons "h_align": "center", # Align horizontally diff --git a/config/fabric/snippets/popup.py b/config/fabric/snippets/popup.py deleted file mode 100644 index cfcc3e7a..00000000 --- a/config/fabric/snippets/popup.py +++ /dev/null @@ -1,313 +0,0 @@ -from typing import Literal - -from fabric.widgets.box import Box -from fabric.widgets.eventbox import EventBox -from fabric.widgets.revealer import Revealer -from fabric.widgets.wayland import WaylandWindow -from fabric.widgets.widget import Widget -from gi.repository import GLib - - -class Padding(EventBox): - def __init__(self, name: str | None = None, style: str = "", **kwargs): - super().__init__( - name=name, - h_expand=True, - v_expand=True, - child=Box(style=style, h_expand=True, v_expand=True), - events=["button-press"], - **kwargs, - ) - self.set_can_focus(False) - - -class PopupRevealer(Box): - def __init__( - self, - popup_window: WaylandWindow, - decorations: str = "padding: 1px;", - name: str | None = None, - child: Widget | None = None, - transition_type: Literal[ - "none", - "crossfade", - "slide-right", - "slide-left", - "slide-up", - "slide-down", - ] = "slide-down", - transition_duration: int = 400, - ): - self.revealer: Revealer = Revealer( - name=name, - child=child, - transition_type=transition_type, - transition_duration=transition_duration, - notify_child_revealed=lambda revealer, _: ( - [ - revealer.hide(), - popup_window.set_visible(False), - ] - if not revealer.fully_revealed - else None - ), - notify_reveal_child=lambda revealer, _: ( - [ - popup_window.set_visible(True), - ] - if revealer.child_revealed - else None - ), - ) - super().__init__( - style=decorations, - children=self.revealer, - ) - - -def make_layout(anchor: str, name: str, popup: PopupRevealer, **kwargs) -> Box: - match anchor: - case "center-left": - return Box( - children=[ - Box( - orientation="vertical", - children=[ - Padding(name=name, **kwargs), - popup, - Padding(name=name, **kwargs), - ], - ), - Padding(name=name, **kwargs), - ] - ) - - case "center": - return Box( - children=[ - Padding(name=name, **kwargs), - Box( - orientation="vertical", - children=[ - Padding(name=name, **kwargs), - popup, - Padding(name=name, **kwargs), - ], - ), - Padding(name=name, **kwargs), - ] - ) - case "center-right": - return Box( - children=[ - Padding(name=name, **kwargs), - Box( - orientation="vertical", - children=[ - Padding(name=name, **kwargs), - popup, - Padding(name=name, **kwargs), - ], - ), - ] - ) - case "top": - return Box( - children=[ - Padding(name=name, **kwargs), - Box( - orientation="vertical", - children=[popup, Padding(name=name, **kwargs)], - ), - Padding(name=name, **kwargs), - ] - ) - case "top-right": - return Box( - children=[ - Padding(name=name, **kwargs), - Box( - h_expand=False, - orientation="vertical", - children=[popup, Padding(name=name, **kwargs)], - ), - ] - ) - case "top-center": - return Box( - children=[ - Padding(name=name, **kwargs), - Box( - h_expand=False, - orientation="vertical", - children=[popup, Padding(name=name, **kwargs)], - ), - Padding(name=name, **kwargs), - ] - ) - case "top-left": - return Box( - children=[ - Box( - h_expand=False, - orientation="vertical", - children=[popup, Padding(name=name, **kwargs)], - ), - Padding(name=name, **kwargs), - ] - ) - case "bottom-left": - return Box( - children=[ - Box( - h_expand=False, - orientation="vertical", - children=[Padding(name=name, **kwargs), popup], - ), - Padding(name=name, **kwargs), - ] - ) - case "bottom-center": - return Box( - children=[ - Padding(name=name, **kwargs), - Box( - h_expand=False, - orientation="vertical", - children=[Padding(name=name, **kwargs), popup], - ), - Padding(name=name, **kwargs), - ] - ) - case "bottom-right": - return Box( - children=[ - Padding(name=name, **kwargs), - Box( - h_expand=True, - orientation="vertical", - children=[Padding(name=name, **kwargs), popup], - ), - ] - ) - case _: - return None - - -class PopupWindow(WaylandWindow): - def __init__( - self, - name: str = "popup-window", - decorations: str = "padding: 1px;", - child: Widget | None = None, - transition_type: ( - Literal[ - "none", - "crossfade", - "slide-right", - "slide-left", - "slide-up", - "slide-down", - ] - | None - ) = None, - transition_duration: int = 100, - popup_visible: bool = False, - anchor: Literal[ - "center-left", - "center", - "center-right", - "top", - "top-right", - "top-center", - "top-left", - "bottom-left", - "bottom-center", - "bottom-right", - ] = "top-right", - enable_inhibitor: bool = False, - keyboard_mode: Literal["none", "exclusive", "on-demand"] = "on-demand", - timeout: int = 1000, - **kwargs, - ): - self.timeout = timeout - self.currtimeout = 0 - self.popup_running = False - - self.popup_visible = popup_visible - - self.enable_inhibitor = enable_inhibitor - - self.monitor_number: int | None = None - - self.reveal_child = PopupRevealer( - name=name, - popup_window=self, - child=child, - transition_type=transition_type, - transition_duration=transition_duration, - decorations=decorations, - ) - - super().__init__( - layer="top", - keyboard_mode=keyboard_mode, - visible=False, - exclusivity="normal", - anchor="top bottom right left", - child=make_layout( - anchor=anchor, - name=name, - popup=self.reveal_child, - on_button_press_event=self.on_inhibit_click, - ), - on_key_release_event=self.on_key_release, - ) - - def on_key_release(self, _, event_key): - if event_key.get_keycode()[1] == 9: - self.popup_visible = False - self.reveal_child.revealer.set_reveal_child(self.popup_visible) - - def on_inhibit_click(self, *_): - self.popup_visible = False - self.reveal_child.revealer.set_reveal_child(self.popup_visible) - - def toggle_popup(self, monitor: bool = False): - if monitor: - curr_monitor = self.hyprland_monitor.get_current_gdk_monitor_id() - self.monitor = curr_monitor - if self.monitor_number != curr_monitor and self.popup_visible: - self.monitor_number = curr_monitor - return - - self.monitor_number = curr_monitor - - if not self.popup_visible: - self.reveal_child.revealer.show() - - self.popup_visible = not self.popup_visible - self.reveal_child.revealer.set_reveal_child(self.popup_visible) - - def popup_timeout(self): - - if not self.popup_visible: - self.reveal_child.revealer.show() - if self.popup_running: - self.currtimeout = 0 - return - self.popup_visible = True - self.reveal_child.revealer.set_reveal_child(self.popup_visible) - self.popup_running = True - - def popup_func(): - if self.currtimeout >= self.timeout: - self.popup_visible = False - self.reveal_child.revealer.set_reveal_child(self.popup_visible) - self.currtimeout = 0 - self.popup_running = False - return False - self.currtimeout += 500 - return True - - GLib.timeout_add(500, popup_func) -- 2.43.0 From 75c0c46ca7dfff9eed0fd6942b4f9082a1b5d1ad Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 12 Dec 2024 16:34:41 +0545 Subject: [PATCH 13/19] fix --- config/fabric/modules/bar/bar.py | 3 +- config/fabric/modules/bar/style.css | 203 ------------------ config/fabric/modules/bar/widgets/battery.py | 2 +- .../fabric/modules/bar/widgets/bluetooth.py | 2 +- config/fabric/modules/bar/widgets/icon.py | 16 -- config/fabric/modules/bar/widgets/idle.py | 2 +- config/fabric/modules/bar/widgets/info.py | 2 +- .../fabric/modules/bar/widgets/microphone.py | 2 +- config/fabric/modules/bar/widgets/network.py | 2 +- .../modules/bar/widgets/powerprofile.py | 2 +- config/fabric/modules/bar/widgets/volume.py | 2 +- config/fabric/modules/osd.py | 4 +- config/fabric/snippets/icon.py | 4 +- 13 files changed, 13 insertions(+), 233 deletions(-) delete mode 100644 config/fabric/modules/bar/style.css delete mode 100644 config/fabric/modules/bar/widgets/icon.py diff --git a/config/fabric/modules/bar/bar.py b/config/fabric/modules/bar/bar.py index 76df8c85..7e1f0d9b 100644 --- a/config/fabric/modules/bar/bar.py +++ b/config/fabric/modules/bar/bar.py @@ -6,7 +6,6 @@ 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 ( BatteryLabel, BluetoothIndicator, @@ -50,7 +49,7 @@ class Bar(Window): self.recording_indicator = Button( name="bar-button", - child=MaterialIcon("screen_record", size="16px"), + child=MaterialIcon("screen_record", size=16), visible=False, on_clicked=lambda *_: self.screen_recorder.screencast_stop(), ) diff --git a/config/fabric/modules/bar/style.css b/config/fabric/modules/bar/style.css deleted file mode 100644 index 1610c7ec..00000000 --- a/config/fabric/modules/bar/style.css +++ /dev/null @@ -1,203 +0,0 @@ -/* we can use webcss variables, fabric compiles that to gtk css. - global variables can be stored in :vars */ -:vars { - --background: #150d16; - --foreground: #f5dbc4; - --color0: #150d16; - --color1: #72448d; - --color2: #9c5995; - --color3: #d5719f; - --color4: #9a62f3; - --color5: #e075df; - --color6: #f98f9f; - --color7: #f5dbc4; - --color8: #ab9989; - --color9: #72448d; - --color10: #9c5995; - --color11: #d5719f; - --color12: #9a62f3; - --color13: #e075df; - --color14: #f98f9f; - --color15: #f5dbc4; - --window-bg: alpha(var(--background), 0.6); - --module-bg: alpha(var(--background), 0.4); - --border-color: var(--color11); - --ws-active: var(--color9); - --ws-inactive: var(--color3); - --ws-empty: var(--color8); - --ws-hover: var(--color1); - --ws-urgent: var(--color12); -} - -@import url(../../../.cache/material/colors.css); - -#bar { - background-color: @surface; - padding: 3px; -} - -#bar label { - font-weight: bold; -} - -#start-container, -#center-container, -#end-container { - padding-top: 6px; - padding-bottom: 6px; - margin-left: 12px; - margin-right: 12px; -} - -#battery { - background-color: @surfaceContainer; - border-radius: 100px; - padding: 2px 10px 2px 10px; -} - -#workspaces { - border-radius: 100px; - font-style: normal; - background: @surfaceContainer; - padding: 0px 10px 0px 10px; -} - -#datetime { - background-color: @surfaceContainer; - border-radius: 100px; - padding: 8px; -} - -#applets { - background-color: @surfaceContainer; - border-radius: 100px; - padding: 2px 10px 2px 10px; - margin: 0px; -} - -#applets .icon { - color: @onSurface; - font-weight: 900; -} - -#applets > button { - color: @onSurface; - margin: 0px; - padding: 0px; -} - -#taskbar { - border-radius: 100px; - font-weight: bold; - font-style: normal; - color: @onSurface; - background: @surfaceContainer; - padding-left: 4px; - padding-right: 4px; -} - -#taskbar .activated { - border-radius: 100px; - background: @surfaceVariant; -} - -#taskbar > button { - padding: 0px 4px; - margin: 4px 0px; - border-radius: 100px; - border: 0px; -} -#taskbar > button:last-child { - margin-right: 0px; -} - -#info { - background-color: @surfaceContainer; - border-radius: 100px; - padding: 2px 10px 0px 10px; -} - -#info > button { - margin: 0px; - padding: 0px; -} - -#info .progress { - color: lighter(@outlineVariant); - border: 2px solid @onSecondaryContainer; -} - -#material_icon, -#material_icon * { - all: unset; - font-family: "Material Symbols Outlined", "Material Symbols Sharp"; -} - -/* unset so we can style everything from the ground up. */ -* { - all: unset; - color: @foreground; - font-size: 16px; - font-family: "Product Sans", Roboto, "Font Awesome 6 Free", Helvetica, Arial, - sans-serif; -} - -button { - background-size: 400% 400%; -} - -menu > menuitem > label { - font-weight: 900; -} - -/* system tray */ -#system-tray { - padding: 2px 4px; - background-color: var(--module-bg); -} - -/* menu and menu items (written for the system tray) */ -menu { - border: solid 2px; - border-radius: 10px; - border-color: var(--border-color); - background-color: var(--window-bg); -} - -menu > menuitem { - border-radius: 0px; - background-color: var(--module-bg); - padding: 6px; - margin-left: 2px; - margin-right: 2px; -} - -menu > menuitem:first-child { - margin-top: 1px; - border-radius: 8px 8px 0px 0px; -} - -menu > menuitem:last-child { - margin-bottom: 1px; - border-radius: 0px 0px 8px 8px; -} - -menu > menuitem:hover { - background-color: var(--border-color); -} - -tooltip { - background-color: @surfaceContainer; - border-radius: 11px; - outline: none; - border: none; - box-shadow: none; -} - -tooltip label { - color: @onSurface; - outline: none; - border: none; - box-shadow: none; - font-weight: normal; -} diff --git a/config/fabric/modules/bar/widgets/battery.py b/config/fabric/modules/bar/widgets/battery.py index 39ed5549..ea82395a 100644 --- a/config/fabric/modules/bar/widgets/battery.py +++ b/config/fabric/modules/bar/widgets/battery.py @@ -50,7 +50,7 @@ class BatteryLabel(Box): icons = self.ICONS_CHARGING if is_charging else self.ICONS_NOT_CHARGING index = min(max(battery_percent // 10, 0), 10) - battery_icon = MaterialIcon(icons[index], size="16px") + battery_icon = MaterialIcon(icons[index], size=16) self.children = (battery_icon, battery_label) diff --git a/config/fabric/modules/bar/widgets/bluetooth.py b/config/fabric/modules/bar/widgets/bluetooth.py index 0252385a..ffc4fec8 100644 --- a/config/fabric/modules/bar/widgets/bluetooth.py +++ b/config/fabric/modules/bar/widgets/bluetooth.py @@ -22,7 +22,7 @@ class BluetoothIndicator(Box): self.ICON_ENABLED if self.bluetooth_client.enabled else self.ICON_DISABLED ) - new_icon = MaterialIcon(icon_label, size="16px") + new_icon = MaterialIcon(icon_label, size=16) if self.bluetooth_icon: self.remove(self.bluetooth_icon) diff --git a/config/fabric/modules/bar/widgets/icon.py b/config/fabric/modules/bar/widgets/icon.py deleted file mode 100644 index 7bf8e7ac..00000000 --- a/config/fabric/modules/bar/widgets/icon.py +++ /dev/null @@ -1,16 +0,0 @@ -from fabric.widgets.label import Label - - -def MaterialIcon(icon_name: str, size: str = "24px", props: dict = None): - label_props = { - "label": icon_name, # Directly use the provided icon name - "name": "material_icon", - "style": f"font-size: {size}; ", # Set font family for Material Icons - "h_align": "center", # Align horizontally - "v_align": "center", # Align vertically - } - - if props: - label_props.update(props) - - return Label(**label_props) diff --git a/config/fabric/modules/bar/widgets/idle.py b/config/fabric/modules/bar/widgets/idle.py index e93d44a1..6cfb1a0f 100644 --- a/config/fabric/modules/bar/widgets/idle.py +++ b/config/fabric/modules/bar/widgets/idle.py @@ -14,7 +14,7 @@ class IdleIndicator(Box): self.children = [self.idle_icon] def create_idle_icon(self): - return MaterialIcon("schedule", size="16px") + return MaterialIcon("schedule", size=16) def check_idle_status(self, *_): diff --git a/config/fabric/modules/bar/widgets/info.py b/config/fabric/modules/bar/widgets/info.py index fdebc438..f83e9911 100644 --- a/config/fabric/modules/bar/widgets/info.py +++ b/config/fabric/modules/bar/widgets/info.py @@ -49,7 +49,7 @@ class SystemInfo(Button): return Label(style="font-size:14px; margin: 4px;") def _create_icon(self, icon_name): - return MaterialIcon(icon_name, size="16px") + return MaterialIcon(icon_name, size=16) def _refresh_system_info(self, *_): usages = self._retrieve_system_data() diff --git a/config/fabric/modules/bar/widgets/microphone.py b/config/fabric/modules/bar/widgets/microphone.py index cc0d3a67..a89baf7c 100644 --- a/config/fabric/modules/bar/widgets/microphone.py +++ b/config/fabric/modules/bar/widgets/microphone.py @@ -16,7 +16,7 @@ class MicrophoneIndicator(Box): self.children = (self.microphone_icon,) def create_microphone_icon(self): - return MaterialIcon("mic_off", size="16px") + return MaterialIcon("mic_off", size=16) def update_microphone_status(self, *args): current_microphone = self.audio_service.microphone diff --git a/config/fabric/modules/bar/widgets/network.py b/config/fabric/modules/bar/widgets/network.py index 457d86d9..3407134e 100644 --- a/config/fabric/modules/bar/widgets/network.py +++ b/config/fabric/modules/bar/widgets/network.py @@ -25,7 +25,7 @@ class NetworkIndicator(Box): return True def update_icon(self, current_status): - self.icon_label = MaterialIcon(current_status, size="16px") + self.icon_label = MaterialIcon(current_status, size=16) self.children = (self.icon_label,) def get_network_status(self): diff --git a/config/fabric/modules/bar/widgets/powerprofile.py b/config/fabric/modules/bar/widgets/powerprofile.py index e7cc93e0..34884adf 100644 --- a/config/fabric/modules/bar/widgets/powerprofile.py +++ b/config/fabric/modules/bar/widgets/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="16px") if icon_name else None + new_icon = MaterialIcon(icon_name, size=16) if icon_name else None if self.profile_icon: self.remove(self.profile_icon) diff --git a/config/fabric/modules/bar/widgets/volume.py b/config/fabric/modules/bar/widgets/volume.py index e7ded21d..b6577678 100644 --- a/config/fabric/modules/bar/widgets/volume.py +++ b/config/fabric/modules/bar/widgets/volume.py @@ -28,7 +28,7 @@ class VolumeIndicator(Box): self.children = (self.volume_icon_button,) def create_volume_icon(self): - icon = MaterialIcon(VOLUME_ICONS["muted"], size="16px") + icon = MaterialIcon(VOLUME_ICONS["muted"], size=16) button = Button(child=icon) button.icon_widget = icon return button diff --git a/config/fabric/modules/osd.py b/config/fabric/modules/osd.py index 1b09a305..47e82493 100644 --- a/config/fabric/modules/osd.py +++ b/config/fabric/modules/osd.py @@ -36,7 +36,7 @@ class BrightnessOSDContainer(Box): def __init__(self, **kwargs): super().__init__(**kwargs, orientation="h", spacing=12, name="osd") self.brightness_service = Brightness() - self.icon = MaterialIcon(icon_name="brightness_7", size="28px") + self.icon = MaterialIcon(icon_name="brightness_7", size=28) self.scale = AnimatedScale( marks=(ScaleMark(value=i) for i in range(0, 101, 10)), value=70, @@ -102,7 +102,7 @@ class AudioOSDContainer(Box): def __init__(self, **kwargs): super().__init__(**kwargs, orientation="h", spacing=13, name="osd") self.audio = Audio() - self.icon = MaterialIcon(icon_name="volume_up", size="28px") + self.icon = MaterialIcon(icon_name="volume_up", size=28) self.scale = AnimatedScale( marks=(ScaleMark(value=i) for i in range(1, 100, 10)), value=70, diff --git a/config/fabric/snippets/icon.py b/config/fabric/snippets/icon.py index 99027003..86e77c0a 100644 --- a/config/fabric/snippets/icon.py +++ b/config/fabric/snippets/icon.py @@ -1,11 +1,11 @@ from fabric.widgets.label import Label -def MaterialIcon(icon_name: str, size: str = "24px", props=None): +def MaterialIcon(icon_name: str, size: int = 24, props=None): label_props = { "label": str(icon_name), # Directly use the provided icon name "name": "material_icon", - "style": f"font-size: {size}; ", # Set font family for Material Icons + "style": f"font-size: {size}px;", # Set font family for Material Icons "h_align": "center", # Align horizontally "v_align": "center", # Align vertically } -- 2.43.0 From 0e73d402afb34102586ff8bf025e4c4b687335bb Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 13 Dec 2024 17:36:35 +0545 Subject: [PATCH 14/19] fix --- config/fabric/modules/bar/bar.py | 57 +++++--------- config/fabric/modules/bar/widgets/__init__.py | 1 - config/fabric/modules/bar/widgets/tray.py | 76 ------------------- config/fabric/styles/bar.css | 47 +++++++----- 4 files changed, 49 insertions(+), 132 deletions(-) delete mode 100644 config/fabric/modules/bar/widgets/tray.py diff --git a/config/fabric/modules/bar/bar.py b/config/fabric/modules/bar/bar.py index 7e1f0d9b..ccbdc3b9 100644 --- a/config/fabric/modules/bar/bar.py +++ b/config/fabric/modules/bar/bar.py @@ -1,5 +1,6 @@ from fabric.hyprland.widgets import Language -from fabric.system_tray.widgets import SystemTray + +# from fabric.system_tray.widgets import SystemTray from fabric.utils import FormattedString, bulk_replace from fabric.widgets.box import Box from fabric.widgets.button import Button @@ -8,23 +9,21 @@ from fabric.widgets.datetime import DateTime from fabric.widgets.wayland import WaylandWindow as Window from modules.bar.widgets import ( BatteryLabel, - BluetoothIndicator, + Bluetooth, IdleIndicator, MicrophoneIndicator, - NetworkIndicator, - PowerProfileIndicator, + Network, SystemInfo, - SystemTray, TaskBar, VolumeIndicator, workspace, ) -from services import ScreenRecorder -from snippets import MaterialIcon class Bar(Window): - def __init__(self): + def __init__( + self, + ): super().__init__( layer="top", anchor="left bottom right", @@ -32,8 +31,6 @@ class Bar(Window): visible=False, all_visible=False, ) - self.screen_recorder = ScreenRecorder() - self.workspaces = Button(child=workspace, name="workspaces") self.language = Language( formatter=FormattedString( "{replace_lang(language)}", @@ -45,38 +42,23 @@ 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), - visible=False, - on_clicked=lambda *_: self.screen_recorder.screencast_stop(), - ) - - self.screen_recorder.connect( - "recording", - lambda _, status: self.recording_indicator.set_visible(status), - ) - - self.battery = BatteryLabel(name="battery") - self.volume = VolumeIndicator() - self.bluetooth = BluetoothIndicator() - self.network = NetworkIndicator() - self.microphone = MicrophoneIndicator() - self.idle = IdleIndicator() + # self.system_tray = SystemTray(name="tray", spacing=4, icon_size=18) self.taskbar = TaskBar() + self.volume = VolumeIndicator() + self.network = Network() + self.bluetooth = Bluetooth() + self.battery = BatteryLabel(name="battery") + self.microphone = MicrophoneIndicator() + self.workspaces = Button(child=workspace, name="workspaces") self.info = SystemInfo() - self.powerindicator = PowerProfileIndicator() - self.tray = SystemTray() - + self.idle = IdleIndicator() self.applets = Box( name="applets", spacing=4, - orientation="h", children=[ self.language, - self.powerindicator, self.bluetooth, self.network, self.volume, @@ -100,15 +82,16 @@ class Bar(Window): name="center-container", spacing=8, orientation="h", - children=self.taskbar, + children=[ + self.taskbar, + ], ), end_children=Box( name="end-container", spacing=8, orientation="h", children=[ - # self.recording_indicator, - self.tray, + # self.system_tray, self.battery, self.applets, self.date_time, diff --git a/config/fabric/modules/bar/widgets/__init__.py b/config/fabric/modules/bar/widgets/__init__.py index a2f39b03..0c03b6da 100644 --- a/config/fabric/modules/bar/widgets/__init__.py +++ b/config/fabric/modules/bar/widgets/__init__.py @@ -6,6 +6,5 @@ from .microphone import * from .network import * from .powerprofile import * from .taskbar import * -from .tray import * from .volume import * from .workspace import * diff --git a/config/fabric/modules/bar/widgets/tray.py b/config/fabric/modules/bar/widgets/tray.py deleted file mode 100644 index 7fb3128b..00000000 --- a/config/fabric/modules/bar/widgets/tray.py +++ /dev/null @@ -1,76 +0,0 @@ -import gi -from fabric.widgets.box import Box -from fabric.widgets.button import Button -from fabric.widgets.image import Image -from gi.repository import Gdk, GdkPixbuf, Gray, Gtk -from loguru import logger - -gi.require_version("Gray", "0.1") -gi.require_version("Gtk", "3.0") - - -class SystemTray(Box): - def __init__(self, pixel_size: int = 16, **kwargs) -> None: - super().__init__(name="system-tray", **kwargs) - self.pixel_size = pixel_size - self.watcher = Gray.Watcher() - self.watcher.connect("item-added", self.on_item_added) - - def on_item_added(self, _, identifier: str): - item = self.watcher.get_item_for_identifier(identifier) - item_button = self.do_bake_item_button(item) - item.connect("removed", lambda *args: item_button.destroy()) - item.connect( - "icon-changed", - lambda icon_item: self.do_update_item_button(icon_item, item_button), - ) - item_button.show_all() - self.add(item_button) - - def do_bake_item_button(self, item: Gray.Item) -> Button: - button = Button() - # context menu handler - button.connect( - "button-press-event", - lambda button, event: self.on_button_click(button, item, event), - ) - self.do_update_item_button(item, button) - - return button - - def do_update_item_button(self, item: Gray.Item, item_button: Button): - pixmap = Gray.get_pixmap_for_pixmaps(item.get_icon_pixmaps(), 24) - - # convert the pixmap to a pixbuf - pixbuf: GdkPixbuf.Pixbuf = ( - pixmap.as_pixbuf(self.config["icon_size"], GdkPixbuf.InterpType.HYPER) - if pixmap is not None - else Gtk.IconTheme() - .get_default() - .load_icon( - item.get_icon_name(), - self.pixel_size, - Gtk.IconLookupFlags.FORCE_SIZE, - ) - ) - item_button.set_image(Image(pixbuf=pixbuf, pixel_size=self.pixel_size)) - - def on_button_click(self, button, item: Gray.Item, event): - match event.button: - case 1: - try: - item.activate(event.x, event.y) - except Exception as e: - logger.error(e) - case 3: - menu = item.get_property("menu") - menu.set_name("system-tray-menu") - if menu: - menu.popup_at_widget( - button, - Gdk.Gravity.SOUTH, - Gdk.Gravity.NORTH, - event, - ) - else: - item.context_menu(event.x, event.y) diff --git a/config/fabric/styles/bar.css b/config/fabric/styles/bar.css index 07ce3eaa..1e3d4137 100644 --- a/config/fabric/styles/bar.css +++ b/config/fabric/styles/bar.css @@ -7,10 +7,6 @@ font-weight: bold; } -#corner { - background-color: @surface; -} - /* * ── bar moudles ─────────────────────────────────────────────────────── */ @@ -75,23 +71,33 @@ } /* -* ─── info ────────────────────────────────────────────────────────────── + * ── tray ────────────────────────────────────────────────────────────── */ -#info { +#tray { background-color: @surfaceContainer; border-radius: 100px; padding: 2px 10px 0px 10px; } -#info > button { +#tray > button { margin: 0px; padding: 0px; } -#info .progress { - color: lighter(@outlineVariant); - border: 2px solid @onSecondaryContainer; +menu { + background-color: @surfaceContainer; +} + +menu > menuitem { + border-radius: 12px; + padding: 10px; + margin-left: 2px; + margin-right: 2px; +} + +menu > menuitem:hover { + background-color: mix(@onSurface, @surface, 0.85); } /* @@ -145,26 +151,31 @@ margin-right: 0px; } -/* systemtray */ +#progress { + color: lighter(@outlineVariant); + border: 2px solid @onSecondaryContainer; +} + +/* + * ── system tray ─────────────────────────────────────────────────────── +*/ #system-tray { - padding: 0.125em 0.25em; background-color: @surfaceContainer; border-radius: 100px; + padding: 2px 10px 0 10px; } #system-tray > button { - margin: 0 0.1em; - padding: 0 0.15em; - border-radius: 100px; + margin: 0px; + padding: 0px; } #system-tray-menu > menuitem menu, #system-tray-menu { background-color: @surfaceContainer; - border-radius: 1em; + border-radius: 12px; padding: 10px; - min-width: 100px; } #system-tray-menu > menuitem menu > menuitem, @@ -183,5 +194,5 @@ #system-tray-menu > menuitem menu > menuitem:hover, #system-tray-menu > menuitem:hover, #submenu-button:hover { - background-color: @surface; + background-color: mix(@onSurface, @surface, 0.85); } -- 2.43.0 From 8452a1939e8ab9105418cd3d834fb3df0f4bad15 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 14 Dec 2024 20:29:26 +0545 Subject: [PATCH 15/19] notification: added circularprogesson on close button --- config/fabric/modules/notifications.py | 98 ++++++++++++++++++++++---- config/fabric/styles/notification.css | 9 +++ 2 files changed, 95 insertions(+), 12 deletions(-) diff --git a/config/fabric/modules/notifications.py b/config/fabric/modules/notifications.py index f878268a..ff60e3a9 100644 --- a/config/fabric/modules/notifications.py +++ b/config/fabric/modules/notifications.py @@ -1,3 +1,5 @@ +import time + import gi gi.require_version("GdkPixbuf", "2.0") @@ -11,12 +13,41 @@ from fabric.notifications import ( from fabric.utils import invoke_repeater from fabric.widgets.box import Box from fabric.widgets.button import Button +from fabric.widgets.circularprogressbar import CircularProgressBar from fabric.widgets.image import Image from fabric.widgets.label import Label +from fabric.widgets.overlay import Overlay from fabric.widgets.revealer import Revealer from fabric.widgets.wayland import WaylandWindow as Window -from gi.repository import GdkPixbuf -from snippets import CustomImage +from gi.repository import GdkPixbuf, GLib, GObject +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) + + self.animator = ( + Animator( + bezier_curve=bezier_curve, + duration=duration, + min_value=self.min_value, + max_value=self.value, + tick_widget=self, + notify_value=lambda p, *_: self.set_value(p.value), + ) + .build() + .play() + .unwrap() + ) + + def animate_value(self, value: float): + self.animator.pause() + self.animator.min_value = self.value + self.animator.max_value = value + self.animator.play() + return class ActionButton(Button): @@ -51,8 +82,23 @@ class NotificationWidget(Box): ) self._notification = notification + self._timer = None + self.anim_parts = 20 + self.anim_interval = self.get_timeout() / self.anim_parts + self.timeout_in_sec = self.get_timeout() / 1000 + self.time = GLib.DateTime.new_from_unix_local(time.time()).format("%m/%d") + self.connect("button-press-event", self.on_button_press) header_container = Box(spacing=8, orientation="h") + self.progress_timeout = AnimatedCircularProgressBar( + name="notification-circular-progress-bar", + size=30, + min_value=0, + max_value=1, + radius_color=True, + value=0, + ) + header_container.children = ( self.get_icon(notification.app_icon, notification.app_name, 25), Label( @@ -71,17 +117,17 @@ class NotificationWidget(Box): Box( v_align="start", children=( - Button( - image=Image( - icon_name="close-symbolic", - icon_size=16, + Overlay( + child=self.progress_timeout, + overlays=Button( + image=Image( + icon_name="window-close-symbolic", + icon_size=16, + ), style_classes="close-button", - ), - style_classes="close-button", - v_align="center", - h_align="end", - on_clicked=lambda *_: self._notification.close( - "dismissed-by-user" + on_clicked=lambda *_: self._notification.close( + "dismissed-by-user" + ), ), ), ), @@ -148,6 +194,25 @@ class NotificationWidget(Box): ), ) + self.start_timer() + + def start_timer(self): + self._timer = GObject.timeout_add(200, self.update_progress) + + def update_progress(self): + self.progress_timeout.animate_value( + self.progress_timeout.value + 1 / self.anim_parts + ) + if self.progress_timeout.value >= self.timeout_in_sec: + self.progress_timeout.value = self.timeout_in_sec + self.stop_timer() + return True # Continue the timer + + def stop_timer(self): + if self._timer: + GObject.source_remove(self._timer) + self._timer = None + def get_icon(self, app_icon, app_name, size) -> Image: # Normalize app_name app_name = ( @@ -178,6 +243,15 @@ class NotificationWidget(Box): # Return a symbolic icon as fallback return Image(name="notification-icon", icon_name=icon_name, icon_size=size) + def on_button_press(self, _, event): + if event.button != 1: + (self._notification.close("dismissed-by-user"),) + + def get_timeout(self): + return ( + self._notification.timeout if self._notification.timeout != -1 else 5 * 1000 + ) + class NotificationRevealer(Revealer): def __init__(self, notification: Notification, **kwargs): diff --git a/config/fabric/styles/notification.css b/config/fabric/styles/notification.css index ff185f70..b1ba83cb 100644 --- a/config/fabric/styles/notification.css +++ b/config/fabric/styles/notification.css @@ -18,6 +18,10 @@ font-size: 0.92rem; } +#notification .close-button { + border-radius: 100px; +} + #notification .close-button:hover { background: alpha(@foreground, 0.2); transition: background 0.15s ease-in-out; @@ -49,3 +53,8 @@ .image { border-radius: 30px; } + +#notification-circular-progress-bar { + border: solid 0px @outlineVariant; + color: transparent; +} -- 2.43.0 From e41a17bf4c53c25b7aca373abbba7108bb49f370 Mon Sep 17 00:00:00 2001 From: 00xJ4CK <144516471+00xJ4CK@users.noreply.github.com> Date: Sat, 21 Dec 2024 08:00:13 +0545 Subject: [PATCH 16/19] add calendar widget and fixes some error --- config/fabric/assets/config.json | 5 ++ config/fabric/main.py | 6 +-- config/fabric/modules/launcher/launcher.py | 16 +++---- .../modules/launcher/widgets/__init__.py | 1 + .../modules/launcher/widgets/calendar.py | 25 ++++++++++ .../modules/launcher/widgets/power_menu.py | 2 +- ...notifications.py => notification_popup.py} | 0 config/fabric/snippets/__init__.py | 1 + config/fabric/snippets/calendar.py | 48 +++++++++++++++++++ config/fabric/styles/launcher.css | 40 ++++++++++++++++ 10 files changed, 132 insertions(+), 12 deletions(-) create mode 100644 config/fabric/modules/launcher/widgets/calendar.py rename config/fabric/modules/{notifications.py => notification_popup.py} (100%) create mode 100644 config/fabric/snippets/calendar.py diff --git a/config/fabric/assets/config.json b/config/fabric/assets/config.json index 56f99727..9b339cff 100644 --- a/config/fabric/assets/config.json +++ b/config/fabric/assets/config.json @@ -34,6 +34,11 @@ "command": ":p", "description": "Shutdown and go sleepy time", "handler": "show_powermenu" + }, + { + "command": ":cl", + "description": "Show the calendar", + "handler": "show_calendar" } ] } diff --git a/config/fabric/main.py b/config/fabric/main.py index 2cd4f4d6..0e3199eb 100644 --- a/config/fabric/main.py +++ b/config/fabric/main.py @@ -1,13 +1,13 @@ import os import setproctitle -from fabric import Application -from fabric.utils import get_relative_path, monitor_file from loguru import logger +from fabric import Application +from fabric.utils import get_relative_path, monitor_file from modules.bar.bar import Bar from modules.launcher.launcher import Launcher -from modules.notifications import NotificationPopup +from modules.notification_popup import NotificationPopup from modules.osd import OSDContainer from services import ScreenRecorder diff --git a/config/fabric/modules/launcher/launcher.py b/config/fabric/modules/launcher/launcher.py index 9d66db49..1cae00c3 100644 --- a/config/fabric/modules/launcher/launcher.py +++ b/config/fabric/modules/launcher/launcher.py @@ -1,7 +1,5 @@ -from fabric import Application from fabric.utils import ( get_desktop_applications, - get_relative_path, idle_add, invoke_repeater, remove_handler, @@ -13,8 +11,10 @@ from fabric.widgets.label import Label from fabric.widgets.revealer import Revealer from fabric.widgets.scrolledwindow import ScrolledWindow from fabric.widgets.wayland import WaylandWindow as Window + from modules.launcher.widgets import ( BluetoothMenu, + Calendar, ClipboardManager, EmojiManager, PowerMenu, @@ -63,6 +63,7 @@ class Launcher(Window): 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( @@ -272,9 +273,8 @@ class Launcher(Window): self.update_dynamic_button(dynamic_buttons) self.scrolled_revealer.reveal() - -# if __name__ == "__main__": -# launcher = Launcher() -# app = Application("launcher", launcher) -# app.set_stylesheet_from_file(get_relative_path("./styles/main.css")) -# app.run() + 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() diff --git a/config/fabric/modules/launcher/widgets/__init__.py b/config/fabric/modules/launcher/widgets/__init__.py index 59567757..c99174db 100644 --- a/config/fabric/modules/launcher/widgets/__init__.py +++ b/config/fabric/modules/launcher/widgets/__init__.py @@ -1,5 +1,6 @@ from .app import * from .bluetooth import * +from .calendar import * from .clipboard import * from .emoji import * from .power_menu import * diff --git a/config/fabric/modules/launcher/widgets/calendar.py b/config/fabric/modules/launcher/widgets/calendar.py new file mode 100644 index 00000000..6ffcb155 --- /dev/null +++ b/config/fabric/modules/launcher/widgets/calendar.py @@ -0,0 +1,25 @@ +from fabric.widgets.box import Box +from fabric.widgets.button import Button +from snippets import GtkCalendar, 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=GtkCalendar(h_expand=True), + ) + + viewport.add(calendar_container) + + def get_calendar_buttons(self): + return self.today_button diff --git a/config/fabric/modules/launcher/widgets/power_menu.py b/config/fabric/modules/launcher/widgets/power_menu.py index f24eb5c8..97f052a8 100644 --- a/config/fabric/modules/launcher/widgets/power_menu.py +++ b/config/fabric/modules/launcher/widgets/power_menu.py @@ -74,7 +74,7 @@ class PowerMenu: orientation="h", spacing=10, children=[ - MaterialIcon(option["icon"], size="28px"), + MaterialIcon(option["icon"], size=28), Label(label=option["label"], h_align="start"), ], ), diff --git a/config/fabric/modules/notifications.py b/config/fabric/modules/notification_popup.py similarity index 100% rename from config/fabric/modules/notifications.py rename to config/fabric/modules/notification_popup.py diff --git a/config/fabric/snippets/__init__.py b/config/fabric/snippets/__init__.py index add4b114..0cd2d48b 100644 --- a/config/fabric/snippets/__init__.py +++ b/config/fabric/snippets/__init__.py @@ -1,4 +1,5 @@ from .animator import * +from .calendar import * from .custom_image import * from .functions import * from .icon import * diff --git a/config/fabric/snippets/calendar.py b/config/fabric/snippets/calendar.py new file mode 100644 index 00000000..cff34150 --- /dev/null +++ b/config/fabric/snippets/calendar.py @@ -0,0 +1,48 @@ +from collections.abc import Iterable +from typing import Literal + +import gi +from fabric.widgets.widget import Widget +from gi.repository import Gtk + +gi.require_version("Gtk", "3.0") + + +class GtkCalendar(Gtk.Calendar, Widget): + """A switch widget.""" + + def __init__( + self, + name: str | None = None, + h_align: ( + Literal["fill", "start", "end", "center", "baseline"] | Gtk.Align | None + ) = None, + v_align: ( + Literal["fill", "start", "end", "center", "baseline"] | Gtk.Align | None + ) = None, + h_expand: bool = False, + v_expand: bool = False, + tooltip_text: str | None = None, + tooltip_markup: str | None = None, + visible: bool = True, + all_visible: bool = False, + style: str | None = None, + style_classes: Iterable[str] | str | None = None, + **kwargs, + ): + Gtk.Calendar.__init__(self) # type: ignore + Widget.__init__( + self, + name, + visible, + all_visible, + style, + style_classes, + tooltip_text, + tooltip_markup, + h_align, + v_align, + h_expand, + v_expand, + **kwargs, + ) diff --git a/config/fabric/styles/launcher.css b/config/fabric/styles/launcher.css index 683996d9..0ad7cb01 100644 --- a/config/fabric/styles/launcher.css +++ b/config/fabric/styles/launcher.css @@ -144,3 +144,43 @@ background-color: @surfaceVariant; 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); +} -- 2.43.0 From 06c577afc1ccabcc39a711885a1b0eea9dedd26f Mon Sep 17 00:00:00 2001 From: 00xJ4CK <144516471+00xJ4CK@users.noreply.github.com> Date: Sat, 21 Dec 2024 08:02:36 +0545 Subject: [PATCH 17/19] fix --- .../modules/launcher/widgets/wallpaper.py | 44 ++--- .../modules/launcher/widgets/wallpaper1.py | 166 ------------------ 2 files changed, 22 insertions(+), 188 deletions(-) delete mode 100644 config/fabric/modules/launcher/widgets/wallpaper1.py diff --git a/config/fabric/modules/launcher/widgets/wallpaper.py b/config/fabric/modules/launcher/widgets/wallpaper.py index c44d2121..7ea4b8a3 100644 --- a/config/fabric/modules/launcher/widgets/wallpaper.py +++ b/config/fabric/modules/launcher/widgets/wallpaper.py @@ -1,23 +1,24 @@ import hashlib import os -from pathlib import Path 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/wall") + 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 = Path.home() / "Pictures" / "wallpapers" + 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() @@ -71,11 +72,10 @@ class WallpaperManager: return None def generate_or_load_thumbnail(self, wallpaper_path): - """Generate or load a cached thumbnail.""" - cache_path = self.get_cache_path(wallpaper_path.name) + cache_path = self.get_cache_path(os.path.basename(wallpaper_path)) if not os.path.exists(cache_path): - pixbuf = self.create_thumbnail(str(wallpaper_path)) + pixbuf = self.create_thumbnail(wallpaper_path) if pixbuf: pixbuf.savev(cache_path, "png", [], []) return cache_path @@ -113,15 +113,23 @@ class WallpaperManager: def _get_wallpapers(self, search_term: str): return ( - f - for f in self.wallpaper_dir.iterdir() - if f.is_file() - and f.suffix.lower() in self.IMAGE_EXTENSIONS - and self._matches_search(f, search_term) + 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, search_term: str): - return not search_term or search_term.lower() in file.name.lower() + 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( @@ -137,19 +145,11 @@ class WallpaperManager: on_clicked=lambda _: self._select_wallpaper(wallpaper_path), ) - 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 _select_wallpaper(self, wallpaper_path): self._apply_wallpaper(wallpaper_path) def _apply_wallpaper(self, wallpaper_path): - self._execute_wallpaper_script("--image", str(wallpaper_path)) + self._execute_wallpaper_script("--image", wallpaper_path) def apply_wallpaper_random(self): self._execute_wallpaper_script("-R") diff --git a/config/fabric/modules/launcher/widgets/wallpaper1.py b/config/fabric/modules/launcher/widgets/wallpaper1.py deleted file mode 100644 index ee03d514..00000000 --- a/config/fabric/modules/launcher/widgets/wallpaper1.py +++ /dev/null @@ -1,166 +0,0 @@ -import os -import threading -from pathlib import Path - -from fabric.utils import exec_shell_command, exec_shell_command_async -from fabric.widgets.box import Box -from fabric.widgets.button import Button -from loguru import logger -from snippets import MaterialIcon - - -class WallpaperManager: - IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".webp"} - THUMBNAIL_SIZE = "x64" - THUMBNAIL_ASPECT_RATIO = "1:1" - WALLPAPER_SCRIPT_PATH = os.path.expanduser("~/dotfiles/hypr/scripts/wallpaper.py") - - def __init__(self): - self.wallpaper_dir = Path.home() / "Pictures" / "wallpapers" - self.thumbnail_dir = ( - Path.home() / ".cache" / "fabric" / "thumbnails" / "wallpapers" - ) - self.thumbnail_dir.mkdir(parents=True, exist_ok=True) - 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 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_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 ( - f - for f in self.wallpaper_dir.iterdir() - if f.is_file() - and f.suffix.lower() in self.IMAGE_EXTENSIONS - and self._matches_search(f, search_term) - ) - - def _matches_search(self, file, search_term: str): - return not search_term or search_term.lower() in file.name.lower() - - def _generate_thumbnail(self, wallpaper_path): - thumbnail_path = self.thumbnail_dir / wallpaper_path.name - if not thumbnail_path.exists(): - threading.Thread( - target=self._create_thumbnail, - args=(wallpaper_path, thumbnail_path), - daemon=True, - ).start() - return thumbnail_path - - def _create_thumbnail(self, wallpaper_path, thumbnail_path): - logger.debug(f"Generating thumbnail for {wallpaper_path}") - exec_shell_command_async( - [ - "magick", - str(wallpaper_path), - "-resize", - self.THUMBNAIL_SIZE, - "-gravity", - "Center", - "-extent", - self.THUMBNAIL_ASPECT_RATIO, - str(thumbnail_path), - ], - lambda *args: logger.debug(args), - ) - - 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 _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 _select_wallpaper(self, wallpaper_path): - self._apply_wallpaper(wallpaper_path) - - def _apply_wallpaper(self, wallpaper_path): - self._execute_wallpaper_script("--image", str(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 -- 2.43.0 From 2cb92a308ffba73fec3485e19f97bfea287819ea Mon Sep 17 00:00:00 2001 From: 00xJ4CK <144516471+00xJ4CK@users.noreply.github.com> Date: Sun, 22 Dec 2024 20:52:24 +0545 Subject: [PATCH 18/19] fix --- .../modules/launcher/widgets/calendar.py | 5 +- config/fabric/snippets/__init__.py | 1 - config/fabric/snippets/calendar.py | 48 ------------------- config/hypr/UserConfigs/UserSettings.conf | 3 +- 4 files changed, 4 insertions(+), 53 deletions(-) delete mode 100644 config/fabric/snippets/calendar.py diff --git a/config/fabric/modules/launcher/widgets/calendar.py b/config/fabric/modules/launcher/widgets/calendar.py index 6ffcb155..2b522287 100644 --- a/config/fabric/modules/launcher/widgets/calendar.py +++ b/config/fabric/modules/launcher/widgets/calendar.py @@ -1,6 +1,7 @@ from fabric.widgets.box import Box from fabric.widgets.button import Button -from snippets import GtkCalendar, MaterialIcon +from gi.repository import Gtk +from snippets import MaterialIcon class Calendar: @@ -16,7 +17,7 @@ class Calendar: calendar_container = Box( name="calendar", - children=GtkCalendar(h_expand=True), + children=Gtk.Calendar(visible=True, hexpand=True), ) viewport.add(calendar_container) diff --git a/config/fabric/snippets/__init__.py b/config/fabric/snippets/__init__.py index 0cd2d48b..add4b114 100644 --- a/config/fabric/snippets/__init__.py +++ b/config/fabric/snippets/__init__.py @@ -1,5 +1,4 @@ from .animator import * -from .calendar import * from .custom_image import * from .functions import * from .icon import * diff --git a/config/fabric/snippets/calendar.py b/config/fabric/snippets/calendar.py deleted file mode 100644 index cff34150..00000000 --- a/config/fabric/snippets/calendar.py +++ /dev/null @@ -1,48 +0,0 @@ -from collections.abc import Iterable -from typing import Literal - -import gi -from fabric.widgets.widget import Widget -from gi.repository import Gtk - -gi.require_version("Gtk", "3.0") - - -class GtkCalendar(Gtk.Calendar, Widget): - """A switch widget.""" - - def __init__( - self, - name: str | None = None, - h_align: ( - Literal["fill", "start", "end", "center", "baseline"] | Gtk.Align | None - ) = None, - v_align: ( - Literal["fill", "start", "end", "center", "baseline"] | Gtk.Align | None - ) = None, - h_expand: bool = False, - v_expand: bool = False, - tooltip_text: str | None = None, - tooltip_markup: str | None = None, - visible: bool = True, - all_visible: bool = False, - style: str | None = None, - style_classes: Iterable[str] | str | None = None, - **kwargs, - ): - Gtk.Calendar.__init__(self) # type: ignore - Widget.__init__( - self, - name, - visible, - all_visible, - style, - style_classes, - tooltip_text, - tooltip_markup, - h_align, - v_align, - h_expand, - v_expand, - **kwargs, - ) diff --git a/config/hypr/UserConfigs/UserSettings.conf b/config/hypr/UserConfigs/UserSettings.conf index 8fc85202..3bbcd2ed 100644 --- a/config/hypr/UserConfigs/UserSettings.conf +++ b/config/hypr/UserConfigs/UserSettings.conf @@ -19,8 +19,7 @@ general { gaps_out = 8 border_size = 0 - col.active_border = $border_color_active - col.inactive_border = $border_color_inactive + layout = dwindle } -- 2.43.0 From 9b1a998c747263fe007565fe9a72819682799503 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 31 Dec 2024 04:34:53 +0545 Subject: [PATCH 19/19] update --- config/fabric/modules/bar/bar.py | 56 +++++--- config/fabric/modules/bar/widgets/info.py | 2 +- config/fabric/modules/launcher/launcher.py | 1 - config/fabric/services/screen_record.py | 38 ++---- config/fabric/styles/main.css | 10 +- config/hypr/UserConfigs/WindowRules.conf | 147 +++++---------------- config/hypr/scripts/ScreenShot.sh | 15 --- config/hypr/scripts/battery.sh | 106 +++++++++++++++ config/hypr/scripts/status.sh | 23 ---- config/hypr/scripts/wallpaper.py | 6 +- config/material-colors/generate.py | 54 +++----- 11 files changed, 216 insertions(+), 242 deletions(-) delete mode 100755 config/hypr/scripts/ScreenShot.sh create mode 100755 config/hypr/scripts/battery.sh delete mode 100755 config/hypr/scripts/status.sh diff --git a/config/fabric/modules/bar/bar.py b/config/fabric/modules/bar/bar.py index ccbdc3b9..12f7ab1f 100644 --- a/config/fabric/modules/bar/bar.py +++ b/config/fabric/modules/bar/bar.py @@ -1,6 +1,5 @@ from fabric.hyprland.widgets import Language - -# from fabric.system_tray.widgets import SystemTray +from fabric.system_tray.widgets import SystemTray from fabric.utils import FormattedString, bulk_replace from fabric.widgets.box import Box from fabric.widgets.button import Button @@ -9,21 +8,23 @@ from fabric.widgets.datetime import DateTime from fabric.widgets.wayland import WaylandWindow as Window from modules.bar.widgets import ( BatteryLabel, - Bluetooth, + BluetoothIndicator, IdleIndicator, MicrophoneIndicator, - Network, + NetworkIndicator, + PowerProfileIndicator, SystemInfo, TaskBar, VolumeIndicator, workspace, + Recorder, ) +from services import ScreenRecorder +from snippets import MaterialIcon class Bar(Window): - def __init__( - self, - ): + def __init__(self): super().__init__( layer="top", anchor="left bottom right", @@ -31,6 +32,8 @@ class Bar(Window): visible=False, all_visible=False, ) + self.screen_recorder = ScreenRecorder() + self.workspaces = Button(child=workspace, name="workspaces") self.language = Language( formatter=FormattedString( "{replace_lang(language)}", @@ -42,23 +45,39 @@ class Bar(Window): ), ), ) - self.date_time = DateTime(formatters=["%-I:%M 󰧞 %a %d %b"], name="datetime") - # self.system_tray = SystemTray(name="tray", spacing=4, icon_size=18) - self.taskbar = TaskBar() - self.volume = VolumeIndicator() - self.network = Network() - self.bluetooth = Bluetooth() + + self.recording_indicator = Button( + name="bar-button", + child=MaterialIcon("screen_record", size=16), + visible=False, + on_clicked=lambda *_: self.screen_recorder.screencast_stop(), + ) + + self.screen_recorder.connect( + "recording", + lambda _, status: self.recording_indicator.set_visible(status), + ) + self.battery = BatteryLabel(name="battery") + self.volume = VolumeIndicator() + self.bluetooth = BluetoothIndicator() + self.network = NetworkIndicator() self.microphone = MicrophoneIndicator() - self.workspaces = Button(child=workspace, name="workspaces") - self.info = SystemInfo() self.idle = IdleIndicator() + self.taskbar = TaskBar() + self.info = SystemInfo() + self.powerindicator = PowerProfileIndicator() + self.tray = SystemTray(name="tray", icon_size=16, spacing=4) + self.recorder = Recorder() + self.applets = Box( name="applets", spacing=4, + orientation="h", children=[ self.language, + self.powerindicator, self.bluetooth, self.network, self.volume, @@ -82,16 +101,15 @@ class Bar(Window): name="center-container", spacing=8, orientation="h", - children=[ - self.taskbar, - ], + children=self.taskbar, ), end_children=Box( name="end-container", spacing=8, orientation="h", children=[ - # self.system_tray, + self.recorder, + self.tray, self.battery, self.applets, self.date_time, diff --git a/config/fabric/modules/bar/widgets/info.py b/config/fabric/modules/bar/widgets/info.py index f83e9911..18f095f8 100644 --- a/config/fabric/modules/bar/widgets/info.py +++ b/config/fabric/modules/bar/widgets/info.py @@ -42,7 +42,7 @@ class SystemInfo(Button): def _create_progress_bar(self): return CircularProgressBar( - style_classes="progress", line_style="round", line_width=1, size=30 + name="progress", line_style="round", line_width=1, size=30 ) def _create_label(self): diff --git a/config/fabric/modules/launcher/launcher.py b/config/fabric/modules/launcher/launcher.py index 1cae00c3..b4f6596f 100644 --- a/config/fabric/modules/launcher/launcher.py +++ b/config/fabric/modules/launcher/launcher.py @@ -11,7 +11,6 @@ from fabric.widgets.label import Label from fabric.widgets.revealer import Revealer from fabric.widgets.scrolledwindow import ScrolledWindow from fabric.widgets.wayland import WaylandWindow as Window - from modules.launcher.widgets import ( BluetoothMenu, Calendar, diff --git a/config/fabric/services/screen_record.py b/config/fabric/services/screen_record.py index 20f23869..5f2f12c1 100644 --- a/config/fabric/services/screen_record.py +++ b/config/fabric/services/screen_record.py @@ -7,26 +7,16 @@ from gi.repository import Gio, GLib from loguru import logger + class ScreenRecorder(Service): @Signal def recording(self, value: bool) -> None: ... - _instance = None - - def __init__(self, **kwargs): - if hasattr(self, "_initialized") and self._initialized: - return + def __init__(self, **kwargs): self.screenshot_path = GLib.get_home_dir() + "/Pictures/Screenshots/" - self.screenrecord_path = GLib.get_home_dir() + "/Videos/Screencasting/" - self._current_screencast_path = None + self.screenrecord_path = GLib.get_home_dir() + "/Videos/Screenrecords/" super().__init__(**kwargs) - self._initialized = True - - def __new__(cls, *args, **kwargs): - if not cls._instance: - cls._instance = super(ScreenRecorder, cls).__new__(cls, *args, **kwargs) - return cls._instance def screenshot(self, fullscreen=False, save_copy=True): time = datetime.datetime.today().strftime("%Y-%m-%d_%H-%M-%S") @@ -37,13 +27,13 @@ class ScreenRecorder(Service): else ["grimblast", "copy" "screen"] ) if not fullscreen: - command[2] = "area" + command[3] = "area" try: subprocess.run(command, check=True) self.send_screenshot_notification( file_path=file_path if file_path else None, ) - except Exception as e: + except Exception: logger.error(f"[SCREENSHOT] Failed to run command: {command}") def screencast_start(self, fullscreen=False): @@ -54,6 +44,7 @@ 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}" @@ -61,25 +52,11 @@ class ScreenRecorder(Service): self.emit("recording", True) def screencast_stop(self): - if not self.is_recording: - logger.error("[SCREENRECORD] No active recording to stop") - return exec_shell_command_async("killall -INT wf-recorder") self.emit("recording", False) self.send_screencast_notification(self._current_screencast_path) - # def screencast_stop(self): - # exec_shell_command_async("killall -INT wf-recorder") - # self.emit("recording", False) - # if hasattr(self, "_current_screencast_path") and self._current_screencast_path: - # self.send_screencast_notification(self._current_screencast_path) - # else: - # logger.error("[SCREENRECORD] No active screencast to stop") - # 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( [ @@ -161,4 +138,5 @@ class ScreenRecorder(Service): @Property(bool, "readable", default_value=False) def is_recording(self): - return False if len(exec_shell_command("pidof wf-recorder")) == 0 else True + return len(exec_shell_command("pidof wf-recorder")) != 0 + diff --git a/config/fabric/styles/main.css b/config/fabric/styles/main.css index 0242029a..e99c6262 100644 --- a/config/fabric/styles/main.css +++ b/config/fabric/styles/main.css @@ -1,8 +1,8 @@ -@import url(../../../.cache/material/colors.css); -@import "launcher.css"; -@import "bar.css"; -@import "notification.css"; -@import "osd.css"; +@import url(/home/sankalp/.cache/material/colors.css); +@import "./launcher.css"; +@import "./bar.css"; +@import "./notification.css"; +@import "./osd.css"; * { all: unset; diff --git a/config/hypr/UserConfigs/WindowRules.conf b/config/hypr/UserConfigs/WindowRules.conf index 00b41a78..95a31db5 100644 --- a/config/hypr/UserConfigs/WindowRules.conf +++ b/config/hypr/UserConfigs/WindowRules.conf @@ -1,6 +1,5 @@ # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more -# Opacity Rules # Xwaylandvideobridge (if installed) windowrulev2 = opacity 0.0 override,class:^(xwaylandvideobridge)$ @@ -10,52 +9,22 @@ windowrulev2 = maxsize 1 1,class:^(xwaylandvideobridge)$ windowrulev2 = noblur,class:^(xwaylandvideobridge)$ # Workspace Rules -windowrule = workspace 5, ^(.*vlc*)$ -windowrule = workspace 2, ^(.*neovim*)$ - #windowrule = stayfocused, ^(com.github.Aylur.ags)$ -windowrule = float, ^(com.github.Aylur.ags)$ -windowrule=float,title:^(Volume Control)(.*)$ -# MPV -windowrule = workspace 5, ^(.*mpv*)$ -windowrulev2 = float, class:^(.*mpv.*) -windowrulev2 = size 70% 70%, class:^(.*mpv.*) - - -# Do not lose focus when gnome polkit is opened -windowrulev2 = stayfocused, class:(polkit-gnome-authentication-agent-1) +# MPV/VLC +windowrule = workspace 5, ^(.*vlc.*)$|(.*mpv.*)$ +windowrulev2 = float, class:^(.*mpv.*)$|(.*vlc.*)$ +windowrulev2 = size 70% 70%, class:^(.*mpv.*)$|(.*vlc.*)$ # Pavucontrol -windowrulev2 = float, class:(pavucontrol) -windowrulev2 = size 533 533, class:(pavucontrol) -windowrulev2 = center, class:(pavucontrol) +windowrulev2 = float, class:^(pavucontrol|org.pulseaudio.pavucontrol|com.saivert.pavucontrol)$ -# Zathura +#Zathura $zathura = class:^(.*zathura.*)$ windowrulev2 = float, $zathura windowrulev2 = size 35% 90%, $zathura windowrulev2 = center 1, $zathura - -# Do not lose focus when gnome polkit is opened -windowrulev2 = stayfocused, class:(polkit-gnome-authentication-agent-1) - -# OBS - -# Main window / Profile screen -windowrulev2 = size 75% 70%, class:(com.obsproject.Studio), title:(.*Profile:.*) - -# Class settings -windowrulev2 = workspace 9, class:(com.obsproject.Studio) -windowrulev2 = float, class:(com.obsproject.Studio) -windowrulev2 = center, class:(com.obsproject.Studio) - -# Folder picker -windowrulev2 = size 50% 45%, class:(com.obsproject.Studio), title:(Select Recording Directory) -windowrulev2 = center, class:(com.obsproject.Studio), title:(Select Recording Directory) - - # Fireox class settings windowrulev2 = workspace 3, class:^(firefox)$ windowrulev2 = pin,title:^(Picture-in-Picture)$ @@ -65,31 +34,9 @@ windowrulev2 = move 72% 7%,title:^(Picture-in-Picture)$ windowrulev2 = idleinhibit fullscreen, class:^(.*firefox.*)$ # Thunar -windowrulev2 = size 456 884, title:(.*Compress.*), class:(thunar) -windowrulev2 = center, title:(.*Compress.*), class:(thunar) -windowrulev2 = float, title:(.*Compress.*), class:(thunar) - -windowrulev2 = size 516 158, title:(.*Rename.*), class:(thunar) -windowrulev2 = center, title:(.*Rename.*), class:(thunar) - -windowrulev2 = size 950 270, title:(Confirm to replace files), class:(thunar) -windowrulev2 = center, title:(Confirm to replace files), class:(thunar) -windowrulev2 = float,title:^(Confirm to replace files) - -windowrulev2 = size 444 103, title:(File Operation Progress), class:(thunar) -windowrulev2 = center, title:(File Operation Progress), class:(thunar) - -windowrulev2 = size 565 591, class:(thunar), title:(Properties) -windowrulev2 = center, class:(thunar), title:(Properties) - -windowrulev2 = size 477 149, class:(thunar), title:(Create New Folder) -windowrulev2 = center, class:(thunar), title:(Create New Folder) - +windowrulev2 = float, class:([Tt]hunar), title:(File Operation Progress) +windowrulev2 = float, class:([Tt]hunar), title:(Confirm to replace files) windowrulev2 = workspace 4, class:(thunar) -#windowrulev2 = float, class:(thunar) -#windowrulev2 = size 1161 619, class:(thunar) -#windowrulev2 = center, class:(thunar) - # File / Folder pickers $center-float = class:^(center-float)$|^(.*file-roller.*)$|^(.*FileRoller.*)$ @@ -101,20 +48,6 @@ windowrulev2 = size 50% 50%, $center-float-title windowrulev2 = center 1, $center-float windowrulev2 = center 1, $center-float-title - -# VS Code -# windowrulev2 = workspace 2, class:^(.*Code.*)$|(.*codium.*)$|(.*VSCodium.*) - - -# Telegram -windowrulev2 = fullscreen, class:(.*materialgram.*), title:(Media viewer) -windowrulev2 = workspace 6, class:(.*materialgram.*) -windowrulev2 = size 833 455, class:(.*materialgram.*), title:(Choose Files) -windowrulev2 = center, class:(.*materialgram.*), title:(Choose Files) - -# discord -windowrulev2 = workspace 7, class:^(.*discord.*)$|(.*vesktop.*)$|(.*WebCord.*)$ - # File Roller windowrulev2 = workspace 4, class:(file-roller), title:(Archive Manager) windowrulev2 = float, class:(file-roller), title:(Archive Manager) @@ -124,71 +57,61 @@ windowrulev2 = float, class:(file-roller), title:(Extract archive) windowrulev2 = size 30% 15%, class:(file-roller), title:(Extract archive) windowrulev2 = center, class:(file-roller), title:(Extract archive) +# VS Code +# windowrulev2 = workspace 2, class:(codium|codium-url-handler|VSCodium|code-oss|code) +windowrulev2 = float, class:(codium|codium-url-handler|VSCodium|code-oss|code), title:(Add Folder to Workspace) + +# Telegram +windowrulev2 = fullscreen, class:^(.*materialgram.*)$|(.*telegram-desktop.*), title:(Media viewer) +windowrulev2 = workspace 6, class:^(.*materialgram.*)$|(.*telegram-desktop.*)$ +windowrulev2 = size 833 455, class:^(.*materialgram.*)$|(.*telegram-desktop.*)$, title:(Choose Files) +windowrulev2 = center, class:^(.*materialgram.*)$|(.*telegram-desktop.*), title:(Choose Files) + +# discord +windowrulev2 = workspace 7, class:^(.*discord.*)$|(.*vesktop.*)$|(.*WebCord.*)$ # Kitty -windowrule = float, title:^(Kitty)$ -windowrule = size 800 500, title:^(Kitty)$ -windowrule = move center, title:^(Kitty)$ -windowrule = animation slide, title:^(Kitty)$ -windowrule = float, title:^(Kitty)$ +windowrulev2 = float,class:^(kitty)$,title:^(Kitty)$ +windowrulev2 = size 800 500, class^(kitty)$, title:^(Kitty)$ +windowrulev2 = move center, class^(kitty)$, title:^(Kitty)$ +windowrulev2 = animation slide, class:^(kitty)$, title:^(Kitty)$ +windowrulev2 = float, class:^(kitty)$, title:^(Kitty)$ # Bluetooth applet windowrulev2 = float, class:(blueman) windowrulev2 = size 680 665, class:(blueman) windowrulev2 = center, class:(blueman) - # IMV image viewer $center-float-large = class:^(center-float-large)$|^(.*imv.*)$|^(.*imv-dir.*)$ windowrulev2 = float, $center-float-large windowrulev2 = size 70% 70%, $center-float-large windowrulev2 = center 1, $center-float-large - # qt5ct / qt6ct -windowrulev2 = float, class:(qt5ct) -windowrulev2 = float, class:(qt6ct) - -windowrulev2 = size 1256 689, class:(qt5ct) -windowrulev2 = size 1256 689, class:(qt6ct) - -windowrulev2 = center, class:(qt5ct) -windowrulev2 = center, class:(qt6ct) - -windowrulev2 = size 257 116, class:(qt5ct), title:(Enter Color Scheme Name) -windowrulev2 = size 257 116, class:(qt6ct), title:(Enter Color Scheme Name) - -windowrulev2 = size 548 476, class:(qt5ct), title:(Select Color) -windowrulev2 = size 548 476, class:(qt6ct), title:(Select Color) - +windowrulev2 = float, class:^(nwg-look|qt5ct|qt6ct)$ +windowrulev2 = size 60% 70%, class:^(qt6ct)$ # Other -windowrule = float, nm-connection-editor|vlc|yad|rofi|Lxappearance -windowrule = float, org.kde.polkit-kde-authentication-agent-1 +windowrule = float, nm-connection-editor|yad|Lxappearance windowrulev2 = size 543 239, class:^(polkit-gnome-authentication-agent-1)$ windowrulev2 = float, class:^(polkit-gnome-authentication-agent-1)$ windowrulev2 = center, class:(polkit-gnome-authentication-agent-1) +windowrulev2 = float, class:(electron), title:(Add Folder to Workspace) +windowrulev2 = float, class:^(org.kde.polkit-kde-authentication-agent-1)$ +windowrulev2 = float, class:(xdg-desktop-portal-gtk) +windowrulev2 = size 70% 70%, class:^(xdg-desktop-portal-gtk)$ +windowrulev2 = stayfocused, class:(polkit-gnome-authentication-agent-1) -windowrulev2 = float, title:(File Operation Progress) -windowrulev2 = center, title:(File Operation Progress) - - - -windowrulev2 = stayfocused, class:(launcher) -# Layer Rules +#Layer Rules # layerrule = noanim, popup.* layerrule = noanim, hyprpicker layerrule = noanim, selection layerrule = noanim, noanim layerrule = ignorezero, gtk-layer-shell -layerrule = blur, notifications -layerrule = ignorealpha 0.69, notifications layerrule = noanim,selection -layerrule = noanim, notifications +# layerrule = noanim, fabric layerrule = animation slide, launcher -# fabric -# layerrule = noanim, fabric -# layerrule = ignorezero, fabric diff --git a/config/hypr/scripts/ScreenShot.sh b/config/hypr/scripts/ScreenShot.sh deleted file mode 100755 index 4c496029..00000000 --- a/config/hypr/scripts/ScreenShot.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -DIR="$HOME/Pictures/screenshots/" -NAME="screenshot_$(date +%d%m%Y_%H%M%S).png" - -# hyprshot -z -m region -o "/tmp" -f "$NAME" -s - -if [[ "$1" == "--window" ]]; then - hyprshot -z -m window -o "/tmp" -f "$NAME" -s -elif [[ "$1" == "--active" ]]; then - hyprshot -z -m active -m output -o "/tmp" -f "$NAME" -s -else - hyprshot -z -m region -o "/tmp" -f "$NAME" -s -- -fi - -swappy -f "/tmp/$NAME" -o "$DIR$NAME" diff --git a/config/hypr/scripts/battery.sh b/config/hypr/scripts/battery.sh new file mode 100755 index 00000000..113303db --- /dev/null +++ b/config/hypr/scripts/battery.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +# This script is used for the lockscreen battery indicator. + +for bat in /sys/class/power_supply/BAT*; do + if [ -e "$bat/uevent" ]; then + BAT_PATH="$bat" + break + fi +done + +if [ -z "$BAT_PATH" ]; then + echo "No battery found." + exit 1 +fi + +# Read battery status and capacity from the uevent file +POWER_SUPPLY_STATUS=$(grep "^POWER_SUPPLY_STATUS=" "$BAT_PATH/uevent" | cut -d'=' -f2) +POWER_SUPPLY_CAPACITY=$(grep "^POWER_SUPPLY_CAPACITY=" "$BAT_PATH/uevent" | cut -d'=' -f2) + +# Check if the values are actually found +if [ -z "$POWER_SUPPLY_STATUS" ] || [ -z "$POWER_SUPPLY_CAPACITY" ]; then + echo "Error: Could not read battery status or capacity." + exit 1 +fi + +declare -A battery_icons_charging=( + [100]="battery_charging_full" + [90]="battery_charging_90" + [80]="battery_charging_80" + [70]="battery_charging_80" + [60]="battery_charging_60" + [50]="battery_charging_50" + [40]="battery_charging_30" + [30]="battery_charging_30" + [20]="battery_charging_20" + [10]="battery_charging_20" + [0]="battery_charging_20" +) + +declare -A battery_icons=( + [100]="battery_full" + [90]="battery_6_bar" + [80]="battery_5_bar" + [70]="battery_5_bar" + [60]="battery_4_bar" + [50]="battery_3_bar" + [40]="battery_2_bar" + [30]="battery_2_bar" + [20]="battery_1_bar" + [10]="battery_1_bar" + [0]="battery_alert" +) + +get_closest_battery_icon() { + local level="$1" + local charging="$2" + local -n icons_array + + if [ "$charging" = "true" ]; then + icons_array=battery_icons_charging + else + icons_array=battery_icons + fi + + local levels=($(for key in "${!icons_array[@]}"; do echo "$key"; done | sort -nr)) + + for threshold in "${levels[@]}"; do + if [ "$level" -ge "$threshold" ]; then + echo "${icons_array[$threshold]}" + return + fi + done + + echo "${icons_array[${levels[-1]}]}" +} + +icon() { + local capacity="$POWER_SUPPLY_CAPACITY" + local charging="false" + + if [ "$POWER_SUPPLY_STATUS" = "Charging" ]; then + charging="true" + fi + + get_closest_battery_icon "$capacity" "$charging" +} + +info() { + cat "$BAT_PATH/uevent" +} + +status() { + echo "$POWER_SUPPLY_CAPACITY%" +} + +case $1 in + info) info ;; + icon) icon ;; + status) status ;; + *) + echo "Usage: $0 {info|icon|status}" + exit 1 + ;; +esac + diff --git a/config/hypr/scripts/status.sh b/config/hypr/scripts/status.sh deleted file mode 100755 index e542d205..00000000 --- a/config/hypr/scripts/status.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -############ Variables ############ -enable_battery=false - -####### Check availability ######## -for battery in /sys/class/power_supply/*BAT*; do - if [[ -f "$battery/uevent" ]]; then - enable_battery=true - break - fi -done - -############# Output ############# -if [[ $enable_battery == true ]]; then - if [[ $(cat /sys/class/power_supply/*/status | head -1) == "Charging" ]]; then - echo -n "(+) " - fi - echo -n "$(cat /sys/class/power_supply/*/capacity | head -1)"% remaining - echo '' -else - exit 1 -fi diff --git a/config/hypr/scripts/wallpaper.py b/config/hypr/scripts/wallpaper.py index bfa8b3df..45743170 100644 --- a/config/hypr/scripts/wallpaper.py +++ b/config/hypr/scripts/wallpaper.py @@ -114,10 +114,10 @@ async def main(): wallpaper_engine = settings['wallpaper-engine'] hyprpaper_tpl = settings['hyprpaper-tpl'] - new_wallpaper = f"{HOME}/dotfiles/wallpapers/lake.png" + new_wallpaper = f"{HOME}/Pictures/wallpapers/1.png" if random: - files = [f for f in os.listdir(f"{HOME}/Pictures/wallpapers") if f.endswith(('.png', '.jpg', '.jpeg'))] + files = [f for f in os.listdir(f"{HOME}/Pictures/wallpapers/") if f.endswith(('.png', '.jpg', '.jpeg'))] if files: new_wallpaper = join(f"{HOME}/Pictures/wallpapers", _random.choice(files)) elif prev: @@ -192,7 +192,7 @@ async def main(): if custom_color != "none" else None )), - scheme=GENERATOR.schemes[generation_scheme] + scheme_name=generation_scheme ) # ----------------------------------------------------- diff --git a/config/material-colors/generate.py b/config/material-colors/generate.py index 5bd382be..d4edcc57 100644 --- a/config/material-colors/generate.py +++ b/config/material-colors/generate.py @@ -1,40 +1,28 @@ -import argparse -import hashlib -import json import os -import pickle import random -import re import subprocess - -import numpy as np -from materialyoucolor.dynamiccolor.material_dynamic_colors import ( - MaterialDynamicColors, -) # type: ignore # noqa -from materialyoucolor.hct import Hct # type: ignore -from materialyoucolor.quantize import QuantizeCelebi # type: ignore -from materialyoucolor.scheme.dynamic_scheme import DynamicScheme # type: ignore # noqa -from materialyoucolor.scheme.scheme_content import SchemeContent # type: ignore # noqa -from materialyoucolor.scheme.scheme_expressive import ( - SchemeExpressive, -) # type: ignore # noqa -from materialyoucolor.scheme.scheme_fidelity import ( - SchemeFidelity, -) # type: ignore # noqa -from materialyoucolor.scheme.scheme_fruit_salad import ( - SchemeFruitSalad, -) # type: ignore # noqa -from materialyoucolor.scheme.scheme_monochrome import ( - SchemeMonochrome, -) # type: ignore # noqa -from materialyoucolor.scheme.scheme_neutral import SchemeNeutral # type: ignore # noqa -from materialyoucolor.scheme.scheme_rainbow import SchemeRainbow # type: ignore # noqa -from materialyoucolor.scheme.scheme_tonal_spot import ( - SchemeTonalSpot, -) # type: ignore # noqa -from materialyoucolor.scheme.scheme_vibrant import SchemeVibrant # type: ignore # noqa -from materialyoucolor.score.score import Score # type: ignore +import json from PIL import Image +import argparse +from materialyoucolor.quantize import QuantizeCelebi # type: ignore +from materialyoucolor.score.score import Score # type: ignore +from materialyoucolor.hct import Hct # type: ignore +from materialyoucolor.dynamiccolor.material_dynamic_colors import MaterialDynamicColors # type: ignore # noqa +from materialyoucolor.scheme.dynamic_scheme import DynamicScheme # type: ignore # noqa +from materialyoucolor.scheme.scheme_tonal_spot import SchemeTonalSpot # type: ignore # noqa +from materialyoucolor.scheme.scheme_expressive import SchemeExpressive # type: ignore # noqa +from materialyoucolor.scheme.scheme_fruit_salad import SchemeFruitSalad # type: ignore # noqa +from materialyoucolor.scheme.scheme_monochrome import SchemeMonochrome # type: ignore # noqa +from materialyoucolor.scheme.scheme_rainbow import SchemeRainbow # type: ignore # noqa +from materialyoucolor.scheme.scheme_vibrant import SchemeVibrant # type: ignore # noqa +from materialyoucolor.scheme.scheme_neutral import SchemeNeutral # type: ignore # noqa +from materialyoucolor.scheme.scheme_fidelity import SchemeFidelity # type: ignore # noqa +from materialyoucolor.scheme.scheme_content import SchemeContent # type: ignore # noqa +import hashlib +import pickle +import numpy as np +import re + schemes = { "tonalSpot": SchemeTonalSpot, -- 2.43.0