huge updates but idk what i update

This commit is contained in:
sankalp committed 2025-02-28 16:44:38 +05:45
1 parent 5d88e059d9
commit 4350f7459e
19 files changed
+563 -617

No files matched your search

+134 -50
View File
@@ -1,3 +1,4 @@
from typing import Literal
from fabric.hyprland.widgets import Language
from fabric.system_tray.widgets import SystemTray
from fabric.utils import (
@@ -5,24 +6,76 @@ from fabric.utils import (
bulk_replace,
exec_shell_command_async,
get_relative_path,
bulk_connect,
)
from fabric.widgets.shapes import Corner
from fabric.widgets.box import Box
from fabric.widgets.button import Button
from fabric.widgets.centerbox import CenterBox
from fabric.widgets.datetime import DateTime
from fabric.widgets.label import Label
from fabric.widgets.revealer import Revealer
from fabric.widgets.wayland import WaylandWindow as Window
from gi.repository import GLib
from modules.bar.components import (
BatteryLabel,
SystemInfo,
TaskBar,
Battery,
Metrics,
workspace,
Indicators,
SystemIndicators,
UpdatesWidget,
)
from services import sc
import snippets.iconss as icons
import utils.icons as icons
class StatusBarCorner(Box):
def __init__(self, corner: Literal["top-right", "top-left"]):
super().__init__(
style="margin-bottom: 15px;",
name="bar-corner",
children=Corner(
orientation=corner,
size=15,
),
)
class Tray(Box):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.tray = Box(
name="left-tray",
children=[SystemTray(name="tray", icon_size=16, spacing=4)],
)
self.profile = Button(
child=Label(name="tray-revealer", markup=icons.chevron_left)
)
self.revealer = Revealer(transition_type="slide-left", transition_duration=1000)
self.revealer.add(self.tray)
bulk_connect(
self.profile,
{
"enter-notify-event": self._on_enter,
"leave-notify-event": self._on_leave,
"button-press-event": self.toggle_revealer,
},
)
self.add(self.profile)
self.add(self.revealer)
def _on_enter(self, *args):
self.profile.set_cursor("pointer")
def _on_leave(self, *args):
self.profile.set_cursor("default")
def toggle_revealer(self, *args):
new_state = not self.revealer.get_reveal_child()
self.revealer.set_reveal_child(new_state)
new_icon = icons.chevron_right if new_state else icons.chevron_left
self.profile.get_child().set_markup(new_icon)
class Bar(Window):
@@ -39,7 +92,7 @@ class Bar(Window):
),
),
)
self.bar_content = CenterBox(name="center-bar")
self.recording_indicator = Button(
name="recording-indicator",
child=Label(name="recorder", markup=icons.record),
@@ -47,16 +100,10 @@ class Bar(Window):
on_clicked=lambda *_: sc.screencast_stop(),
)
sc.connect(
"recording", lambda _, status: self.on_recording_status_change(status)
)
sc.connect("recording", self.on_recording_status_change)
self.date_time = DateTime(formatters=["%-I:%M 󰧞 %a %d %b"], name="datetime")
self.battery = BatteryLabel()
self.taskbar = TaskBar()
self.stats = SystemInfo()
self.tray = SystemTray(name="tray", icon_size=16, spacing=4)
self.battery = Battery()
self.launcher = Button(
name="logo",
child=Label(name="logo-name", label="󰣇 󰫿󰫰󰫵"),
@@ -64,8 +111,6 @@ class Bar(Window):
"fabric-cli exec modus 'launcher.open(\"launcher\")'"
),
)
self.updates = UpdatesWidget()
self.indicators = Indicators()
self.button_config = Button(
name="button-bar",
on_clicked=lambda *_: exec_shell_command_async(
@@ -73,35 +118,22 @@ class Bar(Window):
),
child=Label(name="button-bar-label", markup=icons.config),
)
self.stats = Metrics()
self.updates = UpdatesWidget()
self.tray = Tray()
self.indicators = SystemIndicators()
self.applets = Box(
name="applets",
name="system-indicators",
spacing=4,
orientation="h",
children=[
self.language,
self.indicators,
],
children=[self.language, self.indicators],
)
self.bar = CenterBox(
name="bar",
start_children=Box(
name="start-container",
spacing=8,
orientation="h",
children=[self.launcher, self.workspaces, self.stats, self.updates],
),
center_children=Box(
name="center-container",
spacing=8,
orientation="h",
children=self.taskbar,
),
end_children=Box(
name="end-container",
spacing=8,
orientation="h",
self.bar_content.end_children = [
StatusBarCorner("top-right"),
Box(
name="bar",
spacing=4,
children=[
self.recording_indicator,
self.tray,
@@ -110,27 +142,79 @@ class Bar(Window):
self.date_time,
self.button_config,
],
style_classes="end-container",
),
)
]
self.bar_content.start_children = [
Box(
name="bar",
spacing=4,
children=[self.launcher, self.workspaces, self.stats, self.updates],
style_classes="start-container",
),
StatusBarCorner("top-left"),
]
super().__init__(
layer="top",
anchor="left bottom right",
anchor="left top right",
exclusivity="auto",
visible=True,
child=self.bar,
child=self.bar_content,
)
self.hidden = False
def on_recording_status_change(self, status):
print(f"Recording status changed: {status}")
def on_recording_status_change(self, _, status):
self.recording_indicator.set_visible(status)
def toggle_hidden(self):
self.hidden = not self.hidden
if self.hidden:
self.bar.remove_style_class("visible")
self.bar.add_style_class("hidden")
self.bar_content.add_style_class("hidden")
self.bar_content.remove_style_class("visible")
self.set_property("visible", False)
else:
self.bar.remove_style_class("hidden")
self.bar.add_style_class("visible")
self.bar_content.add_style_class("visible")
self.bar_content.remove_style_class("hidden")
self.set_property("visible", True)
class ScreenCorners(Window):
def __init__(self):
super().__init__(
layer="top",
anchor="top left bottom right",
pass_through=True,
child=Box(
orientation="vertical",
children=[
Box(
children=[
self.make_corner("top-left"),
Box(h_expand=True),
self.make_corner("top-right"),
]
),
Box(v_expand=True),
Box(
children=[
self.make_corner("bottom-left"),
Box(h_expand=True),
self.make_corner("bottom-right"),
]
),
],
),
)
def make_corner(self, orientation) -> Box:
return Box(
h_expand=False,
v_expand=False,
name="bar-corner",
children=Corner(
orientation=orientation,
size=15,
),
)