FreeBSD Desktop – Part 23 – Configuration – Herbe Notifications

vermaden

Son of Beastie

Reaction score: 1,639
Messages: 3,014

I do not use notifications. Dunno really why – seems I just did not needed them. The idea of Do Not Disturb Mode on the desktop/laptop is very strange to me as I ALWAYS work in the Do Not Disturb Mode since I do not use any notifications. Today I came across very small and compact solution for notifications on X11 desktop – herbe – as its author describes it – its daemon-less notifications without D-Bus. Minimal and lightweight.

I was curious if it works on FreeBSD and apparently it is
🙂


Today I will show you how to build, configure and use herbe as part of FreeBSD Desktop series.

herbe.png


You may want to check other articles in the FreeBSD Desktop series on the FreeBSD Desktop – Global Page where you will find links to all episodes of the series along with table of contents for each episode’s contents.

Fetch​


We will use the compact git-lite package from FreeBSD which has less dependencies then the default git package. Then we will clone the herbe repository.

# pkg install git-lite
% git clone https://github.com/dudik/herbe
Cloning into 'herbe'...
remote: Enumerating objects: 228, done.
remote: Counting objects: 100% (42/42), done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 228 (delta 21), reused 11 (delta 4), pack-reused 186
Receiving objects: 100% (228/228), 152.95 KiB | 272.00 KiB/s, done.
Resolving deltas: 100% (118/118), done.
$ cd herbe
% ls -l
total 23K
-rw-r--r-- 1 vermaden vermaden 650 2021-04-18 19:18 config.def.h
-rw-r--r-- 1 vermaden vermaden 5268 2021-04-18 19:18 herbe.c
-rw-r--r-- 1 vermaden vermaden 1070 2021-04-18 19:18 LICENSE
-rw-r--r-- 1 vermaden vermaden 425 2021-04-18 19:18 Makefile
-rw-r--r-- 1 vermaden vermaden 5578 2021-04-18 19:18 README.md

Patch​


We will need a tiny one line patch to make it build on FreeBSD.

This FreeBSD patch for Makefile file is available here:
https://github.com/dudik/herbe/pull/16

… or diff(1) directly here:
https://patch-diff.githubusercontent.com/raw/dudik/herbe/pull/16.diff

We will now apply that patch.

% fetch https://patch-diff.githubusercontent.com/raw/dudik/herbe/pull/16.diff
% patch < 16.diff
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/Makefile b/Makefile
|index 3225e36..69c8efc 100644
|--- a/Makefile
|+++ b/Makefile
--------------------------
Patching file Makefile using Plan A...
Hunk #1 succeeded at 1.
done


The herbe is now buildable on FreeBSD.

There are also other available patches – herbe patches – available here.

From all of them I find Vertical Stacking patch the most interesting. We will also apply it.

% fetch https://patch-diff.githubusercontent.com/raw/dudik/herbe/pull/19.diff
% patch < 19.diff
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/herbe.c b/herbe.c
|index 51d3990..8bfdbc1 100644
|--- a/herbe.c
|+++ b/herbe.c
--------------------------
Patching file herbe.c using Plan A...
Hunk #1 succeeded at 7.
Hunk #2 succeeded at 80.
Hunk #3 succeeded at 162.
Hunk #4 succeeded at 188.
Hunk #5 succeeded at 218.
Hunk #6 succeeded at 230.
done



Config​


You can additionally patch herbe so it will be configurable by using ~/.Xresources or ~/.Xdefaults files. IMHO its so small and compiles in second that its not needed but if you would like to also apply it then its available here – Xresources – in the patches section.

I have chosen to configure it using the config.def.h file. Here are my values.

% cat config.def.h
static const char *background_color = "#222222";
static const char *border_color = "#666666";
static const char *font_color = "#eeeeee";
static const char *font_pattern = "Ubuntu Mono:size=10";
static const unsigned line_spacing = 5;
static const unsigned int padding = 15;

static const unsigned int width = 550;
static const unsigned int border_size = 4;
static const unsigned int pos_x = 15;
static const unsigned int pos_y = 45;

enum corners { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT };
enum corners corner = TOP_RIGHT;

static const unsigned int duration = 5; /* in seconds */

#define DISMISS_BUTTON Button1
#define ACTION_BUTTON Button3

Build​


The build process could not be simpler. Just type make and you are done.

% make
cp config.def.h config.h
cc herbe.c -Wall -Wextra -pedantic -I/usr/local/include -L/usr/local/lib -lX11 -lXft -I/usr/local/include/freetype2 -pthread -o herbe

% file -s herbe | tr ',' '\n'
herbe: ELF 64-bit LSB executable
x86-64
version 1 (FreeBSD)
dynamically linked
interpreter /libexec/ld-elf.so.1
for FreeBSD 13.0 (1300139)
FreeBSD-style
with debug_info
not stripped

% ./herbe
Usage: ./herbe body

Test​


I did not yet implemented herbe anywhere on my scripts so I will use this simple ‘mockup’ to show you what to expect.

% \
herbe "Wifi connection 'wireless' is not connected." \
& herbe "Removable storage /dev/da0 automounted at /media/da0 with exFAT filesystem." \
&


Here is how it looks in real life X11 session.

desktop-notifications.jpg


As you can see it works very well and its ultra fast. Its also very light on system resources.

% ps aux | grep -e RSS -e herbe -e sshd
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
vermaden 41909 0.0 0.1 19568 9128 3 S+ 20:22 0:00.02 herbe Message.
root 38 0.0 0.1 20948 8340 - Is Thu23 0:00.00 /usr/sbin/sshd


As you can see its RAM usage is very little – as little as sshd daemon.

EOF

Continue reading...
 
Top