feat: changing layout changes theme
This commit is contained in:
parent
092dc8d71e
commit
4849ee9120
2 changed files with 46 additions and 7 deletions
15
pyproject.toml
Normal file
15
pyproject.toml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[tool.poetry]
|
||||
name = "clibard"
|
||||
version = "0.1.0"
|
||||
description = "See all your notifications in the terminal"
|
||||
authors = ["nojhan <nojhan@nojhan.net>"]
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
faker = "^0.7.4"
|
||||
humanize = "^4.11"
|
||||
rich = "^13.9"
|
||||
dbus-python = "^1.3"
|
||||
PyGObject = "^3.50" # You may need to install the system package for libgirepository1.0-dev
|
||||
|
||||
|
|
@ -201,6 +201,7 @@ class Message:
|
|||
self.last_color = f"{self.style(key)}"
|
||||
|
||||
|
||||
class MessageLine(Message):
|
||||
def print_on(self, console = None, end = ""):
|
||||
hdate = humanize.naturaltime(self.date)
|
||||
if console != None:
|
||||
|
|
@ -208,18 +209,41 @@ class Message:
|
|||
self.print_segment("date", hdate, console)
|
||||
self.print_segment(self.urgency, self.app, console, prefix = "bold")
|
||||
self.print_segment(f"summary_{self.urgency}", self.summary, console, prefix = "bold")
|
||||
self.print_segment("body", self.body, console)
|
||||
body = " ".join(self.body.split())
|
||||
self.print_segment("body", body, console)
|
||||
self.print_segment("none", "", console)
|
||||
console.print("", end="\n")
|
||||
console.print(end, end="")
|
||||
|
||||
return len(hdate) + len(self.app) + len(self.summary) + len(self.body) + 6
|
||||
|
||||
|
||||
class MessageParagraph(Message):
|
||||
def print_on(self, console = None, end = ""):
|
||||
hdate = humanize.naturaltime(self.date)
|
||||
if console != None:
|
||||
# console.print(" ", end="")
|
||||
# self.print_segment("date", hdate, console)
|
||||
self.print_segment(self.urgency, self.app, console, prefix = "bold")
|
||||
self.print_segment(f"summary_{self.urgency}", self.summary, console, prefix = "bold")
|
||||
self.print_segment("none", "", console)
|
||||
console.print("\n", end="")
|
||||
body = " ".join(self.body.split())
|
||||
self.print_segment("body", body, console)
|
||||
self.print_segment("none", "", console)
|
||||
console.print("", end="\n")
|
||||
console.print(end, end="")
|
||||
|
||||
return len(hdate) + len(self.app) + len(self.summary) + len(self.body) + 6
|
||||
|
||||
|
||||
|
||||
class Broker:
|
||||
def __init__(self, max_msg = 100, bounds = ""):
|
||||
def __init__(self, max_msg = 100, bounds = "", msg_cls = Message):
|
||||
|
||||
self.max_msg = max_msg
|
||||
self.bounds = bounds
|
||||
self.msg_cls = msg_cls
|
||||
|
||||
self.deck = collections.deque()
|
||||
|
||||
|
|
@ -245,7 +269,7 @@ class Broker:
|
|||
# print("Interface:", notification.get_interface(), flush = True)
|
||||
|
||||
if notification.get_member() == "Notify" and notification.get_interface() == 'org.freedesktop.Notifications':
|
||||
msg = Message(notification)
|
||||
msg = self.msg_cls(notification)
|
||||
mlen = msg.print_on(None)
|
||||
if len(self.deck) == 0:
|
||||
self.deck.append( (msg, mlen) )
|
||||
|
|
@ -274,8 +298,8 @@ class Broker:
|
|||
|
||||
class HorizontalBroker(Broker):
|
||||
|
||||
def __init__(self, max_msg = 100, bounds = ""):
|
||||
super().__init__(max_msg, bounds)
|
||||
def __init__(self, max_msg = 100, bounds = "", msg_cls = MessageLine):
|
||||
super().__init__(max_msg, bounds, msg_cls)
|
||||
|
||||
|
||||
def width(self, deck):
|
||||
|
|
@ -315,8 +339,8 @@ class HorizontalBroker(Broker):
|
|||
|
||||
class VerticalBroker(Broker):
|
||||
|
||||
def __init__(self, max_msg = 100, bounds = ""):
|
||||
super().__init__(max_msg, bounds)
|
||||
def __init__(self, max_msg = 100, bounds = "", msg_cls = MessageParagraph):
|
||||
super().__init__(max_msg, bounds, msg_cls)
|
||||
|
||||
|
||||
def print(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue