feat: nixos dbus availability
This commit is contained in:
parent
e4744bab81
commit
82b0cf7aaa
23
bar/main.py
23
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 loguru import logger
|
||||||
|
|
||||||
from fabric import Application
|
from fabric import Application
|
||||||
@ -12,17 +10,22 @@ from fabric.utils import (
|
|||||||
get_relative_path,
|
get_relative_path,
|
||||||
)
|
)
|
||||||
from .modules.bar import StatusBar
|
from .modules.bar import StatusBar
|
||||||
|
from .modules.window_fuzzy import FuzzyWindowFinder
|
||||||
|
|
||||||
|
|
||||||
def main():
|
tray = SystemTray(name="system-tray", spacing=4)
|
||||||
tray = SystemTray(name="system-tray", spacing=4)
|
river = get_river_connection()
|
||||||
river = get_river_connection()
|
|
||||||
|
|
||||||
dummy = Window(visible=False)
|
dummy = Window(visible=False)
|
||||||
|
finder = FuzzyWindowFinder()
|
||||||
|
|
||||||
bar_windows = []
|
bar_windows = []
|
||||||
|
|
||||||
def spawn_bars():
|
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")
|
logger.info("[Bar] Spawning bars after river ready")
|
||||||
outputs = river.outputs
|
outputs = river.outputs
|
||||||
|
|
||||||
@ -38,13 +41,13 @@ def main():
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
if river.ready:
|
if river.ready:
|
||||||
spawn_bars()
|
spawn_bars()
|
||||||
else:
|
else:
|
||||||
river.connect("notify::ready", lambda sender, pspec: spawn_bars())
|
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()
|
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;
|
doCheck = false;
|
||||||
dontWrapGApps = true;
|
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 = ''
|
preFixup = ''
|
||||||
makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
|
makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
|
||||||
'';
|
'';
|
||||||
|
|||||||
@ -14,14 +14,11 @@ description = "Fabric using Nix example."
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = {file = "LICENSE"}
|
license = {file = "LICENSE"}
|
||||||
|
|
||||||
[project.scripts]
|
|
||||||
bar = "bar.main:main"
|
|
||||||
|
|
||||||
[tool.setuptools]
|
[tool.setuptools]
|
||||||
include-package-data = true
|
include-package-data = true
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages]
|
||||||
where = ["."]
|
find = { namespaces = true }
|
||||||
|
|
||||||
[tool.setuptools.package-data]
|
[tool.setuptools.package-data]
|
||||||
"*" = ["*.css", "styles"]
|
"*" = ["*.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