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/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/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 ae81ed08..0e3199eb 100644 --- a/config/fabric/main.py +++ b/config/fabric/main.py @@ -5,8 +5,13 @@ 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 modules.bar.bar import Bar +from modules.launcher.launcher import Launcher +from modules.notification_popup import NotificationPopup +from modules.osd import OSDContainer +from services import ScreenRecorder + +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("fabric-bar", bar, launcher, osd) + launcher = Launcher() + launcher.hide() + + app = Application( + "quickbar", + bar, + launcher, + osd, + ) setproctitle.setproctitle("quickbar") css_file = monitor_file(get_relative_path("styles")) @@ -35,7 +43,4 @@ if __name__ == "__main__": apply_style(app) - def quit_fabric(): - app.quit() - app.run() 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..12f7ab1f 100644 --- a/config/fabric/modules/bar/bar.py +++ b/config/fabric/modules/bar/bar.py @@ -8,22 +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, - PowerProfile, + 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,25 +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.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(name="tray", icon_size=16, spacing=4) + self.recorder = Recorder() + 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.recorder, + self.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 27ff16e8..0c03b6da 100644 --- a/config/fabric/modules/bar/widgets/__init__.py +++ b/config/fabric/modules/bar/widgets/__init__.py @@ -1,23 +1,10 @@ -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 .volume import * +from .workspace import * 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 a91dd160..ffc4fec8 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,12 +17,12 @@ 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 ) - 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/idle.py b/config/fabric/modules/bar/widgets/idle.py new file mode 100644 index 00000000..6cfb1a0f --- /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=16) + + def check_idle_status(self, *_): + + output = exec_shell_command("pidof wayland-idle-inhibitor.py") + is_idle = bool(str(output).strip()) + self.update_idle_status(is_idle) + + 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..18f095f8 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 = {} @@ -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 d84a6dad..a89baf7c 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=16) 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..3407134e 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, ) @@ -24,7 +25,7 @@ class Network(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): @@ -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..34884adf 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() @@ -30,7 +30,7 @@ class PowerProfile(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/launcher/launcher.py b/config/fabric/modules/launcher/launcher.py index 37636106..b4f6596f 100644 --- a/config/fabric/modules/launcher/launcher.py +++ b/config/fabric/modules/launcher/launcher.py @@ -13,6 +13,7 @@ from fabric.widgets.scrolledwindow import ScrolledWindow from fabric.widgets.wayland import WaylandWindow as Window from modules.launcher.widgets import ( BluetoothMenu, + Calendar, ClipboardManager, EmojiManager, PowerMenu, @@ -61,6 +62,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( @@ -149,7 +151,6 @@ 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) @@ -270,3 +271,9 @@ class Launcher(Window): dynamic_buttons = self.bluetooth_menu.get_bluetooth_buttons() self.update_dynamic_button(dynamic_buttons) self.scrolled_revealer.reveal() + + 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 81e42e29..c99174db 100644 --- a/config/fabric/modules/launcher/widgets/__init__.py +++ b/config/fabric/modules/launcher/widgets/__init__.py @@ -1,19 +1,9 @@ -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 .calendar 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 40c92df9..32d8aaca 100644 --- a/config/fabric/modules/launcher/widgets/app.py +++ b/config/fabric/modules/launcher/widgets/app.py @@ -5,59 +5,64 @@ 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: + if not query.strip(): launcher.additional_box.set_visible(True) - launcher.scrolled_revealer.unreveal() 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", - 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", - ), - ], - ), - ], - ), - name="app-item", - on_clicked=lambda *_: (app.launch(), launcher.set_visible(False)), - ) - for app in filtered_apps[:6] # Limit to 6 apps + bake_application_slot(launcher, app) for app in filtered_apps[:6] ] launcher.scrolled_revealer.reveal() else: launcher.scrolled_revealer.unreveal() + + +def bake_application_slot(launcher, app, **kwargs) -> Button: + return Button( + child=Box( + orientation="h", + spacing=10, + children=[ + Image(pixbuf=app.get_icon_pixbuf(), h_align="start", size=62), + Box( + orientation="v", + spacing=10, + children=[ + Label( + label=app.display_name or "Unknown", + h_expand=True, + name="title", + v_align="center", + h_align="start", + ), + Label( + label=app.description or "", + name="description", + h_expand=True, + v_align="center", + justification="left", + line_wrap="char", + ), + ], + ), + ], + ), + name="app-item", + on_clicked=lambda *_: (app.launch(), launcher.set_visible(False)), + **kwargs, + ) diff --git a/config/fabric/modules/launcher/widgets/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/calendar.py b/config/fabric/modules/launcher/widgets/calendar.py new file mode 100644 index 00000000..2b522287 --- /dev/null +++ b/config/fabric/modules/launcher/widgets/calendar.py @@ -0,0 +1,26 @@ +from fabric.widgets.box import Box +from fabric.widgets.button import Button +from gi.repository import Gtk +from snippets import MaterialIcon + + +class Calendar: + def __init__(self, launcher): + self.launcher = launcher + self.today_button = Button( + child=MaterialIcon("event_available"), + v_align="center", + ) + + def show_calendar_menu(self, viewport): + viewport.children = [] + + calendar_container = Box( + name="calendar", + children=Gtk.Calendar(visible=True, hexpand=True), + ) + + viewport.add(calendar_container) + + def get_calendar_buttons(self): + return self.today_button diff --git a/config/fabric/modules/launcher/widgets/clipboard.py b/config/fabric/modules/launcher/widgets/clipboard.py index 4b7b5cb2..7722633b 100644 --- a/config/fabric/modules/launcher/widgets/clipboard.py +++ b/config/fabric/modules/launcher/widgets/clipboard.py @@ -41,7 +41,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 +94,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"]: @@ -119,7 +122,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/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/launcher/widgets/wallpaper.py b/config/fabric/modules/launcher/widgets/wallpaper.py index a0e99000..7ea4b8a3 100644 --- a/config/fabric/modules/launcher/widgets/wallpaper.py +++ b/config/fabric/modules/launcher/widgets/wallpaper.py @@ -1,40 +1,38 @@ +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) - self.theme_toggle_button = self.create_theme_toggle_button() + self.wallpaper_dir = os.path.expanduser("~/Pictures/wallpapers") + os.makedirs(self.CACHE_DIR, exist_ok=True) + self.thumbnails = [] + self.theme_toggle_button = self._create_theme_toggle_button() self._update_button_style() - def create_theme_toggle_button(self): - 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,100 +42,114 @@ 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 get_cache_path(self, file_name: str) -> str: + file_hash = hashlib.md5(file_name.encode("utf-8")).hexdigest() + return os.path.join(self.CACHE_DIR, f"{file_hash}.png") + + def create_thumbnail(self, image_path: str, thumbnail_size=100): + try: + pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_path) + width, height = pixbuf.get_width(), pixbuf.get_height() + if width > height: + new_width = thumbnail_size + new_height = int(height * (thumbnail_size / width)) + else: + new_height = thumbnail_size + new_width = int(width * (thumbnail_size / height)) + return pixbuf.scale_simple( + new_width, new_height, GdkPixbuf.InterpType.BILINEAR + ) + except Exception as e: + logger.error(f"Error creating thumbnail for {image_path}: {e}") + return None + + def generate_or_load_thumbnail(self, wallpaper_path): + cache_path = self.get_cache_path(os.path.basename(wallpaper_path)) + + if not os.path.exists(cache_path): + pixbuf = self.create_thumbnail(wallpaper_path) + if pixbuf: + pixbuf.savev(cache_path, "png", [], []) + return cache_path + def show_wallpaper_thumbnails(self, viewport, search_term: str = ""): - wallpapers = 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 - thumbnail_path = self._generate_thumbnail(wallpaper) - thumbnail_button = self._create_wallpaper_thumbnail( - thumbnail_path, wallpaper - ) - row.add(thumbnail_button) + for index, wallpaper in enumerate(wallpapers, 1): + thumbnail_path = self.generate_or_load_thumbnail(wallpaper) + row.add(self._create_wallpaper_thumbnail(thumbnail_path, wallpaper)) - if (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 _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 _get_wallpapers(self, search_term: str): + return ( + os.path.join(self.wallpaper_dir, file_name) + for file_name in os.listdir(self.wallpaper_dir) + if os.path.isfile(os.path.join(self.wallpaper_dir, file_name)) + and os.path.splitext(file_name)[1].lower() in self.IMAGE_EXTENSIONS + and self._matches_search(file_name, search_term) + ) - def _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 _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): - 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", 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/notifications.py b/config/fabric/modules/notification_popup.py similarity index 65% rename from config/fabric/modules/notifications.py rename to config/fabric/modules/notification_popup.py index 948b68e6..ff60e3a9 100644 --- a/config/fabric/modules/notifications.py +++ b/config/fabric/modules/notification_popup.py @@ -1,3 +1,5 @@ +import time + import gi gi.require_version("GdkPixbuf", "2.0") @@ -11,11 +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, GLib +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): @@ -50,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( @@ -70,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" + ), ), ), ), @@ -95,11 +142,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( @@ -142,8 +194,32 @@ class NotificationWidget(Box): ), ) - def get_icon(self, app_icon, app_name, size) -> Image: + 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 = ( + 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,11 +240,18 @@ 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) + 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/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/services/__init__.py b/config/fabric/services/__init__.py index 1df3d07e..7373da1a 100644 --- a/config/fabric/services/__init__.py +++ b/config/fabric/services/__init__.py @@ -1,12 +1,3 @@ -from .brightness import Brightness -from .screen_record import ScreenRecorder -from .weather import WeatherInfo -from .wifi import NetworkClient, Wifi - -__all__ = [ - "Brightness", - "ScreenRecorder", - "WeatherInfo", - "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 6a1fc993..5f2f12c1 100644 --- a/config/fabric/services/screen_record.py +++ b/config/fabric/services/screen_record.py @@ -1,31 +1,21 @@ 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): + 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 + self.screenrecord_path = GLib.get_home_dir() + "/Videos/Screenrecords/" + super().__init__(**kwargs) def screenshot(self, fullscreen=False, save_copy=True): @@ -37,28 +27,70 @@ 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): + 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" - area = "" - if fullscreen: - area = exec_shell_command("slurp") - command = f"wf-recorder -g {area} -f {file_path}" + 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}" 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): + 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 +135,8 @@ 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 len(exec_shell_command("pidof wf-recorder")) != 0 + diff --git a/config/fabric/snippets/__init__.py b/config/fabric/snippets/__init__.py index d6986d37..add4b114 100644 --- a/config/fabric/snippets/__init__.py +++ b/config/fabric/snippets/__init__.py @@ -1,19 +1,5 @@ -from .animator import Animator -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", -] +from .animator import * +from .custom_image import * +from .functions import * +from .icon import * +from .icon_resolver import * 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/snippets/icon.py b/config/fabric/snippets/icon.py index 7bf8e7ac..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: dict = None): +def MaterialIcon(icon_name: str, size: int = 24, 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 + "style": f"font-size: {size}px;", # Set font family for Material Icons "h_align": "center", # Align horizontally "v_align": "center", # Align vertically } 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/fabric/styles/bar.css b/config/fabric/styles/bar.css index 6d8af42b..1e3d4137 100644 --- a/config/fabric/styles/bar.css +++ b/config/fabric/styles/bar.css @@ -155,3 +155,44 @@ menu > menuitem:hover { color: lighter(@outlineVariant); border: 2px solid @onSecondaryContainer; } + +/* + * ── system tray ─────────────────────────────────────────────────────── +*/ + +#system-tray { + background-color: @surfaceContainer; + border-radius: 100px; + padding: 2px 10px 0 10px; +} + +#system-tray > button { + margin: 0px; + padding: 0px; +} + +#system-tray-menu > menuitem menu, +#system-tray-menu { + background-color: @surfaceContainer; + border-radius: 12px; + padding: 10px; +} + +#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: mix(@onSurface, @surface, 0.85); +} 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); +} diff --git a/config/fabric/styles/main.css b/config/fabric/styles/main.css index 79ebe208..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/fabric/styles/notification.css b/config/fabric/styles/notification.css index 88d79b72..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; @@ -45,3 +49,12 @@ #notification-icon { margin-right: 5px; } + +.image { + border-radius: 30px; +} + +#notification-circular-progress-bar { + border: solid 0px @outlineVariant; + color: transparent; +} 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..3bbcd2ed 100644 --- a/config/hypr/UserConfigs/UserSettings.conf +++ b/config/hypr/UserConfigs/UserSettings.conf @@ -15,80 +15,15 @@ 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 +62,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 +77,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..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,49 +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 - -# 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)$ @@ -62,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.*)$ @@ -98,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) @@ -121,76 +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)$ -windowrule = float, kitty_float - +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) - - - -# Layer Rules -layerrule = noanim, popup.* +#Layer Rules +# 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 - -# fabric -layerrule = noanim, fabric -# layerrule = ignorezero, fabric +# layerrule = noanim, fabric +layerrule = animation slide, launcher 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/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 c389c686..d4edcc57 100644 --- a/config/material-colors/generate.py +++ b/config/material-colors/generate.py @@ -33,7 +33,7 @@ schemes = { "vibrant": SchemeVibrant, "neutral": SchemeNeutral, "fidelity": SchemeFidelity, - "content": SchemeContent + "content": SchemeContent, } @@ -41,7 +41,7 @@ def join(*args): return os.path.join(*args) -home = os.path.expanduser('~') +home = os.path.expanduser("~") script_dir = os.path.dirname(os.path.abspath(__file__)) cache_path = f"{home}/.cache/material/" @@ -49,14 +49,14 @@ os.makedirs(cache_path, exist_ok=True) def rgb_to_hex(rgb): - return '#{:02x}{:02x}{:02x}'.format(*rgb[:3]) + return "#{:02x}{:02x}{:02x}".format(*rgb[:3]) def rgba_to_rgb(rgba): - return f'{rgba[0]}, {rgba[1]}, {rgba[2]}' + return f"{rgba[0]}, {rgba[1]}, {rgba[2]}" -class Color(): +class Color: def __init__(self, scheme) -> None: self.scheme = scheme @@ -70,11 +70,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 +97,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 +110,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 +125,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 +146,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 +172,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 +198,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 +206,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 +242,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 +259,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 +280,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 +290,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 +310,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 +325,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 +340,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 +372,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 +404,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; } +