diff --git a/config/lemonbar/launch.sh b/config/lemonbar/launch.sh deleted file mode 100755 index 42c747e..0000000 --- a/config/lemonbar/launch.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env sh - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" - -ex="$DIR/bar.py" - -# Terminate already running bar instances -ps x | grep "python3 $ex" | grep -v grep | awk '{print $1}' | while read p; do kill $p; done -killall -q lemonbar - -$ex - - diff --git a/config/lemonbar/requirements.txt b/config/lemonbar/requirements.txt deleted file mode 100644 index 33e73b9..0000000 --- a/config/lemonbar/requirements.txt +++ /dev/null @@ -1,13 +0,0 @@ -coloredlogs==10.0 -enum-compat==0.0.2 -humanfriendly==4.16.1 -i3ipc==1.6.0 -ifaddr==0.1.4 -ipaddress==1.0.22 -psutil==5.4.7 -pulsectl>=23.5.2<24 -pyinotify==0.9.6 -python-mpd2>=3.0.0<4 -python-uinput==0.11.2 -yoke==0.1.1 -zeroconf==0.21.3 diff --git a/config/nix/hm/common.nix b/config/nix/hm/common.nix index af0a19e..7269f79 100644 --- a/config/nix/hm/common.nix +++ b/config/nix/hm/common.nix @@ -25,7 +25,7 @@ in commonRc = lib.strings.concatLines ([ '' # Colored ls - # TODO Doesn't allow completion + # TODO Doesn't allow completion. Check out lsd instead _colored_ls() { \ls -lh --color=always $@ | awk ' BEGIN { diff --git a/config/nix/hm/desktop.nix b/config/nix/hm/desktop.nix index 941eab1..6587326 100644 --- a/config/nix/hm/desktop.nix +++ b/config/nix/hm/desktop.nix @@ -496,10 +496,11 @@ simplescreenrecorder trayer xclip - lemonbar-xft keynav xorg.xinit xorg.xbacklight + # TODO Make this clean. Service? + (callPackage (import ./frobar) {}) # FIXME Call it where needed # organisation diff --git a/config/lemonbar/barng.py b/config/nix/hm/frobar/.dev/barng.py similarity index 100% rename from config/lemonbar/barng.py rename to config/nix/hm/frobar/.dev/barng.py diff --git a/config/lemonbar/oldbar.py b/config/nix/hm/frobar/.dev/oldbar.py similarity index 100% rename from config/lemonbar/oldbar.py rename to config/nix/hm/frobar/.dev/oldbar.py diff --git a/config/lemonbar/pip.py b/config/nix/hm/frobar/.dev/pip.py similarity index 100% rename from config/lemonbar/pip.py rename to config/nix/hm/frobar/.dev/pip.py diff --git a/config/lemonbar/x.py b/config/nix/hm/frobar/.dev/x.py similarity index 100% rename from config/lemonbar/x.py rename to config/nix/hm/frobar/.dev/x.py diff --git a/config/nix/hm/frobar/.gitignore b/config/nix/hm/frobar/.gitignore new file mode 100644 index 0000000..be91729 --- /dev/null +++ b/config/nix/hm/frobar/.gitignore @@ -0,0 +1,2 @@ +dist/* +frobar.egg-info/* diff --git a/config/nix/hm/frobar/default.nix b/config/nix/hm/frobar/default.nix new file mode 100644 index 0000000..cf1d7a7 --- /dev/null +++ b/config/nix/hm/frobar/default.nix @@ -0,0 +1,31 @@ +{ pkgs ? import { config = { }; overlays = [ ]; } }: +# Tried using pyproject.nix but mpd2 dependency wouldn't resolve, +# is called pyton-mpd2 on PyPi but mpd2 in nixpkgs. +let + frobar = pkgs.python3Packages.buildPythonApplication { + pname = "frobar"; + version = "2.0"; + + propagatedBuildInputs = with pkgs.python3Packages; [ + coloredlogs + notmuch + i3ipc + mpd2 + psutil + pulsectl + pyinotify + ]; + + src = ./.; + }; + frobar_launcher = pkgs.writeShellApplication + { + name = "frobar_launcher"; + runtimeInputs = with pkgs; [ lemonbar-xft wirelesstools ]; + text = '' + ${pkgs.procps}/bin/pkill /bin/frobar || true + ${frobar}/bin/frobar + ''; + }; +in +frobar_launcher diff --git a/config/lemonbar/bar.py b/config/nix/hm/frobar/frobar/__init__.py old mode 100755 new mode 100644 similarity index 97% rename from config/lemonbar/bar.py rename to config/nix/hm/frobar/frobar/__init__.py index 9854fe7..a54813e --- a/config/lemonbar/bar.py +++ b/config/nix/hm/frobar/frobar/__init__.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 -from providers import * +from frobar.providers import * # TODO If multiple screen, expand the sections and share them # TODO Graceful exit -if __name__ == "__main__": +def run(): Bar.init() Updater.init() diff --git a/config/lemonbar/display.py b/config/nix/hm/frobar/frobar/display.py old mode 100755 new mode 100644 similarity index 99% rename from config/lemonbar/display.py rename to config/nix/hm/frobar/frobar/display.py index a109e01..3a18af7 --- a/config/lemonbar/display.py +++ b/config/nix/hm/frobar/frobar/display.py @@ -1,15 +1,17 @@ #!/usr/bin/env python3 import enum -import threading -import time -import i3ipc +import logging import os import signal import subprocess -import logging +import threading +import time + import coloredlogs -import updaters +import i3ipc + +from frobar.notbusy import notBusy coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s") log = logging.getLogger() @@ -168,7 +170,6 @@ class Bar: @staticmethod def updateAll(): - if Bar.running: Bar.string = "" for bar in Bar.everyone: @@ -295,7 +296,7 @@ class SectionThread(threading.Thread): def run(self): while Section.somethingChanged.wait(): - updaters.notBusy.wait() + notBusy.wait() Section.updateAll() animTime = self.ANIMATION_START frameTime = time.perf_counter() @@ -311,7 +312,6 @@ class SectionThread(threading.Thread): class Section: - # TODO Update all of that to base16 # COLORS = ['#272822', '#383830', '#49483e', '#75715e', '#a59f85', '#f8f8f2', # '#f5f4f1', '#f9f8f5', '#f92672', '#fd971f', '#f4bf75', '#a6e22e', diff --git a/config/nix/hm/frobar/frobar/notbusy.py b/config/nix/hm/frobar/frobar/notbusy.py new file mode 100644 index 0000000..690e304 --- /dev/null +++ b/config/nix/hm/frobar/frobar/notbusy.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 + +import threading + +notBusy = threading.Event() diff --git a/config/lemonbar/providers.py b/config/nix/hm/frobar/frobar/providers.py old mode 100755 new mode 100644 similarity index 99% rename from config/lemonbar/providers.py rename to config/nix/hm/frobar/frobar/providers.py index c65f528..219fd20 --- a/config/lemonbar/providers.py +++ b/config/nix/hm/frobar/frobar/providers.py @@ -1,20 +1,21 @@ #!/usr/bin/env python3 import datetime -from updaters import * -from display import * -import pulsectl -import psutil -import subprocess -import socket import ipaddress -import logging -import coloredlogs import json -import notmuch -import mpd +import logging import random -import math +import socket +import subprocess + +import coloredlogs +import mpd +import notmuch +import psutil +import pulsectl + +from frobar.display import * +from frobar.updaters import * coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s") log = logging.getLogger() @@ -43,7 +44,6 @@ def randomColor(seed=0): class TimeProvider(StatefulSection, PeriodicUpdater): - FORMATS = ["%H:%M", "%m-%d %H:%M:%S", "%a %y-%m-%d %H:%M:%S"] NUMBER_STATES = len(FORMATS) DEFAULT_STATE = 1 @@ -257,7 +257,6 @@ class PulseaudioProvider(StatefulSection, ThreadedUpdater): class NetworkProviderSection(StatefulSection, Updater): - NUMBER_STATES = 5 DEFAULT_STATE = 1 diff --git a/config/lemonbar/updaters.py b/config/nix/hm/frobar/frobar/updaters.py old mode 100755 new mode 100644 similarity index 99% rename from config/lemonbar/updaters.py rename to config/nix/hm/frobar/frobar/updaters.py index d3e5986..06b65f3 --- a/config/lemonbar/updaters.py +++ b/config/nix/hm/frobar/frobar/updaters.py @@ -1,22 +1,24 @@ #!/usr/bin/env python3 -import math import functools -import threading -import pyinotify -import os -import time import logging +import math +import os +import threading +import time + import coloredlogs import i3ipc -from display import Text +import pyinotify + +from frobar.display import Text +from frobar.notbusy import notBusy coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s") log = logging.getLogger() # TODO Sync bar update with PeriodicUpdater updates -notBusy = threading.Event() class Updater: @@ -241,7 +243,6 @@ class I3Updater(ThreadedUpdater): class MergedUpdater(Updater): - # TODO OPTI Do not update until end of periodic batch def fetcher(self): text = Text() diff --git a/config/nix/hm/frobar/setup.py b/config/nix/hm/frobar/setup.py new file mode 100644 index 0000000..275440c --- /dev/null +++ b/config/nix/hm/frobar/setup.py @@ -0,0 +1,20 @@ +from setuptools import setup + +setup( + name="frobar", + version="2.0", + install_requires=[ + "coloredlogs", + "notmuch", + "i3ipc", + "python-mpd2", + "psutil", + "pulsectl", + "pyinotify", + ], + entry_points={ + "console_scripts": [ + "frobar = frobar:run", + ] + }, +)