sxalert

Simple notification system for X
Log | Files | Refs | README | LICENSE

commit 0725ebc23d5e2e565c43d870331e92327a1b3587
parent 6c5cfea6ffcfff1a020c3920b5e1c1b82d74174c
Author: Michael Constantine Dimopoulos <mk@mcdim.xyz>
Date:   Sun,  5 Nov 2023 14:22:04 +0000

Fixed height bug, updated Makefile & readme

Diffstat:
MMakefile | 6+++++-
MREADME.md | 2+-
Mconfig.h | 5+++--
Msxalert.c | 28++++++++++++++--------------
4 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,2 +1,6 @@ sxalert: - c99 sxalert.c -I/usr/include/freetype2/ -lXft -lX11 -lfreetype + c99 sxalert.c -I/usr/include/freetype2/ -lXft -lX11 -lfreetype -o sxalert +install: + mv sxalert /bin/sxalert +uninstall: + rm /bin/sxalert diff --git a/README.md b/README.md @@ -7,6 +7,7 @@ Simple notification system for X that works without a daemon. This is mainly for + Freetype scalable fonts + UTF-8 support + Configurable & scriptable ++ Dynamic box sizing ## Dependencies To build simple X alert, you'll need Xlib and Xft. @@ -31,7 +32,6 @@ These will overwrite the defaults written in `config.h` ## TODOs: + Dynamic screen positioning -+ Width based on text + Exit by event (perhaps as a path) + Titles (perhaps as a patch) + (?) optional daemon for positinioning diff --git a/config.h b/config.h @@ -18,7 +18,8 @@ static char border_color[7] = "e1ba9b"; static int border_width = 1; static int text_x_padding = 10; -static int min_width = 400; -static int max_width = 600; +static int min_width = 300; +static int max_width = 1100; const char *fontname = "DejaVu Sans Mono:size=12:antialias=true"; +static int text_height = 10; diff --git a/sxalert.c b/sxalert.c @@ -82,14 +82,14 @@ get_max(int arr[], int len) static int get_width(Display *dpy, XftFont *font, char **lines, int length) { - XGlyphInfo extents; + XGlyphInfo ext; int width = 0; if (length > 0) { int width_lines[length]; int j = 0; for (int i = 0; i < length; i++) { - XftTextExtentsUtf8(dpy, font, (XftChar8*)lines[i], strlen(lines[i]), &extents); - width_lines[i] = extents.xOff; + XftTextExtentsUtf8(dpy, font, (XftChar8*)lines[i], strlen(lines[i]), &ext); + width_lines[i] = ext.xOff; j++; } @@ -105,7 +105,6 @@ get_width(Display *dpy, XftFont *font, char **lines, int length) return width; } - static void write_text(Display *dpy, XftDraw *draw, XftColor color, XftFont *font, int text_height, char **lines, int length) { @@ -159,18 +158,19 @@ draw(int border, int duration, char **lines, int length) int width = get_width(dpy, font, lines, length); - int text_height, height; - if (length > 0) { - XftTextExtentsUtf8(dpy, font, (XftChar8*)lines[0], strlen(lines[0]), &extents); - text_height = extents.height; - height = length * (text_height * 2) + text_height; - } else { - int text_height = text_x_padding; - height = text_height; - } + int height = length * (text_height * 2) + text_height; + //if (length > 0) { + // XftTextExtentsUtf8(dpy, font, (XftChar8*)lines[0], strlen(lines[0]), &extents); + // text_height = extents.height; + // height = length * (text_height * 2) + text_height; + //} else { + // text_height = text_x_padding; + // height = text_height; + //} + //printf("text_height: %d\n", text_height); /* TODO: calculate position dynamically */ - Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, scr), 1500, 50, width, height, border, hex2int(border_color), hex2int(bg_color)); + Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, scr), 1500-(width-400), 50, width, height, border, hex2int(border_color), hex2int(bg_color)); XSetWindowAttributes attributes; attributes.override_redirect = True; XChangeWindowAttributes(dpy, win, CWOverrideRedirect, &attributes);