feat: uses sigusr to clear/update display
This commit is contained in:
parent
9b32ba17d4
commit
092dc8d71e
2 changed files with 64 additions and 7 deletions
66
README.md
66
README.md
|
|
@ -1,14 +1,66 @@
|
|||
CLI bard — See all your last notifications in the terminal
|
||||
==========================================================
|
||||
|
||||
The CLI bard is a very simple command line application that displays the last
|
||||
D-Bus notifications in a single line of the terminal.
|
||||
The *CLI bard* is a very simple command line application that displays the last
|
||||
notifications received on the D-Bus (the common notification system under Linux).
|
||||
|
||||
It is not an interactive application, it just displays a single line, and
|
||||
overwrites it when a new notification comes.
|
||||
It is not an interactive application, it just displays incoming notifications.
|
||||
At any time, as much as possible of the last notifications are displayed.
|
||||
The display refreshes when a notification is added at the end of the line.
|
||||
The display refreshes when a notification is received.
|
||||
|
||||
CLI bard is written in Python and is available under the AGPLv3 license.
|
||||
The CLI bard is written in Python and is available under the AGPLv3 license.
|
||||
|
||||
|
||||
Install
|
||||
=======
|
||||
|
||||
The CLI bard relies on your terminal using a font patched with the "Powerline"
|
||||
characters. The recommended fonts are the ones from the
|
||||
[Nerd font project](https://www.nerdfonts.com/).
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Command arguments
|
||||
-----------------
|
||||
|
||||
> usage: clibard.py [-h] [-l {h,v,horizontal,vertical}] [--test NB_ITEMS] [--send NB_ITEMS]
|
||||
> options:
|
||||
> -h, --help show this help message and exit
|
||||
> -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
|
||||
> printing new notifications on new lines.
|
||||
|
||||
|
||||
Signaling
|
||||
---------
|
||||
|
||||
The CLI bard does respond to POSIX "user signals".
|
||||
Signals can be issued with the `kill` command, using the `--signal` flag along
|
||||
with 10 (SIGUSR1) or 12 (SIGUSR2) as an argument.
|
||||
SIGUSR1 will refresh the display, SIGUSR2 will erase any notification in the
|
||||
cache and clear the display (if it can).
|
||||
|
||||
Note that with the horizontal layout, refreshing the display actually changes
|
||||
the display. Erasing the cache will remove any on-screen notification.
|
||||
With the vertical layout, this does nothing on the display.
|
||||
|
||||
|
||||
Layouts
|
||||
=======
|
||||
|
||||
The default layout is the horizontal one.
|
||||
This will display on a single line, and overwrite it as soon as an update is
|
||||
received.
|
||||
When refreshing its display in the horizontal layout, the displayed dates will
|
||||
be refreshed as well.
|
||||
However, it does not show all the cached notifications, but only the few last
|
||||
ones that can fit the current width of the terminal.
|
||||
|
||||
The vertical layout simply prints a new line as soon as the CLI bard receive
|
||||
a notification. The display cannot be cleared nor refreshed.
|
||||
Most notably, the dates of notifications will all be "now".
|
||||
However, the terminal does display all the received notifications, if you can
|
||||
scroll back enough.
|
||||
|
||||
To run it, just run the `clibard.py` script in a wide-enough terminal.
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ class Broker:
|
|||
self.deck = collections.deque()
|
||||
|
||||
signal.signal(signal.SIGUSR1, self.sigusr1)
|
||||
signal.signal(signal.SIGUSR2, self.sigusr2)
|
||||
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
|
||||
|
|
@ -259,6 +260,10 @@ class Broker:
|
|||
|
||||
|
||||
def sigusr1(self, signum, stack):
|
||||
self.print()
|
||||
|
||||
|
||||
def sigusr2(self, signum, stack):
|
||||
self.deck.clear()
|
||||
self.print()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue