Awesome Open Source
Awesome Open Source

[[https://github.com/phuhl/linux_notification_center/workflows/CI/badge.svg?branch=master]]

  • Linux Notification Center

A haskell-written notification center for users that like a desktop with style...

** Features

The notification center receives notifications via DBUS (like any notification daemon) and shows them in the upper right corner of the screen. The notification (if not specified in the notification otherwise) will also be shown in the notification center even after the notification disappeared by itself. The notifications can be clicked to make them disappear.

Notifications can be replaced by the use of the =replaces-id= feature of the notification specification.

The notification center can (optionally) show user-specified buttons in the bottom that can be in two states (highlighted/not highlighted) and that can run customizable shell commands.

#+BEGIN_EXAMPLE

      ▙              █  █ ████████████  ███▙                  █   ▄██████▄
      ███▄           █  █ ████        █  ███▙                █    ████    ██
      ▜█████▄        █  █ ████         █  ███▙              █   █  ████    ▜█
        ▜██████▄     █  █ ████          █  ███▙      ▙     █     █  ████
      █▄   ▜██████▄  █  █ ████████████   █  ███▙    ██▙   █       █  ████
      █ ▜█▄   ▜█████▄█  █ ████            █  ███▙   ███▙ █         █  ████
      █    ▜█▄   ▜████  █ ████             █  ███▙█  ████           █  ████
      █       ▜█▄   ▜█  █ ████              █  ███ █  ██       █▙    █  ████
      █          ▜█▄    █ ████               █  █   █           █▙    █  ████
      █             ▜▄  █ ████████████        █      █           ▜████▛  ██▛


 ▄▇▇▀▀▀▀█▌        ▄▄▄▄▄▀▀██▇█▄▄▀▀▀▀▀    ▄▄▄▄▄▄      ▄▄█▇██▀▀▄▄▄▄▄        ▐█▀▀▀▀▇▇▄
▐██▌   ▀▀    ▄▄▄████████▄▄█▀        ▄█████▀▀▀███▄      ▀█▄▄████████▄▄▄    ▀▀   ▐██▌
████▄  ▄▄▄██████████▀▀   ▀▀▀█▄     ▇████▀    ▀▀██▌   ▄█▀▀▀   ▀▀██████████▄▄▄  ▄████
 ▀███████████████▀▀         ▐█▌   ██████    ▄ ▐███  ▐█▌         ▀▀███████████████▀
    ▀▀▀▀██████▀             ▀▀   ▐██▐▇▇     ▀▀▀▀      ▀▀             ▀██████▀▀▀▀
    ▄▄██████▀                     ██ ██▌         ▄                     ▀██████▄▄
  ▄███████▀                      █▀██ ▀█▄▄      ▄▄                       ▀███████▄
 ▄███████                          ▀██▄▄█████████▀                         ███████▄
 ██████                               ▀▀█████▀▀▀                            ███████
 ▐████▌                                                                      ▐████▌
   ███▄▄▄▄▄▌                                                             ▐▄▄▄▄▄███
    ▀▀▀▀▀▀                                                                 ▀▀▀▀▀▀


                                  ╒══════╕
                              NEW │ 2021 │ Update:
                                  ╘══════╛

                               Customize all CSS
                               ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈

                       New deadd.css configuration file
                          Style all elements yourself

                         Reload CSS styling on the fly

                Use CSS transitions when loading a new colortheme
                           and smoothly change the mood

           (might [probably will] brake your current styling settings)
         (more information on this in the file updateyourconfig2021.org)


                          More notification scripting
                          ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈

                            Icons can be changed

                            Images can be changed

                        Action buttons can be removed


                         Progress bar in notifications
                         ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈


                                Some Bugfixes
                                ┈┈┈┈┈┈┈┈┈┈┈┈┈

             Too wide notifications don't push out buttons anymore

                   Notification area is always full height now

                                  Many more


                       Additional new Features from 2020
                       ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈

                          More configuration options

                               Git AUR package

                               Text ellipsation

                             Better html parsing

                                 Pause poups

                                  Much more


        2020 has been a rough year for many. The DNC did make some progress
        anyways, especially due to many new contributors:


   (¯`·.¸¸.·´                                                     `·.¸¸.·´¯)
   ( \                                                                     / )
  ( \ )        mitchell-gil96 balsoft resolritter trk9001 rbowden91       ( / )
 ( ) (                                                                     ) ( )
  ( / )     ahmubashshir CobaltSpace woutervb avdv lierdakil MyriaCore    ( \ )
   ( /                                                                     \ )
    (_.·´¯`·.¸                                                    ¸.·´¯`·.¸_)


                             Thank you very much!


        Special thanks to MyriaCore who created many high quality PRs and was
        very active in the issue tracker.

        Finally, thank you to everyone who created issues, commented, and
        helped to further this project.

                                                                                     ▝
                                                                                     ▝

▖ ▐ ▖ ▐ ▌ Further news in releasenotes.org ▐ ▙▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▟

#+END_EXAMPLE

** Screenshots

Some applications, notification: [[file:README.org.img/org_20200223_193450_1en7sh.jpg]]

Notification Center opened: [[file:README.org.img/org_20200223_193345_VhlbOf.jpg]]

Link, Markup, Progressbar, and Action support: [[file:README.org.img/org_20201220_000601_9V037T.jpg]]

** Usage

To start it: #+BEGIN_SRC sh

deadd-notification-center #+END_SRC

Toggle between hidden and shown state of the notification center: #+BEGIN_SRC sh kill -s USR1 $(pidof deadd-notification-center) #+END_SRC

Set the state of a user defined button (in this example the first button, which has =id= 0): #+BEGIN_SRC sh

turn highlighting on

notify-send.py a --hint boolean:deadd-notification-center:true
int🆔0 boolean:state:true type:string:buttons

turn highlighting off

notify-send.py a --hint boolean:deadd-notification-center:true
int🆔0 boolean:state:false type:string:buttons #+END_SRC This snippet uses [[https://github.com/phuhl/notify-send.py][notify-send.py]], an improved version of libnotify (notify-send).

Clear all notifications #+BEGIN_SRC sh

within the notification center

notify-send.py a --hint boolean:deadd-notification-center:true
string:type:clearInCenter

popups

notify-send.py a --hint boolean:deadd-notification-center:true
string:type:clearPopups #+END_SRC

Pause/Unpause popup notifications #+BEGIN_SRC sh

pause popup notifications

notify-send.py a --hint boolean:deadd-notification-center:true
string:type:pausePopups

unpause popup notifications

notify-send.py a --hint boolean:deadd-notification-center:true
string:type:unpausePopups #+END_SRC

Reload CSS Styling file #+BEGIN_SRC sh notify-send.py a --hint boolean:deadd-notification-center:true
string:type:reloadStyle #+END_SRC

Send notifications that only show up in the notification center but do not produce a popup: #+BEGIN_SRC sh notify-send.py "Does not pop up" -t 1 #+END_SRC

*** Supported hints and features

Action buttons with gtk icons #+BEGIN_SRC sh notify-send.py "And buttons" "Do you like buttons?"
--hint boolean:action-icons:true
--action yes:face-cool no:face-sick
#+END_SRC

Notification images by gtk icon #+BEGIN_SRC sh notify-send.py "Icons are" "COOL"
--hint string:image-path:face-cool #+END_SRC

Notification images by file #+BEGIN_SRC sh notify-send.py "Images are" "COOL"
--hint string:image-path:file://path/to/image/from/root.png #+END_SRC

Notification with progress bar #+BEGIN_SRC sh notify-send.py "This notification has a progressbar" "33%"
--hint int:has-percentage:33) #or notify-send.py "This notification has a progressbar" "33%"
--hint int:value:33) #+END_SRC

Notification with slider #+BEGIN_SRC sh notify-send.py "This notification has a slider" "33%"
--hint int:has-percentage:33 --action changeValue:abc) #+END_SRC

*** Example: Brightness indicator

This snippet can be used to produce a brightness-indicator. It requires the [[https://github.com/phuhl/notify-send.py][notify-send.py]] script.

#+BEGIN_SRC sh #!/bin/bash

if [ "$1" == "inc" ]; then xbacklight -inc 5 fi

if [ "$1" == "dec" ]; then xbacklight -lower 5 fi

BRIGHTNESS=$(xbacklight -get) NOTI_ID=$(notify-send.py "Bildschirmhelligkeit" "$BRIGHTNESS/100"
--hint string:image-path:video-display boolean:transient:true
int:has-percentage:$BRIGHTNESS
--replaces-process "brightness-popup") #+END_SRC

*** Example: Volume indicator

This snippet can be used to produce a volume-indicator. It requires the [[https://github.com/phuhl/notify-send.py][notify-send.py]] script.

#+BEGIN_SRC sh #!/bin/bash

if [ "$1" == "inc" ]; then amixer -q sset Master 5%+ fi

if [ "$1" == "dec" ]; then amixer -q sset Master 5%- fi

if [ "$1" == "mute" ]; then amixer -q sset Master toggle fi

AMIXER=$(amixer sget Master) VOLUME=$(echo $AMIXER | grep 'Right:' | awk -F'[][]' '{ print $2 }' | tr -d "%") MUTE=$(echo $AMIXER | grep -o '[off]' | tail -n 1) if [ "$VOLUME" -le 20 ]; then ICON=audio-volume-low else if [ "$VOLUME" -le 60 ]; then ICON=audio-volume-medium else ICON=audio-volume-high fi fi if [ "$MUTE" == "[off]" ]; then ICON=audio-volume-muted fi

NOTI_ID=$(notify-send.py "Lautstärke" "$VOLUME/100"
--hint string:image-path:$ICON boolean:transient:true
int:has-percentage:$VOLUME
--replaces-process "volume-popup") #+END_SRC

** Install

Install from the AUR for Arch: [[https://aur.archlinux.org/packages/deadd-notification-center/][deadd-notification-center]].

OR

If you want to spare yourself the hassle of the build time there is a binary package available: [[https://aur.archlinux.org/packages/deadd-notification-center-bin/][deadd-notification-center-bin]].

OR

If you don't want to wait for me to publish the next stable release: Use the new AUR git-package.

[[https://aur.archlinux.org/packages/deadd-notification-center-git/][deadd-notification-center-git]].

OR

On Ubuntu, Debian, everything... Replace 1.7.2 with the current-most release from the [[https://github.com/phuhl/linux_notification_center/releases][release section]].

Manually install the dependencies (exact names might differ in your distribution):

  • gtk3
  • gobject-introspection-runtime

#+BEGIN_SRC sh tar -xvzf linux_notification_center-1.7.2.tar.gz cd linux_notification_center-1.7.2 wget https://github.com/phuhl/linux_notification_center/releases/download/1.7.2/deadd-notification-center mkdir -p .out mv deadd-notification-center .out sudo make install #+END_SRC

OR

Dependencies:

  • [[https://www.archlinux.org/packages/community/x86_64/stack/][stack]]
  • cairo
  • pango
  • gobject-introspection
  • gtk3

#+BEGIN_SRC shell-script make sudo make install #+END_SRC

** Configuration

NOTE: Some styling config has moved. More infos in this file: [[https://github.com/phuhl/linux_notification_center/blob/master/updateyourconfig2021.org][updateyourconfig2021.org]]

No configuration is necessary, the notification center comes with sensible defaults™.

All colors and sizes are customizable, as well as the default timeout for notifications and the optional buttons in the notification center. Below are possible configurable options shown. The configuration file must be located at =~/.config/deadd/deadd.conf= (or, if configured differently on your system: =${XDG_CONFIG_HOME}/deadd/deadd.conf=).

Additionally, a =deadd.css= will be loaded from the same folder. It contains the styling of the notification center. You can load changes from the =deadd.css= file by using the command described in the section "Usage".

#+BEGIN_SRC ini [notification-center]

Hide the notification center when the mouse leaves the window

hideOnMouseLeave = True

Margin at the top of the notification center in pixels. This can be

used to avoid overlap between the notification center and bars such

as polybar or i3blocks.

marginTop = 0

Margin at the bottom of the notification center in pixels.

marginBottom = 0

Margin to the right of the notification center in pixels.

marginRight = 0

Width of the notification center in pixels.

width = 500

Monitor on which the notification center will be printed.

monitor = 0

If true, the notification center will open on the screen, on which the

mouse is

followMouse = false

(Optional) Command to run at startup. This can be used to setup

button states.

startupCommand = "deadd-notification-center-startup"

If newFirst is set to true, newest notifications appear on the top

of the notification center. Else, notifications stack, from top to

bottom.

newFirst = true

If useActionIcons is set to true, Action Buttons can show Icon

useActionIcons = true

If true, the transient field in notifications will be ignored and

the notification will be persisted in the notification center anyways

ignoreTransient = false

If true, markup (, , , ) will be displayed properly

useMarkup = true

If true, html entities (& for &, % for %, etc) will be parsed

properly. This is useful for chromium-based apps, which tend to send

these in notifications.

parseHtmlEntities = true

If set to true, the parameter noClosedMsg can be set on

notifications. If noClosedMsg is set to true on a notification,

DBUS NotificationClosed messages will not be send for this

notification.

configSendNotiClosedDbusMessage = false

If set to true: If no icon is passed by the app_icon parameter

and no application "desktop-entry"-hint is present, the notification

center will try to guess the icon from the application name (if present).

Default is true.

guessIconFromAppname = true

See section "Notification based scripting" for an explanation

#match = "title=Abc;body=abc":"app=notify-send" #modify = "transient=false" #run = "":"killall notify-send"

[notification-center-notification-popup]

Default timeout used for notifications in milli-seconds. This can

be overwritten with the "-t" option (or "--expire-time") of the

notify-send command.

notiDefaultTimeout = 10000

Margin above notifications (in pixels). This can be used to avoid

overlap between notifications and a bar such as polybar or i3blocks.

distanceTop = 50

Margin on the right of the notification (in pixels).

distanceRight = 50

Vertical distance between 2 notifications (in pixels).

distanceBetween = 20

Width of the notifications.

width = 300

Monitor on which the notification will be printed.

monitor = 0

If true, the notifications will open on the screen, on which the

mouse is

followMouse = false

The display size of the application icons in the notification

pop-ups and in the notification center

iconSize = 20

The maximal display size of images that are part of notifications

for notification pop-ups and in the notification center

maxImageSize = 100

The margin around the top, bottom, left, and right of notification

images. Applies to popup notifications and in-center notifications.

imageMarginTop = 15 imageMarginBottom = 15 imageMarginLeft = 15 imageMarginRight = 0

Truncates notification bodies with '...' at the specified number of

lines. If -1 is specified, the body text will not be truncated.

Applies only to popup notifications

shortenBody = 5

The mouse button for closing a popup. Must be either "mouse1",

"mouse2", "mouse3", "mouse4", or "mouse5"

dismissButton = mouse1

The mouse button for opening a popup with the default action.

Must be either "mouse1", "mouse2", "mouse3", "mouse4", or "mouse5"

defaultActionButton = mouse3

[buttons]

This section describes the configurable buttons within the

notification center and NOT the buttons that appear in the

notifications

Note: If you want your buttons in the notification center to be

squares you should verify that the following equality holds:

[notification-center]::width

== [buttons]::buttonsPerRow * [buttons]::buttonHeight

+ ([buttons]::buttonsPerRow + 1) * [buttons]::buttonMargin

Numbers of buttons that can be drawn on a row of the notification

center.

buttonsPerRow = 5

Height of buttons in the notification center (in pixels).

buttonHeight = 60

Horizontal and vertical margin between each button in the

notification center (in pixels).

buttonMargin = 2

Labels written on the buttons in the notification center. Labels

should be written between quotes and separated by a colon. For

example:

labels = "VPN":"Bluetooth":"Wifi":"Screensaver"

Each label is represented as a clickable button in the notification

center. The commands variable below define the commands that should

be launched when the user clicks on the associated button. There

should be the same number of entries in commands and in labels

commands = "sudo vpnToggle":"bluetoothToggle":"wifiToggle":"screensaverToggle"

#+END_SRC

*** CSS styling

In the file =${XDG_CONFIG_HOME}/deadd/deadd.css= (usually =.config/deadd/deadd.css=) you can add CSS styles (GTK3-flavor). Should the installation not have created a =dead.css=, you can use the content of [[https://github.com/phuhl/linux_notification_center/blob/master/style.css][style.css]] as a foundation.

The following class-names for labels are defined:

  • Notifications:

    • =label.deadd-noti-center.notification.appname= :: Appname
    • =label.deadd-noti-center.notification.body= :: Textbody
    • =label.deadd-noti-center.notification.title= :: Notification title
    • =image.deadd-noti-center.notification.image= :: Image of a notification
    • =image.deadd-noti-center.notification.icon= :: Appicon
  • Notifications in the notification center:

    • =label.deadd-noti-center.in-center.appname= :: Appname
    • =label.deadd-noti-center.in-center.body= :: Textbody
    • =label.deadd-noti-center.in-center.title= :: Notification title
    • =label.deadd-noti-center.in-center.time= :: Notification time
    • =image.deadd-noti-center.in-center.image= :: Image of a notification
    • =image.deadd-noti-center.in-center.icon= :: Appicon
    • =button.deadd-noti-center.in-center.button-close= :: Close button on notification
  • Notification-center:

    • =label.deadd-noti-center.noti-center.time= :: The big time at the top
    • =label.deadd-noti-center.noti-center.date= :: The date text
    • =label.deadd-noti-center.noti-center.delete-all= :: "Delete all" Button

Examples:

#+CAPTION: Remove appname and icon from notifications #+BEGIN_SRC css image.deadd-noti-center.notification.icon, label.deadd-noti-center.notification.appname, image.deadd-noti-center.in-center.icon, label.deadd-noti-center.in-center.appname { opacity: 0 } #+END_SRC

#+CAPTION: Change font #+BEGIN_SRC css .deadd-noti-center { font-family: monospace; } #+END_SRC

*** Notification-based scripting

You can modify notifications if they match certain criteria.

Matching:

The criteria you can specify are equality for the following parameters:

  • title
  • body
  • app
  • time
  • icon

You can test a parameter like this: =title=Abc=. If you want to test for more than one parameter (for all of them to be true) you can concatenate the criteria with =;= like this: =title=Abc;body=You can baz yourself=.

Modifying:

You can set the following parameters:

  • title
  • body
  • app
  • time
  • timeout (specified in milliseconds)
  • right (overrides distanceRight from the configuration)
  • top (overrides distanceTop from the configuration)
  • icon (overrides the app-icon, value must be either empty, a path to an image or a gtk-icon-name)
  • image (overrides the image of the notification, value must be either empty, a path to an image or a gtk-icon-name)
  • transient (value has to be =true= or =false=)
  • noClosedMsg (value has to be =true= or =false=, if set to true it will prevent that a DBUS =NotificationClosed= message will be send for this notification. Only applies if the configuration parameter =configSendNotiClosedDbusMessage= is set to =true=)
  • removeActions (value can be anything, if used, no action buttons will be displayed on the notifications)

If you want to set more than one parameter you can concatenate them with =;= like this: =app=Crashmaster 2000;time=4:20=.

Running Commands:

Not implemented, yet.

#+BEGIN_SRC ini [notification-center] match = "title=Abc;body=abc":"app=notify-send" modify = "transient=false" run = "":"killall notify-send" #+END_SRC

** Issues and goals

See here: [[file:Worklog.org][Log of issues]]

** Contribute

First of all: Contribution is obviously 100% optional.

If you do want to contribute, feel free to send me an email (for the address, see on my profile).

If you do not want to contribute with your time, you can buy me a beer ;). Someone mentioned, she would be willing to donate, so here is my PayPal link: [[https://paypal.me/phuhl]]. Should you consider to donate, please be aware that this does not buy you the right to demand anything. This is a hobby. And will be. But if you just want to give me some motivation by showing me that someone appreciates my work, feel free to do so.

** See also

Also take a look at my [[https://github.com/phuhl/notify-send.py][notify-send.py]] which imitates notify-send (libnotify) but also is able to replace notifications.


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
linux (2,343
haskell (1,555
notifications (287
gtk (156
dbus (22

Find Open Source By Browsing 7,000 Topics Across 59 Categories