Compare commits
No commits in common. "main" and "v1.0.0-rc.1" have entirely different histories.
main
...
v1.0.0-rc.
3 changed files with 15 additions and 89 deletions
|
|
@ -20,8 +20,6 @@ The CLI bard relies on your terminal using a font patched with the "Powerline"
|
||||||
characters. The recommended fonts are the ones from the
|
characters. The recommended fonts are the ones from the
|
||||||
[Nerd font project](https://www.nerdfonts.com/).
|
[Nerd font project](https://www.nerdfonts.com/).
|
||||||
|
|
||||||
You may also need to install the `libgirepository-2.0-dev` on your system.
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,15 @@
|
||||||
[project]
|
[tool.poetry]
|
||||||
name = "clibard"
|
name = "clibard"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "See all your notifications in the terminal"
|
description = "See all your notifications in the terminal"
|
||||||
authors = [
|
authors = ["nojhan <nojhan@nojhan.net>"]
|
||||||
{ name = "nojhan", email = "nojhan@nojhan.net" },
|
|
||||||
]
|
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
requires-python = ">3.11"
|
[tool.poetry.dependencies]
|
||||||
dependencies = [
|
python = "^3.11"
|
||||||
"faker>=0.7.4",
|
faker = "^0.7.4"
|
||||||
"humanize>=4.11",
|
humanize = "^4.11"
|
||||||
"rich>=13.9",
|
rich = "^13.9"
|
||||||
"dbus-python>=1.3",
|
dbus-python = "^1.3"
|
||||||
"PyGObject>=3.50", # You may need to install the system package for libgirepository-2.0-dev
|
PyGObject = "^3.50" # You may need to install the system package for libgirepository1.0-dev
|
||||||
]
|
|
||||||
|
|
||||||
[project.scripts]
|
|
||||||
clibard = "clibard.clibard:main"
|
|
||||||
|
|
||||||
|
|
||||||
[build-system]
|
|
||||||
requires = ["setuptools>=68", "wheel"]
|
|
||||||
build-backend = "setuptools.build_meta"
|
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
|
||||||
where = ["src"]
|
|
||||||
include = ["clibard"]
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,9 @@
|
||||||
import copy
|
import copy
|
||||||
import signal
|
import signal
|
||||||
import datetime
|
import datetime
|
||||||
import humanize
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
import rich
|
import humanize
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
|
|
@ -150,14 +149,6 @@ class Message:
|
||||||
"body": 242,
|
"body": 242,
|
||||||
}
|
}
|
||||||
|
|
||||||
# 🚨🚩🚧🛎 🛈 🏲 🏴📌📳🗨 🗩 🗬 🗭 🗮 🗯 🧭⚠⚲✎ <20> ❓❔︖🯄
|
|
||||||
self.icons = {
|
|
||||||
"low": "🛈 ",
|
|
||||||
"normal": "🗨 ",
|
|
||||||
"critical": "🚨",
|
|
||||||
"unknown": "🯄 ",
|
|
||||||
}
|
|
||||||
|
|
||||||
self._style = {}
|
self._style = {}
|
||||||
for k in self.color:
|
for k in self.color:
|
||||||
self._style[k] = f"color({self.color[k]})"
|
self._style[k] = f"color({self.color[k]})"
|
||||||
|
|
@ -209,19 +200,6 @@ class Message:
|
||||||
|
|
||||||
self.last_color = f"{self.style(key)}"
|
self.last_color = f"{self.style(key)}"
|
||||||
|
|
||||||
def auto_fg(self, bg):
|
|
||||||
# Automated black or white foreground.
|
|
||||||
if Color.ansi_lightness(bg) >= 50:
|
|
||||||
return "black"
|
|
||||||
else:
|
|
||||||
return "white"
|
|
||||||
|
|
||||||
def hash_color(self, text, colors = None):
|
|
||||||
if not colors:
|
|
||||||
return hash(text) % 256
|
|
||||||
else:
|
|
||||||
return colors[hash(text) % len(colors)]
|
|
||||||
|
|
||||||
|
|
||||||
class MessageLine(Message):
|
class MessageLine(Message):
|
||||||
def print_on(self, console = None, end = ""):
|
def print_on(self, console = None, end = ""):
|
||||||
|
|
@ -257,37 +235,6 @@ class MessageParagraph(Message):
|
||||||
return len(hdate) + len(self.app) + len(self.summary) + len(self.body) + 6
|
return len(hdate) + len(self.app) + len(self.summary) + len(self.body) + 6
|
||||||
|
|
||||||
|
|
||||||
class MessageBox(Message):
|
|
||||||
def print_on(self, console = None, end = ""):
|
|
||||||
hdate = self.date.strftime("%Y-%m-%d %H:%M")
|
|
||||||
if console != None:
|
|
||||||
# summ_color = f"{self.auto_fg(FIXME)} on color({self.color[self.urgency]})"
|
|
||||||
body_color = f"color({self.color['summary_'+self.urgency]})"
|
|
||||||
|
|
||||||
bg = self.hash_color(self.summary)
|
|
||||||
sfg = f"{self.auto_fg(bg)} on color({bg})"
|
|
||||||
sfgi = f"color({bg})"
|
|
||||||
summ = f"─[{sfgi}][/][{sfg}]{self.summary}[/][{sfgi}][/]─"
|
|
||||||
|
|
||||||
title = f"{self.icons[self.urgency]} {summ} {self.app}"
|
|
||||||
# title = f"[{summ_color}]{self.summary}[/]─ {self.app}"
|
|
||||||
|
|
||||||
bs = self.hash_color(self.app)
|
|
||||||
|
|
||||||
box = rich.panel.Panel(
|
|
||||||
f"[{body_color}]{self.body}[/]",
|
|
||||||
title=title,
|
|
||||||
title_align="left",
|
|
||||||
# subtitle = self.icons[self.urgency],
|
|
||||||
# subtitle_align = "left",
|
|
||||||
border_style=f"color({bs})",
|
|
||||||
safe_box = False,
|
|
||||||
)
|
|
||||||
console.print(box)
|
|
||||||
|
|
||||||
return len(hdate) + len(self.app) + len(self.summary) + len(self.body) + 6
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Broker:
|
class Broker:
|
||||||
def __init__(self, max_msg = 100, bounds = "", msg_cls = Message):
|
def __init__(self, max_msg = 100, bounds = "", msg_cls = Message):
|
||||||
|
|
@ -414,7 +361,7 @@ def test_messages(nb = 7):
|
||||||
return notifs
|
return notifs
|
||||||
|
|
||||||
|
|
||||||
def main():
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
@ -435,8 +382,8 @@ def main():
|
||||||
if asked.layout[0] == "h":
|
if asked.layout[0] == "h":
|
||||||
broker = HorizontalBroker(bounds = "><")
|
broker = HorizontalBroker(bounds = "><")
|
||||||
elif asked.layout[0] == "v":
|
elif asked.layout[0] == "v":
|
||||||
broker = VerticalBroker(bounds = "><", msg_cls=MessageBox)
|
broker = VerticalBroker(bounds = "><")
|
||||||
notifs = test_messages(int(asked.test))
|
notifs = test_messages(int(sys.argv[2]))
|
||||||
for notif in notifs:
|
for notif in notifs:
|
||||||
broker.receive(None, notif)
|
broker.receive(None, notif)
|
||||||
print("\n", end="")
|
print("\n", end="")
|
||||||
|
|
@ -444,7 +391,7 @@ def main():
|
||||||
elif asked.send:
|
elif asked.send:
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
notifs = test_messages(int(asked.send))
|
notifs = test_messages(int(sys.argv[2]))
|
||||||
for notif in notifs:
|
for notif in notifs:
|
||||||
m = Message(notif)
|
m = Message(notif)
|
||||||
os.system(f"""notify-send "{m.summary}" "{m.body}" -u {m.urgency}""")
|
os.system(f"""notify-send "{m.summary}" "{m.body}" -u {m.urgency}""")
|
||||||
|
|
@ -455,9 +402,5 @@ def main():
|
||||||
broker.run()
|
broker.run()
|
||||||
|
|
||||||
elif asked.layout[0] == "v":
|
elif asked.layout[0] == "v":
|
||||||
broker = VerticalBroker(msg_cls=MessageBox)
|
broker = VerticalBroker()
|
||||||
broker.run()
|
broker.run()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue