nix: frobar

Semi-proper Python packaging, and non-conflicting names, yahoo!
This commit is contained in:
Geoffrey Frogeye 2023-11-19 20:51:05 +01:00
parent 0316638e21
commit 47a19d7f82
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
16 changed files with 92 additions and 59 deletions

View file

@ -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

View file

@ -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

View file

@ -25,7 +25,7 @@ in
commonRc = lib.strings.concatLines ([ commonRc = lib.strings.concatLines ([
'' ''
# Colored ls # Colored ls
# TODO Doesn't allow completion # TODO Doesn't allow completion. Check out lsd instead
_colored_ls() { _colored_ls() {
\ls -lh --color=always $@ | awk ' \ls -lh --color=always $@ | awk '
BEGIN { BEGIN {

View file

@ -496,10 +496,11 @@
simplescreenrecorder simplescreenrecorder
trayer trayer
xclip xclip
lemonbar-xft
keynav keynav
xorg.xinit xorg.xinit
xorg.xbacklight xorg.xbacklight
# TODO Make this clean. Service?
(callPackage (import ./frobar) {}) # FIXME Call it where needed
# organisation # organisation

2
config/nix/hm/frobar/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
dist/*
frobar.egg-info/*

View file

@ -0,0 +1,31 @@
{ pkgs ? import <nixpkgs> { 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

View file

@ -1,10 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from providers import * from frobar.providers import *
# TODO If multiple screen, expand the sections and share them # TODO If multiple screen, expand the sections and share them
# TODO Graceful exit # TODO Graceful exit
if __name__ == "__main__": def run():
Bar.init() Bar.init()
Updater.init() Updater.init()

View file

@ -1,15 +1,17 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import enum import enum
import threading import logging
import time
import i3ipc
import os import os
import signal import signal
import subprocess import subprocess
import logging import threading
import time
import coloredlogs import coloredlogs
import updaters import i3ipc
from frobar.notbusy import notBusy
coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s") coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s")
log = logging.getLogger() log = logging.getLogger()
@ -168,7 +170,6 @@ class Bar:
@staticmethod @staticmethod
def updateAll(): def updateAll():
if Bar.running: if Bar.running:
Bar.string = "" Bar.string = ""
for bar in Bar.everyone: for bar in Bar.everyone:
@ -295,7 +296,7 @@ class SectionThread(threading.Thread):
def run(self): def run(self):
while Section.somethingChanged.wait(): while Section.somethingChanged.wait():
updaters.notBusy.wait() notBusy.wait()
Section.updateAll() Section.updateAll()
animTime = self.ANIMATION_START animTime = self.ANIMATION_START
frameTime = time.perf_counter() frameTime = time.perf_counter()
@ -311,7 +312,6 @@ class SectionThread(threading.Thread):
class Section: class Section:
# TODO Update all of that to base16 # TODO Update all of that to base16
# COLORS = ['#272822', '#383830', '#49483e', '#75715e', '#a59f85', '#f8f8f2', # COLORS = ['#272822', '#383830', '#49483e', '#75715e', '#a59f85', '#f8f8f2',
# '#f5f4f1', '#f9f8f5', '#f92672', '#fd971f', '#f4bf75', '#a6e22e', # '#f5f4f1', '#f9f8f5', '#f92672', '#fd971f', '#f4bf75', '#a6e22e',

View file

@ -0,0 +1,5 @@
#!/usr/bin/env python3
import threading
notBusy = threading.Event()

View file

@ -1,20 +1,21 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import datetime import datetime
from updaters import *
from display import *
import pulsectl
import psutil
import subprocess
import socket
import ipaddress import ipaddress
import logging
import coloredlogs
import json import json
import notmuch import logging
import mpd
import random 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") coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s")
log = logging.getLogger() log = logging.getLogger()
@ -43,7 +44,6 @@ def randomColor(seed=0):
class TimeProvider(StatefulSection, PeriodicUpdater): class TimeProvider(StatefulSection, PeriodicUpdater):
FORMATS = ["%H:%M", "%m-%d %H:%M:%S", "%a %y-%m-%d %H:%M:%S"] FORMATS = ["%H:%M", "%m-%d %H:%M:%S", "%a %y-%m-%d %H:%M:%S"]
NUMBER_STATES = len(FORMATS) NUMBER_STATES = len(FORMATS)
DEFAULT_STATE = 1 DEFAULT_STATE = 1
@ -257,7 +257,6 @@ class PulseaudioProvider(StatefulSection, ThreadedUpdater):
class NetworkProviderSection(StatefulSection, Updater): class NetworkProviderSection(StatefulSection, Updater):
NUMBER_STATES = 5 NUMBER_STATES = 5
DEFAULT_STATE = 1 DEFAULT_STATE = 1

View file

@ -1,22 +1,24 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import math
import functools import functools
import threading
import pyinotify
import os
import time
import logging import logging
import math
import os
import threading
import time
import coloredlogs import coloredlogs
import i3ipc 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") coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s")
log = logging.getLogger() log = logging.getLogger()
# TODO Sync bar update with PeriodicUpdater updates # TODO Sync bar update with PeriodicUpdater updates
notBusy = threading.Event()
class Updater: class Updater:
@ -241,7 +243,6 @@ class I3Updater(ThreadedUpdater):
class MergedUpdater(Updater): class MergedUpdater(Updater):
# TODO OPTI Do not update until end of periodic batch # TODO OPTI Do not update until end of periodic batch
def fetcher(self): def fetcher(self):
text = Text() text = Text()

View file

@ -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",
]
},
)