fix
This commit is contained in:
1 parent
505705c432
commit
e44421b2d6
4 files changed
+49
-132
No files matched your search
@@ -1,5 +1,6 @@
|
||||
from fabric.hyprland.widgets import Language
|
||||
from fabric.system_tray.widgets import SystemTray
|
||||
|
||||
# from fabric.system_tray.widgets import SystemTray
|
||||
from fabric.utils import FormattedString, bulk_replace
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
@@ -8,23 +9,21 @@ from fabric.widgets.datetime import DateTime
|
||||
from fabric.widgets.wayland import WaylandWindow as Window
|
||||
from modules.bar.widgets import (
|
||||
BatteryLabel,
|
||||
BluetoothIndicator,
|
||||
Bluetooth,
|
||||
IdleIndicator,
|
||||
MicrophoneIndicator,
|
||||
NetworkIndicator,
|
||||
PowerProfileIndicator,
|
||||
Network,
|
||||
SystemInfo,
|
||||
SystemTray,
|
||||
TaskBar,
|
||||
VolumeIndicator,
|
||||
workspace,
|
||||
)
|
||||
from services import ScreenRecorder
|
||||
from snippets import MaterialIcon
|
||||
|
||||
|
||||
class Bar(Window):
|
||||
def __init__(self):
|
||||
def __init__(
|
||||
self,
|
||||
):
|
||||
super().__init__(
|
||||
layer="top",
|
||||
anchor="left bottom right",
|
||||
@@ -32,8 +31,6 @@ class Bar(Window):
|
||||
visible=False,
|
||||
all_visible=False,
|
||||
)
|
||||
self.screen_recorder = ScreenRecorder()
|
||||
self.workspaces = Button(child=workspace, name="workspaces")
|
||||
self.language = Language(
|
||||
formatter=FormattedString(
|
||||
"{replace_lang(language)}",
|
||||
@@ -45,38 +42,23 @@ class Bar(Window):
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
self.date_time = DateTime(formatters=["%-I:%M %a %d %b"], name="datetime")
|
||||
|
||||
self.recording_indicator = Button(
|
||||
name="bar-button",
|
||||
child=MaterialIcon("screen_record", size=16),
|
||||
visible=False,
|
||||
on_clicked=lambda *_: self.screen_recorder.screencast_stop(),
|
||||
)
|
||||
|
||||
self.screen_recorder.connect(
|
||||
"recording",
|
||||
lambda _, status: self.recording_indicator.set_visible(status),
|
||||
)
|
||||
|
||||
self.battery = BatteryLabel(name="battery")
|
||||
self.volume = VolumeIndicator()
|
||||
self.bluetooth = BluetoothIndicator()
|
||||
self.network = NetworkIndicator()
|
||||
self.microphone = MicrophoneIndicator()
|
||||
self.idle = IdleIndicator()
|
||||
# self.system_tray = SystemTray(name="tray", spacing=4, icon_size=18)
|
||||
self.taskbar = TaskBar()
|
||||
self.volume = VolumeIndicator()
|
||||
self.network = Network()
|
||||
self.bluetooth = Bluetooth()
|
||||
self.battery = BatteryLabel(name="battery")
|
||||
self.microphone = MicrophoneIndicator()
|
||||
self.workspaces = Button(child=workspace, name="workspaces")
|
||||
self.info = SystemInfo()
|
||||
self.powerindicator = PowerProfileIndicator()
|
||||
self.tray = SystemTray()
|
||||
|
||||
self.idle = IdleIndicator()
|
||||
self.applets = Box(
|
||||
name="applets",
|
||||
spacing=4,
|
||||
orientation="h",
|
||||
children=[
|
||||
self.language,
|
||||
self.powerindicator,
|
||||
self.bluetooth,
|
||||
self.network,
|
||||
self.volume,
|
||||
@@ -100,15 +82,16 @@ class Bar(Window):
|
||||
name="center-container",
|
||||
spacing=8,
|
||||
orientation="h",
|
||||
children=self.taskbar,
|
||||
children=[
|
||||
self.taskbar,
|
||||
],
|
||||
),
|
||||
end_children=Box(
|
||||
name="end-container",
|
||||
spacing=8,
|
||||
orientation="h",
|
||||
children=[
|
||||
# self.recording_indicator,
|
||||
self.tray,
|
||||
# self.system_tray,
|
||||
self.battery,
|
||||
self.applets,
|
||||
self.date_time,
|
||||
|
||||
@@ -6,6 +6,5 @@ from .microphone import *
|
||||
from .network import *
|
||||
from .powerprofile import *
|
||||
from .taskbar import *
|
||||
from .tray import *
|
||||
from .volume import *
|
||||
from .workspace import *
|
||||
@@ -1,76 +0,0 @@
|
||||
import gi
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.image import Image
|
||||
from gi.repository import Gdk, GdkPixbuf, Gray, Gtk
|
||||
from loguru import logger
|
||||
|
||||
gi.require_version("Gray", "0.1")
|
||||
gi.require_version("Gtk", "3.0")
|
||||
|
||||
|
||||
class SystemTray(Box):
|
||||
def __init__(self, pixel_size: int = 16, **kwargs) -> None:
|
||||
super().__init__(name="system-tray", **kwargs)
|
||||
self.pixel_size = pixel_size
|
||||
self.watcher = Gray.Watcher()
|
||||
self.watcher.connect("item-added", self.on_item_added)
|
||||
|
||||
def on_item_added(self, _, identifier: str):
|
||||
item = self.watcher.get_item_for_identifier(identifier)
|
||||
item_button = self.do_bake_item_button(item)
|
||||
item.connect("removed", lambda *args: item_button.destroy())
|
||||
item.connect(
|
||||
"icon-changed",
|
||||
lambda icon_item: self.do_update_item_button(icon_item, item_button),
|
||||
)
|
||||
item_button.show_all()
|
||||
self.add(item_button)
|
||||
|
||||
def do_bake_item_button(self, item: Gray.Item) -> Button:
|
||||
button = Button()
|
||||
# context menu handler
|
||||
button.connect(
|
||||
"button-press-event",
|
||||
lambda button, event: self.on_button_click(button, item, event),
|
||||
)
|
||||
self.do_update_item_button(item, button)
|
||||
|
||||
return button
|
||||
|
||||
def do_update_item_button(self, item: Gray.Item, item_button: Button):
|
||||
pixmap = Gray.get_pixmap_for_pixmaps(item.get_icon_pixmaps(), 24)
|
||||
|
||||
# convert the pixmap to a pixbuf
|
||||
pixbuf: GdkPixbuf.Pixbuf = (
|
||||
pixmap.as_pixbuf(self.config["icon_size"], GdkPixbuf.InterpType.HYPER)
|
||||
if pixmap is not None
|
||||
else Gtk.IconTheme()
|
||||
.get_default()
|
||||
.load_icon(
|
||||
item.get_icon_name(),
|
||||
self.pixel_size,
|
||||
Gtk.IconLookupFlags.FORCE_SIZE,
|
||||
)
|
||||
)
|
||||
item_button.set_image(Image(pixbuf=pixbuf, pixel_size=self.pixel_size))
|
||||
|
||||
def on_button_click(self, button, item: Gray.Item, event):
|
||||
match event.button:
|
||||
case 1:
|
||||
try:
|
||||
item.activate(event.x, event.y)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
case 3:
|
||||
menu = item.get_property("menu")
|
||||
menu.set_name("system-tray-menu")
|
||||
if menu:
|
||||
menu.popup_at_widget(
|
||||
button,
|
||||
Gdk.Gravity.SOUTH,
|
||||
Gdk.Gravity.NORTH,
|
||||
event,
|
||||
)
|
||||
else:
|
||||
item.context_menu(event.x, event.y)
|
||||
@@ -7,10 +7,6 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#corner {
|
||||
background-color: @surface;
|
||||
}
|
||||
|
||||
/*
|
||||
* ── bar moudles ───────────────────────────────────────────────────────
|
||||
*/
|
||||
@@ -75,23 +71,33 @@
|
||||
}
|
||||
|
||||
/*
|
||||
* ─── info ──────────────────────────────────────────────────────────────
|
||||
* ── tray ──────────────────────────────────────────────────────────────
|
||||
*/
|
||||
|
||||
#info {
|
||||
#tray {
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 100px;
|
||||
padding: 2px 10px 0px 10px;
|
||||
}
|
||||
|
||||
#info > button {
|
||||
#tray > button {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#info .progress {
|
||||
color: lighter(@outlineVariant);
|
||||
border: 2px solid @onSecondaryContainer;
|
||||
menu {
|
||||
background-color: @surfaceContainer;
|
||||
}
|
||||
|
||||
menu > menuitem {
|
||||
border-radius: 12px;
|
||||
padding: 10px;
|
||||
margin-left: 2px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
menu > menuitem:hover {
|
||||
background-color: mix(@onSurface, @surface, 0.85);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -145,26 +151,31 @@
|
||||
margin-right: 0px;
|
||||
}
|
||||
|
||||
/* systemtray */
|
||||
#progress {
|
||||
color: lighter(@outlineVariant);
|
||||
border: 2px solid @onSecondaryContainer;
|
||||
}
|
||||
|
||||
/*
|
||||
* ── system tray ───────────────────────────────────────────────────────
|
||||
*/
|
||||
|
||||
#system-tray {
|
||||
padding: 0.125em 0.25em;
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 100px;
|
||||
padding: 2px 10px 0 10px;
|
||||
}
|
||||
|
||||
#system-tray > button {
|
||||
margin: 0 0.1em;
|
||||
padding: 0 0.15em;
|
||||
border-radius: 100px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#system-tray-menu > menuitem menu,
|
||||
#system-tray-menu {
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 1em;
|
||||
border-radius: 12px;
|
||||
padding: 10px;
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
#system-tray-menu > menuitem menu > menuitem,
|
||||
@@ -183,5 +194,5 @@
|
||||
#system-tray-menu > menuitem menu > menuitem:hover,
|
||||
#system-tray-menu > menuitem:hover,
|
||||
#submenu-button:hover {
|
||||
background-color: @surface;
|
||||
background-color: mix(@onSurface, @surface, 0.85);
|
||||
}
|
||||
Reference in new issue
Block a user