121 lines
3.6 KiB
Python
121 lines
3.6 KiB
Python
from fabric.hyprland.widgets import Language
|
|
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
|
|
from fabric.widgets.centerbox import CenterBox
|
|
from fabric.widgets.datetime import DateTime
|
|
from fabric.widgets.wayland import WaylandWindow as Window
|
|
from modules.bar.widgets import (
|
|
BatteryLabel,
|
|
BluetoothIndicator,
|
|
IdleIndicator,
|
|
MicrophoneIndicator,
|
|
NetworkIndicator,
|
|
PowerProfileIndicator,
|
|
SystemInfo,
|
|
TaskBar,
|
|
VolumeIndicator,
|
|
workspace,
|
|
Recorder,
|
|
)
|
|
from services import ScreenRecorder
|
|
from snippets import MaterialIcon
|
|
|
|
|
|
class Bar(Window):
|
|
def __init__(self):
|
|
super().__init__(
|
|
layer="top",
|
|
anchor="left bottom right",
|
|
exclusivity="auto",
|
|
visible=False,
|
|
all_visible=False,
|
|
)
|
|
self.screen_recorder = ScreenRecorder()
|
|
self.workspaces = Button(child=workspace, name="workspaces")
|
|
self.language = Language(
|
|
formatter=FormattedString(
|
|
"{replace_lang(language)}",
|
|
replace_lang=lambda lang: bulk_replace(
|
|
lang,
|
|
(r".*Eng.*", r".*Nep.*"),
|
|
("en", "np"),
|
|
regex=True,
|
|
),
|
|
),
|
|
)
|
|
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.taskbar = TaskBar()
|
|
self.info = SystemInfo()
|
|
self.powerindicator = PowerProfileIndicator()
|
|
self.tray = SystemTray(name="tray", icon_size=16, spacing=4)
|
|
self.recorder = Recorder()
|
|
|
|
self.applets = Box(
|
|
name="applets",
|
|
spacing=4,
|
|
orientation="h",
|
|
children=[
|
|
self.language,
|
|
self.powerindicator,
|
|
self.bluetooth,
|
|
self.network,
|
|
self.volume,
|
|
self.microphone,
|
|
self.idle,
|
|
],
|
|
)
|
|
|
|
self.children = CenterBox(
|
|
name="bar",
|
|
start_children=Box(
|
|
name="start-container",
|
|
spacing=8,
|
|
orientation="h",
|
|
children=[
|
|
self.workspaces,
|
|
self.info,
|
|
],
|
|
),
|
|
center_children=Box(
|
|
name="center-container",
|
|
spacing=8,
|
|
orientation="h",
|
|
children=self.taskbar,
|
|
),
|
|
end_children=Box(
|
|
name="end-container",
|
|
spacing=8,
|
|
orientation="h",
|
|
children=[
|
|
self.recorder,
|
|
self.tray,
|
|
self.battery,
|
|
self.applets,
|
|
self.date_time,
|
|
],
|
|
),
|
|
)
|
|
|
|
self.show_all()
|