swstatus

fork of slstatus for dmw
git clone https://git.daat.foo/swstatus.git
Log | Files | Refs | README | LICENSE

commit df235ca03e669529e836e5c663b6b78c85266c18
parent 675c83912ea1aca9834448aaa87a040bc9990c52
Author: cowmonk <cowmonk@based.pt>
Date:   Sun, 22 Nov 2026 20:41:35 -0700

swstatus: init commit

just writes to stdout and reorganized some of the project (mostly
with X11 dependent components). Also added .gitignore because I don't
wanna accidentally upload binaries...

Diffstat:
A.gitignore | 2++
MMakefile | 42+++++++++++++++++++++---------------------
MREADME | 37++++++++++++++++++++++---------------
Mconfig.mk | 15++++++++-------
Dslstatus.1 | 47-----------------------------------------------
Mslstatus.c | 31+++++--------------------------
Aswstatus | 0
7 files changed, 58 insertions(+), 116 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +*.o +config.h diff --git a/Makefile b/Makefile @@ -1,10 +1,11 @@ # See LICENSE file for copyright and license details -# slstatus - suckless status monitor +# swstatus - suckless status monitor .POSIX: include config.mk REQ = util +X11COM = components/keyboard_indicators components/keymap COM =\ components/battery\ components/cat\ @@ -15,8 +16,6 @@ COM =\ components/hostname\ components/ip\ components/kernel_release\ - components/keyboard_indicators\ - components/keymap\ components/load_avg\ components/netspeeds\ components/num_files\ @@ -29,9 +28,9 @@ COM =\ components/volume\ components/wifi -all: slstatus +all: swstatus -$(COM:=.o): config.mk $(REQ:=.h) slstatus.h +$(COM:=.o) $(X11COM:=.o): config.mk $(REQ:=.h) slstatus.h slstatus.o: slstatus.c slstatus.h arg.h config.h config.mk $(REQ:=.h) .c.o: @@ -40,30 +39,31 @@ slstatus.o: slstatus.c slstatus.h arg.h config.h config.mk $(REQ:=.h) config.h: cp config.def.h $@ -slstatus: slstatus.o $(COM:=.o) $(REQ:=.o) - $(CC) -o $@ $(LDFLAGS) $(COM:=.o) $(REQ:=.o) slstatus.o $(LDLIBS) +swstatus: slstatus.o $(COM:=.o) $(KEYBOARD:=.o) $(REQ:=.o) + $(CC) -o $@ $(LDFLAGS) $(COM:=.o) $(KEYBOARD:=.o) $(REQ:=.o) slstatus.o $(LDLIBS) clean: - rm -f slstatus slstatus.o $(COM:=.o) $(REQ:=.o) slstatus-${VERSION}.tar.gz + rm -f swstatus slstatus.o $(COM:=.o) $(X11COM:=.o) $(REQ:=.o) swstatus-${VERSION}.tar.gz dist: - rm -rf "slstatus-$(VERSION)" - mkdir -p "slstatus-$(VERSION)/components" + rm -rf "swstatus-$(VERSION)" + mkdir -p "swstatus-$(VERSION)/components" cp -R LICENSE Makefile README config.mk config.def.h \ arg.h slstatus.h slstatus.c $(REQ:=.c) $(REQ:=.h) \ - slstatus.1 "slstatus-$(VERSION)" - cp -R $(COM:=.c) "slstatus-$(VERSION)/components" - tar -cf - "slstatus-$(VERSION)" | gzip -c > "slstatus-$(VERSION).tar.gz" - rm -rf "slstatus-$(VERSION)" + swstatus.1 "swstatus-$(VERSION)" + cp -R $(COM:=.c) $(X11COM:=.c) "swstatus-$(VERSION)/components" + tar -cf - "swstatus-$(VERSION)" | gzip -c > "swstatus-$(VERSION).tar.gz" + rm -rf "swstatus-$(VERSION)" install: all mkdir -p "$(DESTDIR)$(PREFIX)/bin" - cp -f slstatus "$(DESTDIR)$(PREFIX)/bin" - chmod 755 "$(DESTDIR)$(PREFIX)/bin/slstatus" - mkdir -p "$(DESTDIR)$(MANPREFIX)/man1" - cp -f slstatus.1 "$(DESTDIR)$(MANPREFIX)/man1" - chmod 644 "$(DESTDIR)$(MANPREFIX)/man1/slstatus.1" + cp -f swstatus "$(DESTDIR)$(PREFIX)/bin" + chmod 755 "$(DESTDIR)$(PREFIX)/bin/swstatus" + #TODO: manpages (someday) + # mkdir -p "$(DESTDIR)$(MANPREFIX)/man1" + # cp -f swstatus.1 "$(DESTDIR)$(MANPREFIX)/man1" + # chmod 644 "$(DESTDIR)$(MANPREFIX)/man1/swstatus.1" uninstall: - rm -f "$(DESTDIR)$(PREFIX)/bin/slstatus" - rm -f "$(DESTDIR)$(MANPREFIX)/man1/slstatus.1" + rm -f "$(DESTDIR)$(PREFIX)/bin/swstatus" + # rm -f "$(DESTDIR)$(MANPREFIX)/man1/swstatus.1" diff --git a/README b/README @@ -1,9 +1,7 @@ -slstatus - suckless status -========================== -slstatus is a small tool for providing system status information to other -programs over the EWMH property of the root window (used by dwm(1)) or -standard input/output. It is designed to be as efficient as possible by -only issuing the minimum of system calls required. +swstatus +======== +swstatus is a fork of slstatus. It writes one line per update to dmw's +status bar through a pipe. Features @@ -20,8 +18,8 @@ Features - Hostname - IP address (IPv4 and IPv6), interface status - Kernel version -- Keyboard indicators -- Keymap +- Keyboard indicators (optional X11 component) +- Keymap (optional X11 component) - Load average - Network speeds (RX and TX) - Number of files in a directory (hint: Maildir) @@ -35,8 +33,9 @@ Features Requirements ------------ -Currently slstatus works on FreeBSD, Linux and OpenBSD. -In order to build slstatus you need the Xlib header files. +Currently swstatus works on FreeBSD, Linux and OpenBSD. +The optional keymap and keyboard indicators query an X server. To build +them, enable KEYBOARD and the X11 library in config.mk. - For volume percentage on Linux the kernel module `snd-mixer-oss` must be loaded. @@ -45,21 +44,29 @@ In order to build slstatus you need the Xlib header files. Installation ------------ -Edit config.mk to match your local setup (slstatus is installed into the +Edit config.mk to match your local setup (swstatus is installed into the /usr/local namespace by default). -Afterwards enter the following command to build and install slstatus (if +Afterwards enter the following command to build and install swstatus (if necessary as root): make clean install -Running slstatus +Running swstatus ---------------- -See the man page for details. +From a VT: + + swstatus | swc-launch dmw + +Inside an existing Wayland session: + + swstatus | SWC_BACKEND=nested dmw + +Use swstatus -1 to print a single update. Configuration ------------- -slstatus can be customized by creating a custom config.h and (re)compiling the +swstatus can be customized by creating a custom config.h and (re)compiling the source code. This keeps it fast, secure and simple. diff --git a/config.mk b/config.mk @@ -1,4 +1,4 @@ -# slstatus version +# swstatus version VERSION = 1.1 # customize below to fit your system @@ -7,16 +7,17 @@ VERSION = 1.1 PREFIX = /usr/local MANPREFIX = $(PREFIX)/share/man -X11INC = /usr/X11R6/include -X11LIB = /usr/X11R6/lib - # flags -CPPFLAGS = -I$(X11INC) -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\" +CPPFLAGS = -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\" CFLAGS = -std=c99 -pedantic -Wall -Wextra -Wno-unused-parameter -Os -LDFLAGS = -L$(X11LIB) -s +LDFLAGS = -s # OpenBSD: add -lsndio # FreeBSD: add -lkvm -lsndio -LDLIBS = -lX11 +LDLIBS = + +# Uncomment both lines for X11 keyboard indicators and keymap. +# KEYBOARD = $(X11COM) +# LDLIBS += -lX11 # compiler and linker CC = cc diff --git a/slstatus.1 b/slstatus.1 @@ -1,47 +0,0 @@ -.Dd 2023-04-23 -.Dt SLSTATUS 1 -.Os -.Sh NAME -.Nm slstatus -.Nd suckless status -.Sh SYNOPSIS -.Nm -.Op Fl s -.Op Fl 1 -.Sh DESCRIPTION -.Nm -is a small tool for providing system status information to other programs -over the EWMH -.Em WM_NAME -property of the root window (used by -.Xr dwm 1 ) or standard input/output. It is designed to be as efficient as possible by -only issuing the minimum of system calls required. -.P -By default, -.Nm -outputs to WM_NAME. -.Sh OPTIONS -.Bl -tag -width Ds -.It Fl v -Print version information to stderr, then exit. -.It Fl s -Write to stdout instead of WM_NAME. -.It Fl 1 -Write once to stdout and quit. -.El -.Sh CUSTOMIZATION -.Nm -can be customized by creating a custom config.h and (re)compiling the source -code. This keeps it fast, secure and simple. -.Sh SIGNALS -.Nm -responds to the following signals: -.Pp -.Bl -tag -width TERM -compact -.It USR1 -Triggers an instant redraw. -.El -.Sh AUTHORS -See the LICENSE file for the authors. -.Sh SEE ALSO -.Xr dwm 1 diff --git a/slstatus.c b/slstatus.c @@ -5,7 +5,6 @@ #include <stdlib.h> #include <string.h> #include <time.h> -#include <X11/Xlib.h> #include "arg.h" #include "slstatus.h" @@ -19,7 +18,6 @@ struct arg { char buf[1024]; static volatile sig_atomic_t done; -static Display *dpy; #include "config.h" @@ -50,20 +48,18 @@ main(int argc, char *argv[]) struct sigaction act; struct timespec start, current, diff, intspec, wait; size_t i, len; - int sflag, ret; + int ret; char status[MAXLEN]; const char *res; - sflag = 0; ARGBEGIN { case 'v': - die("slstatus-"VERSION); + die("swstatus-"VERSION); break; case '1': done = 1; - /* FALLTHROUGH */ + break; case 's': - sflag = 1; break; default: usage(); @@ -79,9 +75,6 @@ main(int argc, char *argv[]) act.sa_flags |= SA_RESTART; sigaction(SIGUSR1, &act, NULL); - if (!sflag && !(dpy = XOpenDisplay(NULL))) - die("XOpenDisplay: Failed to open display"); - do { if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) die("clock_gettime:"); @@ -98,16 +91,8 @@ main(int argc, char *argv[]) len += ret; } - if (sflag) { - puts(status); - fflush(stdout); - if (ferror(stdout)) - die("puts:"); - } else { - if (XStoreName(dpy, DefaultRootWindow(dpy), status) < 0) - die("XStoreName: Allocation failed"); - XFlush(dpy); - } + if (puts(status) == EOF || fflush(stdout) == EOF) + die("stdout:"); if (!done) { if (clock_gettime(CLOCK_MONOTONIC, &current) < 0) @@ -125,11 +110,5 @@ main(int argc, char *argv[]) } } while (!done); - if (!sflag) { - XStoreName(dpy, DefaultRootWindow(dpy), NULL); - if (XCloseDisplay(dpy) < 0) - die("XCloseDisplay: Failed to close display"); - } - return 0; } diff --git a/swstatus b/swstatus Binary files differ.