Skip to content

axelkar/journald-desktop-notifier

Repository files navigation

journald-desktop-notifier

System journal error notifier

Configuration

Configuration can be written in either TOML or JSON. JSON support has been included to enable writing configuration automatically. Specify matches and their edge cases. Make sure to include a PRIORITY match in your configuration. View the possible fields using journalctl -b0 -o verbose.

[[match]]
# 0 = emerg, 1 = alert, 2 = critical, 3 = error
PRIORITY = "^0|1|2|3$"

# It's fully recursive
[[match]]
SYSLOG_IDENTIFIER = "^foo$"
MESSAGE = "^bar"
[[match.allow]]
MESSAGE = "^bar spam"
[[match.allow.deny]]
_SYSTEMD_UNIT = "^but-actually.service$"

The example above translates to the following boolean condition:

PRIORITY ~= "^0|1|2|3$"
|| (
    SYSLOG_IDENTIFIER ~= "^foo$"
    && MESSAGE ~= "^bar"
    && !(
        MESSAGE ~= "^bar spam"
        && !(_SYSTEMD_UNIT ~= "^but-actually.service$")
    )
)

Home Manager module

This project provides a Home Manager module. To use it, write something like the following into your configuration.

{ ... }:
{
  imports = [ inputs.journald-desktop-notifier.homeModules.default ];
  services.journald-desktop-notifier = {
    enable = true;
    settings.match = [{
      PRIORITY = "^0|1|2|3$";
      allow = [{
        SYSLOG_IDENTIFIER = "^systemd-coredump$";
        MESSAGE = "user 30001"; # nixbld1
      }];
    }];
  };
}

NixOS module

This project also provides a NixOS module, providing similar functionality and configuration options. Note that it defines user units. Here's an example:

{ ... }:
{
  imports = [ inputs.journald-desktop-notifier.nixosModules.default ];
  services.journald-desktop-notifier = {
    enable = true;
    settings.match = [{
      PRIORITY = "^0|1|2|3$";
      allow = [{
        SYSLOG_IDENTIFIER = "^systemd-coredump$";
        MESSAGE = "user 30001"; # nixbld1
      }];
    }];
  };
}

Development

  1. Have Linux

  2. Install Nix

  3. Run the command nix develop in a shell.

    This creates a bash subshell with all the dependencies.

  4. Run cargo commands as you like.

    i.e. cargo build, cargo run, cargo clippy, etc.

Contributing

Please first make sure that you have not introduced any regressions and format the code by running the following commands at the repository root.

cargo fmt
cargo clippy
cargo test

Make a GitHub pull request.

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

System journal error notifier

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published