huge update
This commit is contained in:
1 parent
4b4f291ee1
commit
6a65dcf899
30 files changed
+1143
-196
No files matched your search
Executable
+44
@@ -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
|
||||
|
||||
+18
-10
@@ -1,12 +1,17 @@
|
||||
import os
|
||||
|
||||
import setproctitle
|
||||
from loguru import logger
|
||||
|
||||
from fabric import Application
|
||||
from fabric.utils import get_relative_path, monitor_file
|
||||
from modules import Bar, Launcher, NotificationPopup, OSDContainer
|
||||
from services import Brightness, ScreenRecorder
|
||||
from loguru import logger
|
||||
|
||||
from modules.bar.bar import Bar
|
||||
from modules.launcher.launcher import Launcher
|
||||
from modules.notifications import NotificationPopup
|
||||
from modules.osd import OSDContainer
|
||||
from services import ScreenRecorder
|
||||
|
||||
logger.disable("fabric.hyprland.widgets")
|
||||
|
||||
|
||||
def apply_style(app: Application):
|
||||
@@ -16,15 +21,18 @@ def apply_style(app: Application):
|
||||
|
||||
if __name__ == "__main__":
|
||||
sc = ScreenRecorder()
|
||||
brightness = Brightness()
|
||||
|
||||
logger.disable("fabric.hyprland.widgets")
|
||||
bar = Bar()
|
||||
launcher = Launcher()
|
||||
launcher.hide()
|
||||
osd = OSDContainer()
|
||||
notif = NotificationPopup()
|
||||
app = Application("quickbar", bar, launcher, osd)
|
||||
launcher = Launcher()
|
||||
launcher.hide()
|
||||
|
||||
app = Application(
|
||||
"quickbar",
|
||||
bar,
|
||||
launcher,
|
||||
osd,
|
||||
)
|
||||
setproctitle.setproctitle("quickbar")
|
||||
|
||||
css_file = monitor_file(get_relative_path("styles"))
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
@@ -6,24 +6,26 @@ from fabric.widgets.button import Button
|
||||
from fabric.widgets.centerbox import CenterBox
|
||||
from fabric.widgets.datetime import DateTime
|
||||
from fabric.widgets.wayland import WaylandWindow as Window
|
||||
|
||||
from modules.bar.widgets import (
|
||||
BatteryLabel,
|
||||
Bluetooth,
|
||||
BluetoothIndicator,
|
||||
IdleIndicator,
|
||||
MicrophoneIndicator,
|
||||
Network,
|
||||
PowerProfile,
|
||||
NetworkIndicator,
|
||||
PowerProfileIndicator,
|
||||
SystemInfo,
|
||||
SystemTray,
|
||||
TaskBar,
|
||||
VolumeIndicator,
|
||||
workspace,
|
||||
)
|
||||
from services import ScreenRecorder
|
||||
from snippets import MaterialIcon
|
||||
|
||||
|
||||
class Bar(Window):
|
||||
def __init__(
|
||||
self,
|
||||
):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
layer="top",
|
||||
anchor="left bottom right",
|
||||
@@ -31,6 +33,8 @@ class Bar(Window):
|
||||
visible=False,
|
||||
all_visible=False,
|
||||
)
|
||||
self.screen_recorder = ScreenRecorder()
|
||||
self.workspaces = Button(child=workspace, name="workspaces")
|
||||
self.language = Language(
|
||||
formatter=FormattedString(
|
||||
"{replace_lang(language)}",
|
||||
@@ -42,25 +46,38 @@ class Bar(Window):
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
self.date_time = DateTime(formatters=["%-I:%M %a %d %b"], name="datetime")
|
||||
self.system_tray = SystemTray(name="tray", spacing=4, icon_size=18)
|
||||
self.taskbar = TaskBar()
|
||||
self.volume = VolumeIndicator()
|
||||
self.network = Network()
|
||||
self.bluetooth = Bluetooth()
|
||||
|
||||
self.recording_indicator = Button(
|
||||
name="bar-button",
|
||||
child=MaterialIcon("screen_record", size="16px"),
|
||||
visible=False,
|
||||
on_clicked=lambda *_: self.screen_recorder.screencast_stop(),
|
||||
)
|
||||
|
||||
self.screen_recorder.connect(
|
||||
"recording",
|
||||
lambda _, status: self.recording_indicator.set_visible(status),
|
||||
)
|
||||
|
||||
self.battery = BatteryLabel(name="battery")
|
||||
self.volume = VolumeIndicator()
|
||||
self.bluetooth = BluetoothIndicator()
|
||||
self.network = NetworkIndicator()
|
||||
self.microphone = MicrophoneIndicator()
|
||||
self.power = PowerProfile()
|
||||
self.workspaces = Button(child=workspace, name="workspaces")
|
||||
self.info = SystemInfo()
|
||||
self.idle = IdleIndicator()
|
||||
self.taskbar = TaskBar()
|
||||
self.info = SystemInfo()
|
||||
self.powerindicator = PowerProfileIndicator()
|
||||
self.tray = SystemTray()
|
||||
|
||||
self.applets = Box(
|
||||
name="applets",
|
||||
spacing=4,
|
||||
orientation="h",
|
||||
children=[
|
||||
self.language,
|
||||
self.power,
|
||||
self.powerindicator,
|
||||
self.bluetooth,
|
||||
self.network,
|
||||
self.volume,
|
||||
@@ -84,16 +101,15 @@ class Bar(Window):
|
||||
name="center-container",
|
||||
spacing=8,
|
||||
orientation="h",
|
||||
children=[
|
||||
self.taskbar,
|
||||
],
|
||||
children=self.taskbar,
|
||||
),
|
||||
end_children=Box(
|
||||
name="end-container",
|
||||
spacing=8,
|
||||
orientation="h",
|
||||
children=[
|
||||
self.system_tray,
|
||||
# self.recording_indicator,
|
||||
self.tray,
|
||||
self.battery,
|
||||
self.applets,
|
||||
self.date_time,
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
/* we can use webcss variables, fabric compiles that to gtk css.
|
||||
global variables can be stored in :vars */
|
||||
:vars {
|
||||
--background: #150d16;
|
||||
--foreground: #f5dbc4;
|
||||
--color0: #150d16;
|
||||
--color1: #72448d;
|
||||
--color2: #9c5995;
|
||||
--color3: #d5719f;
|
||||
--color4: #9a62f3;
|
||||
--color5: #e075df;
|
||||
--color6: #f98f9f;
|
||||
--color7: #f5dbc4;
|
||||
--color8: #ab9989;
|
||||
--color9: #72448d;
|
||||
--color10: #9c5995;
|
||||
--color11: #d5719f;
|
||||
--color12: #9a62f3;
|
||||
--color13: #e075df;
|
||||
--color14: #f98f9f;
|
||||
--color15: #f5dbc4;
|
||||
--window-bg: alpha(var(--background), 0.6);
|
||||
--module-bg: alpha(var(--background), 0.4);
|
||||
--border-color: var(--color11);
|
||||
--ws-active: var(--color9);
|
||||
--ws-inactive: var(--color3);
|
||||
--ws-empty: var(--color8);
|
||||
--ws-hover: var(--color1);
|
||||
--ws-urgent: var(--color12);
|
||||
}
|
||||
|
||||
@import url(../../../.cache/material/colors.css);
|
||||
|
||||
#bar {
|
||||
background-color: @surface;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
#bar label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#start-container,
|
||||
#center-container,
|
||||
#end-container {
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 12px;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
#battery {
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 100px;
|
||||
padding: 2px 10px 2px 10px;
|
||||
}
|
||||
|
||||
#workspaces {
|
||||
border-radius: 100px;
|
||||
font-style: normal;
|
||||
background: @surfaceContainer;
|
||||
padding: 0px 10px 0px 10px;
|
||||
}
|
||||
|
||||
#datetime {
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 100px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#applets {
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 100px;
|
||||
padding: 2px 10px 2px 10px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#applets .icon {
|
||||
color: @onSurface;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
#applets > button {
|
||||
color: @onSurface;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#taskbar {
|
||||
border-radius: 100px;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
color: @onSurface;
|
||||
background: @surfaceContainer;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
#taskbar .activated {
|
||||
border-radius: 100px;
|
||||
background: @surfaceVariant;
|
||||
}
|
||||
|
||||
#taskbar > button {
|
||||
padding: 0px 4px;
|
||||
margin: 4px 0px;
|
||||
border-radius: 100px;
|
||||
border: 0px;
|
||||
}
|
||||
#taskbar > button:last-child {
|
||||
margin-right: 0px;
|
||||
}
|
||||
|
||||
#info {
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 100px;
|
||||
padding: 2px 10px 0px 10px;
|
||||
}
|
||||
|
||||
#info > button {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#info .progress {
|
||||
color: lighter(@outlineVariant);
|
||||
border: 2px solid @onSecondaryContainer;
|
||||
}
|
||||
|
||||
#material_icon,
|
||||
#material_icon * {
|
||||
all: unset;
|
||||
font-family: "Material Symbols Outlined", "Material Symbols Sharp";
|
||||
}
|
||||
|
||||
/* unset so we can style everything from the ground up. */
|
||||
* {
|
||||
all: unset;
|
||||
color: @foreground;
|
||||
font-size: 16px;
|
||||
font-family: "Product Sans", Roboto, "Font Awesome 6 Free", Helvetica, Arial,
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
button {
|
||||
background-size: 400% 400%;
|
||||
}
|
||||
|
||||
menu > menuitem > label {
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
/* system tray */
|
||||
#system-tray {
|
||||
padding: 2px 4px;
|
||||
background-color: var(--module-bg);
|
||||
}
|
||||
|
||||
/* menu and menu items (written for the system tray) */
|
||||
menu {
|
||||
border: solid 2px;
|
||||
border-radius: 10px;
|
||||
border-color: var(--border-color);
|
||||
background-color: var(--window-bg);
|
||||
}
|
||||
|
||||
menu > menuitem {
|
||||
border-radius: 0px;
|
||||
background-color: var(--module-bg);
|
||||
padding: 6px;
|
||||
margin-left: 2px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
menu > menuitem:first-child {
|
||||
margin-top: 1px;
|
||||
border-radius: 8px 8px 0px 0px;
|
||||
}
|
||||
|
||||
menu > menuitem:last-child {
|
||||
margin-bottom: 1px;
|
||||
border-radius: 0px 0px 8px 8px;
|
||||
}
|
||||
|
||||
menu > menuitem:hover {
|
||||
background-color: var(--border-color);
|
||||
}
|
||||
|
||||
tooltip {
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 11px;
|
||||
outline: none;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
tooltip label {
|
||||
color: @onSurface;
|
||||
outline: none;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
font-weight: normal;
|
||||
}
|
||||
@@ -1,23 +1,11 @@
|
||||
from .battery import BatteryLabel
|
||||
from .bluetooth import Bluetooth
|
||||
from .idle_indicator import IdleIndicator
|
||||
from .info import SystemInfo
|
||||
from .microphone import MicrophoneIndicator
|
||||
from .network import Network
|
||||
from .powerprofile import PowerProfile
|
||||
from .taskbar import TaskBar
|
||||
from .volume import VolumeIndicator
|
||||
from .workspace import workspace
|
||||
|
||||
__all__ = [
|
||||
"BatteryLabel",
|
||||
"Bluetooth",
|
||||
"IdleIndicator",
|
||||
"SystemInfo",
|
||||
"MicrophoneIndicator",
|
||||
"Network",
|
||||
"PowerProfile",
|
||||
"VolumeIndicator",
|
||||
"workspace",
|
||||
"TaskBar",
|
||||
]
|
||||
from .battery import *
|
||||
from .bluetooth import *
|
||||
from .idle import *
|
||||
from .info import *
|
||||
from .microphone import *
|
||||
from .network import *
|
||||
from .powerprofile import *
|
||||
from .taskbar import *
|
||||
from .tray import *
|
||||
from .volume import *
|
||||
from .workspace import *
|
||||
@@ -3,7 +3,7 @@ from fabric.widgets.box import Box
|
||||
from snippets import MaterialIcon
|
||||
|
||||
|
||||
class Bluetooth(Box):
|
||||
class BluetoothIndicator(Box):
|
||||
ICON_ENABLED = "bluetooth"
|
||||
ICON_DISABLED = "bluetooth_disabled"
|
||||
|
||||
@@ -17,7 +17,7 @@ class Bluetooth(Box):
|
||||
|
||||
self.update_bluetooth_status()
|
||||
|
||||
def update_bluetooth_status(self, *args):
|
||||
def update_bluetooth_status(self, *_):
|
||||
icon_label = (
|
||||
self.ICON_ENABLED if self.bluetooth_client.enabled else self.ICON_DISABLED
|
||||
)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from fabric.widgets.label import Label
|
||||
|
||||
|
||||
def MaterialIcon(icon_name: str, size: str = "24px", props: dict = None):
|
||||
label_props = {
|
||||
"label": icon_name, # Directly use the provided icon name
|
||||
"name": "material_icon",
|
||||
"style": f"font-size: {size}; ", # Set font family for Material Icons
|
||||
"h_align": "center", # Align horizontally
|
||||
"v_align": "center", # Align vertically
|
||||
}
|
||||
|
||||
if props:
|
||||
label_props.update(props)
|
||||
|
||||
return Label(**label_props)
|
||||
@@ -0,0 +1,29 @@
|
||||
from fabric import Fabricator
|
||||
from fabric.utils import exec_shell_command
|
||||
from fabric.widgets.box import Box
|
||||
from snippets import MaterialIcon
|
||||
|
||||
|
||||
class IdleIndicator(Box):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.idle_icon = self.create_idle_icon()
|
||||
self.fabricator = Fabricator(interval=1000, poll_from=self.check_idle_status)
|
||||
|
||||
self.children = [self.idle_icon]
|
||||
|
||||
def create_idle_icon(self):
|
||||
return MaterialIcon("schedule", size="16px")
|
||||
|
||||
def check_idle_status(self, *_):
|
||||
|
||||
output = exec_shell_command("pidof wayland-idle-inhibitor.py")
|
||||
is_idle = bool(str(output).strip())
|
||||
self.update_idle_status(is_idle)
|
||||
|
||||
def update_idle_status(self, is_idle):
|
||||
if is_idle:
|
||||
self.idle_icon.set_visible(True)
|
||||
else:
|
||||
self.idle_icon.set_visible(False)
|
||||
@@ -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)
|
||||
@@ -18,10 +18,10 @@ class SystemInfo(Button):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(child=self._initialize_content())
|
||||
Fabricator(poll_from=self._refresh_system_info, interval=1000)
|
||||
self.fabricator = Fabricator(poll_from=self._refresh_system_info, interval=1000)
|
||||
|
||||
def _initialize_content(self):
|
||||
self.box = Box(orientation="h", name="tray")
|
||||
self.box = Box(orientation="h", name="info")
|
||||
self.progress_bars = {}
|
||||
self.labels = {}
|
||||
self.icons = {}
|
||||
@@ -42,7 +42,7 @@ class SystemInfo(Button):
|
||||
|
||||
def _create_progress_bar(self):
|
||||
return CircularProgressBar(
|
||||
name="progress", line_style="round", line_width=1, size=30
|
||||
style_classes="progress", line_style="round", line_width=1, size=30
|
||||
)
|
||||
|
||||
def _create_label(self):
|
||||
|
||||
@@ -4,8 +4,6 @@ from snippets import MaterialIcon
|
||||
|
||||
|
||||
class MicrophoneIndicator(Box):
|
||||
ICON_MUTED = "mic_off"
|
||||
ICON_UNMUTED = "mic"
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
@@ -18,14 +16,14 @@ class MicrophoneIndicator(Box):
|
||||
self.children = (self.microphone_icon,)
|
||||
|
||||
def create_microphone_icon(self):
|
||||
return MaterialIcon(self.ICON_MUTED, size="16px")
|
||||
return MaterialIcon("mic_off", size="16px")
|
||||
|
||||
def update_microphone_status(self, *args):
|
||||
current_microphone = self.audio_service.microphone
|
||||
|
||||
if current_microphone:
|
||||
is_muted = current_microphone.muted
|
||||
icon_name = self.ICON_MUTED if is_muted else self.ICON_UNMUTED
|
||||
icon_name = "mic_off" if is_muted else "mic"
|
||||
|
||||
self.microphone_icon.set_label(icon_name)
|
||||
self.microphone_icon.set_visible(is_muted)
|
||||
|
||||
@@ -6,12 +6,13 @@ from fabric.widgets.box import Box
|
||||
from snippets import MaterialIcon
|
||||
|
||||
|
||||
class Network(Box):
|
||||
class NetworkIndicator(Box):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.update_interval = 1000
|
||||
self.update_interval = 5000 # Increased interval to 5 seconds
|
||||
self.last_status = None
|
||||
Fabricator(
|
||||
self.wifi_strength_cache = None
|
||||
self.fabricator = Fabricator(
|
||||
interval=self.update_interval,
|
||||
poll_from=self.update_network_status,
|
||||
)
|
||||
@@ -36,6 +37,10 @@ class Network(Box):
|
||||
|
||||
def get_wifi_strength_icon(self):
|
||||
wifi_strength = self.check_wifi_strength()
|
||||
if wifi_strength is not None:
|
||||
self.wifi_strength_cache = wifi_strength # Cache the result
|
||||
else:
|
||||
wifi_strength = self.wifi_strength_cache # Use cached value if available
|
||||
|
||||
return self.wifi_signal_icon(wifi_strength)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
import gi
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.image import Image
|
||||
from gi.repository import Gdk, GdkPixbuf, Gray, Gtk
|
||||
from loguru import logger
|
||||
|
||||
gi.require_version("Gray", "0.1")
|
||||
gi.require_version("Gtk", "3.0")
|
||||
|
||||
|
||||
class SystemTray(Box):
|
||||
def __init__(self, pixel_size: int = 16, **kwargs) -> None:
|
||||
super().__init__(name="system-tray", **kwargs)
|
||||
self.pixel_size = pixel_size
|
||||
self.watcher = Gray.Watcher()
|
||||
self.watcher.connect("item-added", self.on_item_added)
|
||||
|
||||
def on_item_added(self, _, identifier: str):
|
||||
item = self.watcher.get_item_for_identifier(identifier)
|
||||
item_button = self.do_bake_item_button(item)
|
||||
item.connect("removed", lambda *args: item_button.destroy())
|
||||
item.connect(
|
||||
"icon-changed",
|
||||
lambda icon_item: self.do_update_item_button(icon_item, item_button),
|
||||
)
|
||||
item_button.show_all()
|
||||
self.add(item_button)
|
||||
|
||||
def do_bake_item_button(self, item: Gray.Item) -> Button:
|
||||
button = Button()
|
||||
# context menu handler
|
||||
button.connect(
|
||||
"button-press-event",
|
||||
lambda button, event: self.on_button_click(button, item, event),
|
||||
)
|
||||
self.do_update_item_button(item, button)
|
||||
|
||||
return button
|
||||
|
||||
def do_update_item_button(self, item: Gray.Item, item_button: Button):
|
||||
pixmap = Gray.get_pixmap_for_pixmaps(item.get_icon_pixmaps(), 24)
|
||||
|
||||
# convert the pixmap to a pixbuf
|
||||
pixbuf: GdkPixbuf.Pixbuf = (
|
||||
pixmap.as_pixbuf(self.config["icon_size"], GdkPixbuf.InterpType.HYPER)
|
||||
if pixmap is not None
|
||||
else Gtk.IconTheme()
|
||||
.get_default()
|
||||
.load_icon(
|
||||
item.get_icon_name(),
|
||||
self.pixel_size,
|
||||
Gtk.IconLookupFlags.FORCE_SIZE,
|
||||
)
|
||||
)
|
||||
item_button.set_image(Image(pixbuf=pixbuf, pixel_size=self.pixel_size))
|
||||
|
||||
def on_button_click(self, button, item: Gray.Item, event):
|
||||
match event.button:
|
||||
case 1:
|
||||
try:
|
||||
item.activate(event.x, event.y)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
case 3:
|
||||
menu = item.get_property("menu")
|
||||
menu.set_name("system-tray-menu")
|
||||
if menu:
|
||||
menu.popup_at_widget(
|
||||
button,
|
||||
Gdk.Gravity.SOUTH,
|
||||
Gdk.Gravity.NORTH,
|
||||
event,
|
||||
)
|
||||
else:
|
||||
item.context_menu(event.x, event.y)
|
||||
@@ -1,5 +1,7 @@
|
||||
from fabric import Application
|
||||
from fabric.utils import (
|
||||
get_desktop_applications,
|
||||
get_relative_path,
|
||||
idle_add,
|
||||
invoke_repeater,
|
||||
remove_handler,
|
||||
@@ -155,7 +157,7 @@ class Launcher(Window):
|
||||
if handler:
|
||||
handler(query[len(command) :].strip())
|
||||
return
|
||||
self.scrolled_revealer.unreveal()
|
||||
|
||||
if query.startswith(":"):
|
||||
self.additional_box.set_visible(False)
|
||||
self.update_dynamic_button([self.default_button])
|
||||
@@ -224,21 +226,25 @@ class Launcher(Window):
|
||||
self.network_menu.show_wifi_menu(self.viewport)
|
||||
dynamic_buttons = self.network_menu.get_wifi_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_emojis(self, query: str):
|
||||
self.emoji_manager.show_emojis(self.get_viewport(), query)
|
||||
dynamic_buttons = self.emoji_manager.get_emoji_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_clipboard_history(self, query: str):
|
||||
self.clipboard_manager.show_clipboard_history(self.get_viewport(), query)
|
||||
dynamic_buttons = self.clipboard_manager.get_clipboard_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_powermenu(self, query: str = ""):
|
||||
self.power_menu.show_power_menu(self.get_viewport(), query)
|
||||
dynamic_buttons = self.power_menu.get_power_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_shell_commands(self, query: str):
|
||||
if not query:
|
||||
@@ -249,6 +255,7 @@ class Launcher(Window):
|
||||
self.shell_command_manager.show_shell_commands(self.get_viewport(), query)
|
||||
dynamic_buttons = self.shell_command_manager.get_shell_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_wallpapers(self, query: str):
|
||||
if query == "random":
|
||||
@@ -257,8 +264,17 @@ class Launcher(Window):
|
||||
self.wallpaper_manager.show_wallpaper_thumbnails(self.get_viewport(), query)
|
||||
dynamic_buttons = self.wallpaper_manager.get_wallpaper_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_bluetooth_settings(self, *_):
|
||||
self.bluetooth_menu.show_bluetooth_menu(self.viewport)
|
||||
dynamic_buttons = self.bluetooth_menu.get_bluetooth_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# launcher = Launcher()
|
||||
# app = Application("launcher", launcher)
|
||||
# app.set_stylesheet_from_file(get_relative_path("./styles/main.css"))
|
||||
# app.run()
|
||||
@@ -1,19 +1,8 @@
|
||||
from .app import handle_application_search
|
||||
from .bluetooth import BluetoothMenu
|
||||
from .clipboard import ClipboardManager
|
||||
from .emoji import EmojiManager
|
||||
from .power_menu import PowerMenu
|
||||
from .shell import ShellCommandManager
|
||||
from .wallpaper import WallpaperManager
|
||||
from .wifi import WifiMenu
|
||||
|
||||
__all__ = [
|
||||
"handle_application_search",
|
||||
"ClipboardManager",
|
||||
"EmojiManager",
|
||||
"ShellCommandManager",
|
||||
"WallpaperManager",
|
||||
"WifiMenu",
|
||||
"BluetoothMenu",
|
||||
"PowerMenu",
|
||||
]
|
||||
from .app import *
|
||||
from .bluetooth import *
|
||||
from .clipboard import *
|
||||
from .emoji import *
|
||||
from .power_menu import *
|
||||
from .shell import *
|
||||
from .wallpaper import *
|
||||
from .wifi import *
|
||||
@@ -6,10 +6,10 @@ from fabric.widgets.label import Label
|
||||
|
||||
def handle_application_search(launcher, query: str):
|
||||
if not query.strip():
|
||||
launcher.scrolled_revealer.unreveal()
|
||||
launcher.additional_box.set_visible(True)
|
||||
return
|
||||
|
||||
launcher.additional_box.set_visible(False)
|
||||
filtered_apps = [
|
||||
app
|
||||
for app in launcher.all_apps
|
||||
@@ -28,7 +28,6 @@ def handle_application_search(launcher, query: str):
|
||||
bake_application_slot(launcher, app) for app in filtered_apps[:6]
|
||||
]
|
||||
launcher.scrolled_revealer.reveal()
|
||||
launcher.additional_box.set_visible(False)
|
||||
else:
|
||||
launcher.scrolled_revealer.unreveal()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.image import Image
|
||||
from fabric.widgets.label import Label
|
||||
from snippets import MaterialIcon
|
||||
|
||||
|
||||
class NotificationManager:
|
||||
def __init__(self, launcher):
|
||||
self.launcher = launcher
|
||||
self.notifications = []
|
||||
|
||||
self.notification_button = self.create_notification_button()
|
||||
self.update_notification_button_style()
|
||||
|
||||
def create_notification_button(self):
|
||||
button = Button(
|
||||
child=MaterialIcon("notifications"),
|
||||
h_align="center",
|
||||
v_align="center",
|
||||
on_clicked=self.show_notification_menu,
|
||||
)
|
||||
return button
|
||||
|
||||
def add_notification(self, title, message, icon_name="notifications"):
|
||||
"""Add a new notification."""
|
||||
notification = {
|
||||
"title": title,
|
||||
"message": message,
|
||||
"icon_name": icon_name,
|
||||
}
|
||||
self.notifications.append(notification)
|
||||
self.update_notification_button_style()
|
||||
|
||||
def remove_notification(self, index):
|
||||
"""Remove a notification by index."""
|
||||
if 0 <= index < len(self.notifications):
|
||||
del self.notifications[index]
|
||||
self.update_notification_button_style()
|
||||
|
||||
def clear_notifications(self):
|
||||
"""Clear all notifications."""
|
||||
self.notifications.clear()
|
||||
self.update_notification_button_style()
|
||||
|
||||
def update_notification_button_style(self):
|
||||
"""Update the notification button style based on the notification count."""
|
||||
count = len(self.notifications)
|
||||
if count > 0:
|
||||
style = "background-color: @surfaceVariant; border-radius: 50%;"
|
||||
self.notification_button.set_style(style)
|
||||
self.notification_button.set_label(str(count))
|
||||
else:
|
||||
style = "background-color: transparent;"
|
||||
self.notification_button.set_style(style)
|
||||
self.notification_button.set_label("")
|
||||
|
||||
def show_notification_menu(self, *_):
|
||||
"""Display the notification menu."""
|
||||
viewport = self.launcher.viewport
|
||||
viewport.children = []
|
||||
notifications_box = Box(orientation="v", spacing=5)
|
||||
|
||||
for index, notification in enumerate(self.notifications):
|
||||
notification_button = self.create_notification_button_item(
|
||||
notification, index
|
||||
)
|
||||
notifications_box.add(notification_button)
|
||||
|
||||
viewport.add(notifications_box)
|
||||
|
||||
def create_notification_button_item(self, notification, index):
|
||||
"""Create a button for an individual notification."""
|
||||
return Button(
|
||||
child=Box(
|
||||
orientation="h",
|
||||
spacing=10,
|
||||
children=[
|
||||
Image(icon_name=notification["icon_name"], size=32),
|
||||
Box(
|
||||
orientation="v",
|
||||
spacing=2,
|
||||
children=[
|
||||
Label(label=notification["title"], bold=True),
|
||||
Label(label=notification["message"]),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
on_clicked=lambda _, idx=index: self.remove_notification(idx),
|
||||
name="notification-item",
|
||||
)
|
||||
|
||||
def get_notification_button(self):
|
||||
"""Get the notification button for the UI."""
|
||||
return self.notification_button
|
||||
@@ -12,7 +12,7 @@ from snippets import MaterialIcon
|
||||
|
||||
class WallpaperManager:
|
||||
IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".webp"}
|
||||
CACHE_DIR = os.path.expanduser("~/.cache/fabric/thumbnails/wallpapers")
|
||||
CACHE_DIR = os.path.expanduser("~/.cache/fabric/wall")
|
||||
WALLPAPER_SCRIPT_PATH = os.path.expanduser("~/dotfiles/hypr/scripts/wallpaper.py")
|
||||
|
||||
def __init__(self):
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
import os
|
||||
import threading
|
||||
from pathlib import Path
|
||||
|
||||
from fabric.utils import exec_shell_command, exec_shell_command_async
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from loguru import logger
|
||||
from snippets import MaterialIcon
|
||||
|
||||
|
||||
class WallpaperManager:
|
||||
IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".webp"}
|
||||
THUMBNAIL_SIZE = "x64"
|
||||
THUMBNAIL_ASPECT_RATIO = "1:1"
|
||||
WALLPAPER_SCRIPT_PATH = os.path.expanduser("~/dotfiles/hypr/scripts/wallpaper.py")
|
||||
|
||||
def __init__(self):
|
||||
self.wallpaper_dir = Path.home() / "Pictures" / "wallpapers"
|
||||
self.thumbnail_dir = (
|
||||
Path.home() / ".cache" / "fabric" / "thumbnails" / "wallpapers"
|
||||
)
|
||||
self.thumbnail_dir.mkdir(parents=True, exist_ok=True)
|
||||
self.theme_toggle_button = self._create_theme_toggle_button()
|
||||
self._update_button_style()
|
||||
|
||||
def _create_theme_toggle_button(self):
|
||||
return Button(
|
||||
child=MaterialIcon("contrast"),
|
||||
v_align="center",
|
||||
on_clicked=self.toggle_dark_mode,
|
||||
)
|
||||
|
||||
def toggle_dark_mode(self, *_):
|
||||
exec_shell_command(
|
||||
os.path.expanduser("~/fabric/assets/scripts/dark-theme.sh --toggle")
|
||||
)
|
||||
self._update_button_style()
|
||||
|
||||
def check_dark_mode_state(self):
|
||||
result = exec_shell_command(
|
||||
"gsettings get org.gnome.desktop.interface color-scheme"
|
||||
)
|
||||
return result.strip().replace("'", "") == "prefer-dark"
|
||||
|
||||
def _update_button_style(self):
|
||||
dark_mode = self.check_dark_mode_state()
|
||||
style = (
|
||||
"background-color: @surfaceVariant; border-radius:100px; min-height:50px; min-width:50px;"
|
||||
if dark_mode
|
||||
else "background-color: transparent; border-radius:100px;"
|
||||
)
|
||||
self.theme_toggle_button.set_style(style)
|
||||
|
||||
def show_wallpaper_thumbnails(self, viewport, search_term: str = ""):
|
||||
wallpapers = list(self._get_wallpapers(search_term))[:24]
|
||||
if not wallpapers:
|
||||
self._show_no_wallpapers_message(viewport)
|
||||
return
|
||||
|
||||
self._display_thumbnails(viewport, wallpapers)
|
||||
|
||||
def _show_no_wallpapers_message(self, viewport):
|
||||
viewport.add(
|
||||
Box(
|
||||
orientation="h",
|
||||
style="padding:20px;",
|
||||
children=[Button(child="No wallpapers found!", v_align="center")],
|
||||
)
|
||||
)
|
||||
|
||||
def _display_thumbnails(self, viewport, wallpapers):
|
||||
row = Box(orientation="h", spacing=10, style="margin:5px;")
|
||||
|
||||
for index, wallpaper in enumerate(wallpapers, 1):
|
||||
thumbnail_path = self._generate_thumbnail(wallpaper)
|
||||
row.add(self._create_wallpaper_thumbnail(thumbnail_path, wallpaper))
|
||||
|
||||
if index % 6 == 0:
|
||||
viewport.add(row)
|
||||
row = Box(orientation="h", spacing=10, style="margin:5px;")
|
||||
|
||||
if row.children:
|
||||
viewport.add(row)
|
||||
|
||||
def _get_wallpapers(self, search_term: str):
|
||||
return (
|
||||
f
|
||||
for f in self.wallpaper_dir.iterdir()
|
||||
if f.is_file()
|
||||
and f.suffix.lower() in self.IMAGE_EXTENSIONS
|
||||
and self._matches_search(f, search_term)
|
||||
)
|
||||
|
||||
def _matches_search(self, file, search_term: str):
|
||||
return not search_term or search_term.lower() in file.name.lower()
|
||||
|
||||
def _generate_thumbnail(self, wallpaper_path):
|
||||
thumbnail_path = self.thumbnail_dir / wallpaper_path.name
|
||||
if not thumbnail_path.exists():
|
||||
threading.Thread(
|
||||
target=self._create_thumbnail,
|
||||
args=(wallpaper_path, thumbnail_path),
|
||||
daemon=True,
|
||||
).start()
|
||||
return thumbnail_path
|
||||
|
||||
def _create_thumbnail(self, wallpaper_path, thumbnail_path):
|
||||
logger.debug(f"Generating thumbnail for {wallpaper_path}")
|
||||
exec_shell_command_async(
|
||||
[
|
||||
"magick",
|
||||
str(wallpaper_path),
|
||||
"-resize",
|
||||
self.THUMBNAIL_SIZE,
|
||||
"-gravity",
|
||||
"Center",
|
||||
"-extent",
|
||||
self.THUMBNAIL_ASPECT_RATIO,
|
||||
str(thumbnail_path),
|
||||
],
|
||||
lambda *args: logger.debug(args),
|
||||
)
|
||||
|
||||
def _create_wallpaper_thumbnail(self, thumbnail_path, wallpaper_path):
|
||||
return Button(
|
||||
child=Box(
|
||||
orientation="h",
|
||||
h_align="center",
|
||||
v_align="center",
|
||||
style=self._thumbnail_style(thumbnail_path),
|
||||
),
|
||||
h_align="start",
|
||||
v_align="center",
|
||||
name="wall-item",
|
||||
on_clicked=lambda _: self._select_wallpaper(wallpaper_path),
|
||||
)
|
||||
|
||||
def _thumbnail_style(self, thumbnail_path):
|
||||
return (
|
||||
f"background-image: url('{thumbnail_path}'); "
|
||||
"min-width: 64px; min-height: 64px; "
|
||||
"background-repeat: no-repeat; "
|
||||
"background-size: cover; background-position: center;"
|
||||
)
|
||||
|
||||
def _select_wallpaper(self, wallpaper_path):
|
||||
self._apply_wallpaper(wallpaper_path)
|
||||
|
||||
def _apply_wallpaper(self, wallpaper_path):
|
||||
self._execute_wallpaper_script("--image", str(wallpaper_path))
|
||||
|
||||
def apply_wallpaper_random(self):
|
||||
self._execute_wallpaper_script("-R")
|
||||
|
||||
def _execute_wallpaper_script(self, *args):
|
||||
try:
|
||||
exec_shell_command_async(
|
||||
["python3", self.WALLPAPER_SCRIPT_PATH, *args],
|
||||
lambda output: logger.info(f"Wallpaper script output: {output}"),
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error executing wallpaper script: {e}")
|
||||
|
||||
def get_wallpaper_buttons(self):
|
||||
return self.theme_toggle_button
|
||||
@@ -2,8 +2,6 @@ import gi
|
||||
|
||||
gi.require_version("GdkPixbuf", "2.0")
|
||||
|
||||
from gi.repository import GdkPixbuf, GLib
|
||||
|
||||
from fabric.notifications import (
|
||||
Notification,
|
||||
NotificationAction,
|
||||
@@ -17,6 +15,7 @@ from fabric.widgets.image import Image
|
||||
from fabric.widgets.label import Label
|
||||
from fabric.widgets.revealer import Revealer
|
||||
from fabric.widgets.wayland import WaylandWindow as Window
|
||||
from gi.repository import GdkPixbuf
|
||||
from snippets import CustomImage
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
from .brightness import Brightness
|
||||
from .screen_record import ScreenRecorder
|
||||
from .wifi import NetworkClient, Wifi
|
||||
|
||||
__all__ = [
|
||||
"Brightness",
|
||||
"ScreenRecorder",
|
||||
"NetworkClient",
|
||||
"Wifi",
|
||||
]
|
||||
from .brightness import *
|
||||
from .screen_record import *
|
||||
from .wifi import *
|
||||
@@ -11,11 +11,22 @@ class ScreenRecorder(Service):
|
||||
@Signal
|
||||
def recording(self, value: bool) -> None: ...
|
||||
|
||||
_instance = None
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
if hasattr(self, "_initialized") and self._initialized:
|
||||
return
|
||||
self.screenshot_path = GLib.get_home_dir() + "/Pictures/Screenshots/"
|
||||
self.screenrecord_path = GLib.get_home_dir() + "/Videos/Screencasting/"
|
||||
self._current_screencast_path = None
|
||||
|
||||
super().__init__(**kwargs)
|
||||
self._initialized = True
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if not cls._instance:
|
||||
cls._instance = super(ScreenRecorder, cls).__new__(cls, *args, **kwargs)
|
||||
return cls._instance
|
||||
|
||||
def screenshot(self, fullscreen=False, save_copy=True):
|
||||
time = datetime.datetime.today().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
@@ -44,18 +55,27 @@ class ScreenRecorder(Service):
|
||||
time = datetime.datetime.today().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
file_path = self.screenrecord_path + str(time) + ".mp4"
|
||||
self._current_screencast_path = file_path
|
||||
area = ""
|
||||
if fullscreen:
|
||||
f"-g '{exec_shell_command('slurp')}'"
|
||||
area = "" if fullscreen else f"-g '{exec_shell_command('slurp')}'"
|
||||
command = f"wf-recorder --file={file_path} --pixel-format yuv420p {area}"
|
||||
exec_shell_command_async(command)
|
||||
self.emit("recording", True)
|
||||
|
||||
def screencast_stop(self):
|
||||
if not self.is_recording:
|
||||
logger.error("[SCREENRECORD] No active recording to stop")
|
||||
return
|
||||
exec_shell_command_async("killall -INT wf-recorder")
|
||||
self.emit("recording", False)
|
||||
self.send_screencast_notification(self._current_screencast_path)
|
||||
|
||||
# def screencast_stop(self):
|
||||
# exec_shell_command_async("killall -INT wf-recorder")
|
||||
# self.emit("recording", False)
|
||||
# if hasattr(self, "_current_screencast_path") and self._current_screencast_path:
|
||||
# self.send_screencast_notification(self._current_screencast_path)
|
||||
# else:
|
||||
# logger.error("[SCREENRECORD] No active screencast to stop")
|
||||
#
|
||||
def send_screencast_notification(self, file_path):
|
||||
# TODO: Generate a thumbnail
|
||||
# exec_shell_command_async(f"totem-video-thumbnailer {file_path} {FABRIC_CACHE}")
|
||||
|
||||
@@ -1,21 +1,5 @@
|
||||
from .animator import Animator
|
||||
from .custom_image import CustomImage
|
||||
from .functions import (
|
||||
get_current_uptime,
|
||||
get_profile_picture_path,
|
||||
read_config,
|
||||
username,
|
||||
)
|
||||
from .icon import MaterialIcon
|
||||
from .icon_resolver import IconResolver
|
||||
|
||||
__all__ = [
|
||||
"Animator",
|
||||
"MaterialIcon",
|
||||
"read_config",
|
||||
"get_profile_picture_path",
|
||||
"username",
|
||||
"IconResolver",
|
||||
"get_current_uptime",
|
||||
"CustomImage",
|
||||
]
|
||||
from .animator import *
|
||||
from .custom_image import *
|
||||
from .functions import *
|
||||
from .icon import *
|
||||
from .icon_resolver import *
|
||||
@@ -0,0 +1,313 @@
|
||||
from typing import Literal
|
||||
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.eventbox import EventBox
|
||||
from fabric.widgets.revealer import Revealer
|
||||
from fabric.widgets.wayland import WaylandWindow
|
||||
from fabric.widgets.widget import Widget
|
||||
from gi.repository import GLib
|
||||
|
||||
|
||||
class Padding(EventBox):
|
||||
def __init__(self, name: str | None = None, style: str = "", **kwargs):
|
||||
super().__init__(
|
||||
name=name,
|
||||
h_expand=True,
|
||||
v_expand=True,
|
||||
child=Box(style=style, h_expand=True, v_expand=True),
|
||||
events=["button-press"],
|
||||
**kwargs,
|
||||
)
|
||||
self.set_can_focus(False)
|
||||
|
||||
|
||||
class PopupRevealer(Box):
|
||||
def __init__(
|
||||
self,
|
||||
popup_window: WaylandWindow,
|
||||
decorations: str = "padding: 1px;",
|
||||
name: str | None = None,
|
||||
child: Widget | None = None,
|
||||
transition_type: Literal[
|
||||
"none",
|
||||
"crossfade",
|
||||
"slide-right",
|
||||
"slide-left",
|
||||
"slide-up",
|
||||
"slide-down",
|
||||
] = "slide-down",
|
||||
transition_duration: int = 400,
|
||||
):
|
||||
self.revealer: Revealer = Revealer(
|
||||
name=name,
|
||||
child=child,
|
||||
transition_type=transition_type,
|
||||
transition_duration=transition_duration,
|
||||
notify_child_revealed=lambda revealer, _: (
|
||||
[
|
||||
revealer.hide(),
|
||||
popup_window.set_visible(False),
|
||||
]
|
||||
if not revealer.fully_revealed
|
||||
else None
|
||||
),
|
||||
notify_reveal_child=lambda revealer, _: (
|
||||
[
|
||||
popup_window.set_visible(True),
|
||||
]
|
||||
if revealer.child_revealed
|
||||
else None
|
||||
),
|
||||
)
|
||||
super().__init__(
|
||||
style=decorations,
|
||||
children=self.revealer,
|
||||
)
|
||||
|
||||
|
||||
def make_layout(anchor: str, name: str, popup: PopupRevealer, **kwargs) -> Box:
|
||||
match anchor:
|
||||
case "center-left":
|
||||
return Box(
|
||||
children=[
|
||||
Box(
|
||||
orientation="vertical",
|
||||
children=[
|
||||
Padding(name=name, **kwargs),
|
||||
popup,
|
||||
Padding(name=name, **kwargs),
|
||||
],
|
||||
),
|
||||
Padding(name=name, **kwargs),
|
||||
]
|
||||
)
|
||||
|
||||
case "center":
|
||||
return Box(
|
||||
children=[
|
||||
Padding(name=name, **kwargs),
|
||||
Box(
|
||||
orientation="vertical",
|
||||
children=[
|
||||
Padding(name=name, **kwargs),
|
||||
popup,
|
||||
Padding(name=name, **kwargs),
|
||||
],
|
||||
),
|
||||
Padding(name=name, **kwargs),
|
||||
]
|
||||
)
|
||||
case "center-right":
|
||||
return Box(
|
||||
children=[
|
||||
Padding(name=name, **kwargs),
|
||||
Box(
|
||||
orientation="vertical",
|
||||
children=[
|
||||
Padding(name=name, **kwargs),
|
||||
popup,
|
||||
Padding(name=name, **kwargs),
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
case "top":
|
||||
return Box(
|
||||
children=[
|
||||
Padding(name=name, **kwargs),
|
||||
Box(
|
||||
orientation="vertical",
|
||||
children=[popup, Padding(name=name, **kwargs)],
|
||||
),
|
||||
Padding(name=name, **kwargs),
|
||||
]
|
||||
)
|
||||
case "top-right":
|
||||
return Box(
|
||||
children=[
|
||||
Padding(name=name, **kwargs),
|
||||
Box(
|
||||
h_expand=False,
|
||||
orientation="vertical",
|
||||
children=[popup, Padding(name=name, **kwargs)],
|
||||
),
|
||||
]
|
||||
)
|
||||
case "top-center":
|
||||
return Box(
|
||||
children=[
|
||||
Padding(name=name, **kwargs),
|
||||
Box(
|
||||
h_expand=False,
|
||||
orientation="vertical",
|
||||
children=[popup, Padding(name=name, **kwargs)],
|
||||
),
|
||||
Padding(name=name, **kwargs),
|
||||
]
|
||||
)
|
||||
case "top-left":
|
||||
return Box(
|
||||
children=[
|
||||
Box(
|
||||
h_expand=False,
|
||||
orientation="vertical",
|
||||
children=[popup, Padding(name=name, **kwargs)],
|
||||
),
|
||||
Padding(name=name, **kwargs),
|
||||
]
|
||||
)
|
||||
case "bottom-left":
|
||||
return Box(
|
||||
children=[
|
||||
Box(
|
||||
h_expand=False,
|
||||
orientation="vertical",
|
||||
children=[Padding(name=name, **kwargs), popup],
|
||||
),
|
||||
Padding(name=name, **kwargs),
|
||||
]
|
||||
)
|
||||
case "bottom-center":
|
||||
return Box(
|
||||
children=[
|
||||
Padding(name=name, **kwargs),
|
||||
Box(
|
||||
h_expand=False,
|
||||
orientation="vertical",
|
||||
children=[Padding(name=name, **kwargs), popup],
|
||||
),
|
||||
Padding(name=name, **kwargs),
|
||||
]
|
||||
)
|
||||
case "bottom-right":
|
||||
return Box(
|
||||
children=[
|
||||
Padding(name=name, **kwargs),
|
||||
Box(
|
||||
h_expand=True,
|
||||
orientation="vertical",
|
||||
children=[Padding(name=name, **kwargs), popup],
|
||||
),
|
||||
]
|
||||
)
|
||||
case _:
|
||||
return None
|
||||
|
||||
|
||||
class PopupWindow(WaylandWindow):
|
||||
def __init__(
|
||||
self,
|
||||
name: str = "popup-window",
|
||||
decorations: str = "padding: 1px;",
|
||||
child: Widget | None = None,
|
||||
transition_type: (
|
||||
Literal[
|
||||
"none",
|
||||
"crossfade",
|
||||
"slide-right",
|
||||
"slide-left",
|
||||
"slide-up",
|
||||
"slide-down",
|
||||
]
|
||||
| None
|
||||
) = None,
|
||||
transition_duration: int = 100,
|
||||
popup_visible: bool = False,
|
||||
anchor: Literal[
|
||||
"center-left",
|
||||
"center",
|
||||
"center-right",
|
||||
"top",
|
||||
"top-right",
|
||||
"top-center",
|
||||
"top-left",
|
||||
"bottom-left",
|
||||
"bottom-center",
|
||||
"bottom-right",
|
||||
] = "top-right",
|
||||
enable_inhibitor: bool = False,
|
||||
keyboard_mode: Literal["none", "exclusive", "on-demand"] = "on-demand",
|
||||
timeout: int = 1000,
|
||||
**kwargs,
|
||||
):
|
||||
self.timeout = timeout
|
||||
self.currtimeout = 0
|
||||
self.popup_running = False
|
||||
|
||||
self.popup_visible = popup_visible
|
||||
|
||||
self.enable_inhibitor = enable_inhibitor
|
||||
|
||||
self.monitor_number: int | None = None
|
||||
|
||||
self.reveal_child = PopupRevealer(
|
||||
name=name,
|
||||
popup_window=self,
|
||||
child=child,
|
||||
transition_type=transition_type,
|
||||
transition_duration=transition_duration,
|
||||
decorations=decorations,
|
||||
)
|
||||
|
||||
super().__init__(
|
||||
layer="top",
|
||||
keyboard_mode=keyboard_mode,
|
||||
visible=False,
|
||||
exclusivity="normal",
|
||||
anchor="top bottom right left",
|
||||
child=make_layout(
|
||||
anchor=anchor,
|
||||
name=name,
|
||||
popup=self.reveal_child,
|
||||
on_button_press_event=self.on_inhibit_click,
|
||||
),
|
||||
on_key_release_event=self.on_key_release,
|
||||
)
|
||||
|
||||
def on_key_release(self, _, event_key):
|
||||
if event_key.get_keycode()[1] == 9:
|
||||
self.popup_visible = False
|
||||
self.reveal_child.revealer.set_reveal_child(self.popup_visible)
|
||||
|
||||
def on_inhibit_click(self, *_):
|
||||
self.popup_visible = False
|
||||
self.reveal_child.revealer.set_reveal_child(self.popup_visible)
|
||||
|
||||
def toggle_popup(self, monitor: bool = False):
|
||||
if monitor:
|
||||
curr_monitor = self.hyprland_monitor.get_current_gdk_monitor_id()
|
||||
self.monitor = curr_monitor
|
||||
if self.monitor_number != curr_monitor and self.popup_visible:
|
||||
self.monitor_number = curr_monitor
|
||||
return
|
||||
|
||||
self.monitor_number = curr_monitor
|
||||
|
||||
if not self.popup_visible:
|
||||
self.reveal_child.revealer.show()
|
||||
|
||||
self.popup_visible = not self.popup_visible
|
||||
self.reveal_child.revealer.set_reveal_child(self.popup_visible)
|
||||
|
||||
def popup_timeout(self):
|
||||
|
||||
if not self.popup_visible:
|
||||
self.reveal_child.revealer.show()
|
||||
if self.popup_running:
|
||||
self.currtimeout = 0
|
||||
return
|
||||
self.popup_visible = True
|
||||
self.reveal_child.revealer.set_reveal_child(self.popup_visible)
|
||||
self.popup_running = True
|
||||
|
||||
def popup_func():
|
||||
if self.currtimeout >= self.timeout:
|
||||
self.popup_visible = False
|
||||
self.reveal_child.revealer.set_reveal_child(self.popup_visible)
|
||||
self.currtimeout = 0
|
||||
self.popup_running = False
|
||||
return False
|
||||
self.currtimeout += 500
|
||||
return True
|
||||
|
||||
GLib.timeout_add(500, popup_func)
|
||||
@@ -0,0 +1,8 @@
|
||||
#big {
|
||||
font-weight: 500;
|
||||
font-size: 18px;
|
||||
}
|
||||
#small {
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
}
|
||||
@@ -7,6 +7,10 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#corner {
|
||||
background-color: @surface;
|
||||
}
|
||||
|
||||
/*
|
||||
* ── bar moudles ───────────────────────────────────────────────────────
|
||||
*/
|
||||
@@ -71,33 +75,23 @@
|
||||
}
|
||||
|
||||
/*
|
||||
* ── tray ──────────────────────────────────────────────────────────────
|
||||
* ─── info ──────────────────────────────────────────────────────────────
|
||||
*/
|
||||
|
||||
#tray {
|
||||
#info {
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 100px;
|
||||
padding: 2px 10px 0px 10px;
|
||||
}
|
||||
|
||||
#tray > button {
|
||||
#info > button {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
menu {
|
||||
background-color: @surfaceContainer;
|
||||
}
|
||||
|
||||
menu > menuitem {
|
||||
border-radius: 12px;
|
||||
padding: 10px;
|
||||
margin-left: 2px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
menu > menuitem:hover {
|
||||
background-color: mix(@onSurface, @surface, 0.85);
|
||||
#info .progress {
|
||||
color: lighter(@outlineVariant);
|
||||
border: 2px solid @onSecondaryContainer;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -151,7 +145,43 @@ menu > menuitem:hover {
|
||||
margin-right: 0px;
|
||||
}
|
||||
|
||||
#progress {
|
||||
color: lighter(@outlineVariant);
|
||||
border: 2px solid @onSecondaryContainer;
|
||||
/* systemtray */
|
||||
|
||||
#system-tray {
|
||||
padding: 0.125em 0.25em;
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 100px;
|
||||
}
|
||||
|
||||
#system-tray > button {
|
||||
margin: 0 0.1em;
|
||||
padding: 0 0.15em;
|
||||
border-radius: 100px;
|
||||
}
|
||||
|
||||
#system-tray-menu > menuitem menu,
|
||||
#system-tray-menu {
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 1em;
|
||||
padding: 10px;
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
#system-tray-menu > menuitem menu > menuitem,
|
||||
#system-tray-menu > menuitem {
|
||||
margin: 5px 0px;
|
||||
background-color: @surfaceContainer;
|
||||
padding: 0.3em 0.5em;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#system-tray-menu > menuitem menu > menuitem:disabled,
|
||||
#system-tray-menu > menuitem:disabled {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#system-tray-menu > menuitem menu > menuitem:hover,
|
||||
#system-tray-menu > menuitem:hover,
|
||||
#submenu-button:hover {
|
||||
background-color: @surface;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@import url(../../.cache/material/colors.css);
|
||||
@import url(../../../.cache/material/colors.css);
|
||||
@import "launcher.css";
|
||||
@import "bar.css";
|
||||
@import "notification.css";
|
||||
|
||||
Reference in new issue
Block a user