feat: nixos dbus availability
This commit is contained in:
57
bar/main.py
57
bar/main.py
@@ -1,5 +1,3 @@
|
||||
# fabric bar.py example
|
||||
# https://github.com/Fabric-Development/fabric/blob/rewrite/examples/bar/bar.py
|
||||
from loguru import logger
|
||||
|
||||
from fabric import Application
|
||||
@@ -12,39 +10,44 @@ from fabric.utils import (
|
||||
get_relative_path,
|
||||
)
|
||||
from .modules.bar import StatusBar
|
||||
from .modules.window_fuzzy import FuzzyWindowFinder
|
||||
|
||||
|
||||
tray = SystemTray(name="system-tray", spacing=4)
|
||||
river = get_river_connection()
|
||||
|
||||
dummy = Window(visible=False)
|
||||
finder = FuzzyWindowFinder()
|
||||
|
||||
bar_windows = []
|
||||
|
||||
app = Application("bar", dummy, finder)
|
||||
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
||||
|
||||
|
||||
def spawn_bars():
|
||||
logger.info("[Bar] Spawning bars after river ready")
|
||||
outputs = river.outputs
|
||||
|
||||
if not outputs:
|
||||
logger.warning("[Bar] No outputs found — skipping bar spawn")
|
||||
return
|
||||
|
||||
output_ids = sorted(outputs.keys())
|
||||
|
||||
for i, output_id in enumerate(output_ids):
|
||||
bar = StatusBar(display=output_id, tray=tray if i == 0 else None, monitor=i)
|
||||
bar_windows.append(bar)
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
tray = SystemTray(name="system-tray", spacing=4)
|
||||
river = get_river_connection()
|
||||
|
||||
dummy = Window(visible=False)
|
||||
|
||||
bar_windows = []
|
||||
|
||||
def spawn_bars():
|
||||
logger.info("[Bar] Spawning bars after river ready")
|
||||
outputs = river.outputs
|
||||
|
||||
if not outputs:
|
||||
logger.warning("[Bar] No outputs found — skipping bar spawn")
|
||||
return
|
||||
|
||||
output_ids = sorted(outputs.keys())
|
||||
|
||||
for i, output_id in enumerate(output_ids):
|
||||
bar = StatusBar(display=output_id, tray=tray if i == 0 else None, monitor=i)
|
||||
bar_windows.append(bar)
|
||||
|
||||
return False
|
||||
|
||||
if river.ready:
|
||||
spawn_bars()
|
||||
else:
|
||||
river.connect("notify::ready", lambda sender, pspec: spawn_bars())
|
||||
|
||||
app = Application("bar", dummy)
|
||||
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
||||
app.run()
|
||||
|
||||
|
||||
|
||||
24
bar/modules/window_fuzzy.py
Normal file
24
bar/modules/window_fuzzy.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from fabric.widgets.wayland import WaylandWindow as Window
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.label import Label
|
||||
|
||||
|
||||
class FuzzyWindowFinder(Window):
|
||||
def __init__(
|
||||
self,
|
||||
monitor: int = 1,
|
||||
):
|
||||
super().__init__(
|
||||
name="finder",
|
||||
layer="overlay",
|
||||
anchor="center",
|
||||
margin="0px 0px -2px 0px",
|
||||
exclusivity="auto",
|
||||
visible=False,
|
||||
all_visible=False,
|
||||
monitor=monitor,
|
||||
)
|
||||
|
||||
self.children = Box(
|
||||
name="list-windows", children=[Label(name="one-window", markup="Hallo lol")]
|
||||
)
|
||||
Reference in New Issue
Block a user