feat(vertical): display date in ISO
Update doc.
This commit is contained in:
parent
4849ee9120
commit
f9ce1ef3d5
2 changed files with 43 additions and 11 deletions
48
README.md
48
README.md
|
|
@ -25,12 +25,36 @@ Usage
|
||||||
Command arguments
|
Command arguments
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
> usage: clibard.py [-h] [-l {h,v,horizontal,vertical}] [--test NB_ITEMS] [--send NB_ITEMS]
|
> usage: clibard.py [-h] [-l {h,v,horizontal,vertical}] [--test NB_ITEMS]
|
||||||
|
> [--send NB_ITEMS]
|
||||||
|
>
|
||||||
> options:
|
> options:
|
||||||
> -h, --help show this help message and exit
|
> -h, --help show this help message and exit
|
||||||
> -l {h,v,horizontal,vertical}, --layout {h,v,horizontal,vertical}
|
> -l {h,v,horizontal,vertical}, --layout {h,v,horizontal,vertical}
|
||||||
> How to display notifications. `horizontal` = as many of the last notifications that fit on a single line, clear out the old ones. `vertical` = keep
|
> How to display notifications. `horizontal` = as many of
|
||||||
> printing new notifications on new lines.
|
> the last notifications that fit on a single line, clear
|
||||||
|
> out the old ones. `vertical` = keep printing new
|
||||||
|
> notifications on new lines.
|
||||||
|
> --test NB_ITEMS Print NB_ITEMS fake notifications and quit.
|
||||||
|
> --send NB_ITEMS Send NB_ITEMS fake notifications on the D-Bus and quit.
|
||||||
|
|
||||||
|
|
||||||
|
Display
|
||||||
|
-------
|
||||||
|
|
||||||
|
Each notification is displayed as a colored block made of up to four segments,
|
||||||
|
showing in order:
|
||||||
|
1. the *date*,
|
||||||
|
2. the *application* having issued the notification,
|
||||||
|
3. the *summary* of the notification (e.g. chat systems usually display the user, here),
|
||||||
|
4. the *body* of the message.
|
||||||
|
|
||||||
|
The color of the notification block's application and summary depends
|
||||||
|
on the *urgency* of the notification:
|
||||||
|
- *low* in green,
|
||||||
|
- *normal* in blue,
|
||||||
|
- *critical* in orange,
|
||||||
|
- *unknown* in light purple.
|
||||||
|
|
||||||
|
|
||||||
Signaling
|
Signaling
|
||||||
|
|
@ -43,7 +67,8 @@ SIGUSR1 will refresh the display, SIGUSR2 will erase any notification in the
|
||||||
cache and clear the display (if it can).
|
cache and clear the display (if it can).
|
||||||
|
|
||||||
Note that with the horizontal layout, refreshing the display actually changes
|
Note that with the horizontal layout, refreshing the display actually changes
|
||||||
the display. Erasing the cache will remove any on-screen notification.
|
the display. Erasing the cache will remove any on-screen notification
|
||||||
|
if you use the horizontal layout.
|
||||||
With the vertical layout, this does nothing on the display.
|
With the vertical layout, this does nothing on the display.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -51,16 +76,25 @@ Layouts
|
||||||
=======
|
=======
|
||||||
|
|
||||||
The default layout is the horizontal one.
|
The default layout is the horizontal one.
|
||||||
|
|
||||||
|
Horizontal
|
||||||
|
----------
|
||||||
|
|
||||||
This will display on a single line, and overwrite it as soon as an update is
|
This will display on a single line, and overwrite it as soon as an update is
|
||||||
received.
|
received.
|
||||||
|
Dates are given in a "natural" human-readable way.
|
||||||
When refreshing its display in the horizontal layout, the displayed dates will
|
When refreshing its display in the horizontal layout, the displayed dates will
|
||||||
be refreshed as well.
|
be refreshed as well.
|
||||||
However, it does not show all the cached notifications, but only the few last
|
However, it does not show all the cached notifications, but only the few last
|
||||||
ones that can fit the current width of the terminal.
|
ones that can fit the current width of the terminal.
|
||||||
|
|
||||||
|
|
||||||
|
Vertical
|
||||||
|
--------
|
||||||
|
|
||||||
The vertical layout simply prints a new line as soon as the CLI bard receive
|
The vertical layout simply prints a new line as soon as the CLI bard receive
|
||||||
a notification. The display cannot be cleared nor refreshed.
|
a notification. The display cannot be cleared nor refreshed.
|
||||||
Most notably, the dates of notifications will all be "now".
|
Most notably, date is displayed in the ISO-8601 format, down to the minute.
|
||||||
However, the terminal does display all the received notifications, if you can
|
However, your terminal should retain all the received notifications,
|
||||||
scroll back enough.
|
if you can scroll back enough.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,6 @@ class MessageLine(Message):
|
||||||
body = " ".join(self.body.split())
|
body = " ".join(self.body.split())
|
||||||
self.print_segment("body", body, console)
|
self.print_segment("body", body, console)
|
||||||
self.print_segment("none", "", console)
|
self.print_segment("none", "", console)
|
||||||
console.print("", end="\n")
|
|
||||||
console.print(end, end="")
|
console.print(end, end="")
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -220,10 +219,9 @@ class MessageLine(Message):
|
||||||
|
|
||||||
class MessageParagraph(Message):
|
class MessageParagraph(Message):
|
||||||
def print_on(self, console = None, end = ""):
|
def print_on(self, console = None, end = ""):
|
||||||
hdate = humanize.naturaltime(self.date)
|
hdate = self.date.strftime("%Y-%m-%d %H:%M")
|
||||||
if console != None:
|
if console != None:
|
||||||
# console.print(" ", end="")
|
self.print_segment("date", hdate, console)
|
||||||
# self.print_segment("date", hdate, console)
|
|
||||||
self.print_segment(self.urgency, self.app, console, prefix = "bold")
|
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(f"summary_{self.urgency}", self.summary, console, prefix = "bold")
|
||||||
self.print_segment("none", "", console)
|
self.print_segment("none", "", console)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue