feat: nixos dbus availability
This commit is contained in:
parent
e4744bab81
commit
82b0cf7aaa
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")]
|
||||
)
|
||||
@ -49,6 +49,20 @@ python3Packages.buildPythonApplication {
|
||||
doCheck = false;
|
||||
dontWrapGApps = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/${python3Packages.python.sitePackages}
|
||||
cp -r bar $out/${python3Packages.python.sitePackages}/
|
||||
|
||||
# If you have any scripts to install
|
||||
mkdir -p $out/bin
|
||||
cp scripts/launcher.py $out/bin/bar
|
||||
chmod +x $out/bin/bar
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
|
||||
'';
|
||||
|
||||
@ -14,14 +14,11 @@ description = "Fabric using Nix example."
|
||||
readme = "README.md"
|
||||
license = {file = "LICENSE"}
|
||||
|
||||
[project.scripts]
|
||||
bar = "bar.main:main"
|
||||
|
||||
[tool.setuptools]
|
||||
include-package-data = true
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["."]
|
||||
[tool.setuptools.packages]
|
||||
find = { namespaces = true }
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
"*" = ["*.css", "styles"]
|
||||
|
||||
21
scripts/launcher.py
Normal file
21
scripts/launcher.py
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
site_packages_dir = os.path.join(
|
||||
script_dir,
|
||||
os.pardir,
|
||||
"lib",
|
||||
f"python{sys.version_info.major}.{sys.version_info.minor}",
|
||||
"site-packages",
|
||||
)
|
||||
|
||||
if site_packages_dir not in sys.path:
|
||||
sys.path.insert(0, site_packages_dir)
|
||||
|
||||
|
||||
from bar.main import *
|
||||
|
||||
sys.argv[0] = os.path.join(script_dir, os.path.basename(__file__))
|
||||
sys.exit(main())
|
||||
Loading…
x
Reference in New Issue
Block a user