Skip to content

system_notifier

fdev31 edited this page Apr 5, 2024 · 8 revisions

This plugin adds system notifications based on journal logs (or any program's output). It monitors specified sources for log entries matching predefined patterns and generates notifications accordingly (after applying an optional filter).

By default a "journal" parser is provided, defined as follows (may change over time, provided as an example):

[[system_notifier.parsers.journal]]
pattern = "([a-z0-9]+): Link UP$"
filter = "s/.*\[\d+\]: ([a-z0-9]+): Link.*/\1 is active/"
color= "#00aa00"

[[system_notifier.parsers.journal]]
pattern = "([a-z0-9]+): Link DOWN$"
filter = "s/.*\[\d+\]: ([a-z0-9]+): Link.*/\1 is inactive/"
color= "#ff8800"

[[system_notifier.parsers.journal]]
pattern = "Process \d+ \(.*\) of .* dumped core."
filter = "s/.*Process \d+ \((.*)\) of .* dumped core./\1 dumped core/"
color= "#aa0000"

[[system_notifier.parsers.journal]]
pattern = "usb \d+-[0-9.]+: Product: "
filter = "s/.*usb \d+-[0-9.]+: Product: (.*)/USB plugged: \1/"

you can use it by adding one source:

[[system_notifier.sources]]
command = "sudo journalctl -fx"
parser = "journal"

Note

Added in version 2.2.0

Configuration

sources

List of sources to enable (by default nothing is enabled)

Each source must contain a command to run and a parser to use. You can also use a list of parsers, eg:

[[system_notifier.sources]]
command = "sudo journalctl -fkn"
parser = ["journal", "custom_parser"]

parsers

A list of available parsers that can be used to detect lines of interest in the sources and re-format it before issuing a notification.

Each parser definition must contain a pattern and optionally a filter, eg:

[[system_notifier.parsers.custom_parser]]

pattern = 'special value:'

The pattern is any regular expression.

The filters allows to change the text before the notification, eg: filter='s/.*special value: (\d+)/Value=\1/' will set a filter so a string "special value: 42" will lead to the notification "Value=42"

You can also provide an optional color in "hex" or "rgb()" format

color = "#FF5500"

default_color (optional)

Sets the notification color that will be used when none is provided in a parser definition.

[system_notifier]
default_color = "#bbccbb"

Clone this wiki locally