Upload files to ".suckless/slstatus/components"
This commit is contained in:
parent
deab5458d3
commit
a71f359e0f
5 changed files with 401 additions and 0 deletions
69
.suckless/slstatus/components/Makefile
Normal file
69
.suckless/slstatus/components/Makefile
Normal file
|
@ -0,0 +1,69 @@
|
|||
# See LICENSE file for copyright and license details
|
||||
# slstatus - suckless status monitor
|
||||
.POSIX:
|
||||
|
||||
include config.mk
|
||||
|
||||
REQ = util
|
||||
COM =\
|
||||
components/battery\
|
||||
components/cat\
|
||||
components/cpu\
|
||||
components/datetime\
|
||||
components/disk\
|
||||
components/entropy\
|
||||
components/hostname\
|
||||
components/ip\
|
||||
components/kernel_release\
|
||||
components/keyboard_indicators\
|
||||
components/keymap\
|
||||
components/load_avg\
|
||||
components/netspeeds\
|
||||
components/num_files\
|
||||
components/ram\
|
||||
components/run_command\
|
||||
components/swap\
|
||||
components/temperature\
|
||||
components/uptime\
|
||||
components/user\
|
||||
components/volume\
|
||||
components/wifi
|
||||
|
||||
all: slstatus
|
||||
|
||||
$(COM:=.o): config.mk $(REQ:=.h) slstatus.h
|
||||
slstatus.o: slstatus.c slstatus.h arg.h config.h config.mk $(REQ:=.h)
|
||||
|
||||
.c.o:
|
||||
$(CC) -o $@ -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
config.h:
|
||||
cp config.def.h $@
|
||||
|
||||
slstatus: slstatus.o $(COM:=.o) $(REQ:=.o)
|
||||
$(CC) -o $@ $(LDFLAGS) $(COM:=.o) $(REQ:=.o) slstatus.o $(LDLIBS)
|
||||
|
||||
clean:
|
||||
rm -f slstatus slstatus.o $(COM:=.o) $(REQ:=.o) slstatus-${VERSION}.tar.gz
|
||||
|
||||
dist:
|
||||
rm -rf "slstatus-$(VERSION)"
|
||||
mkdir -p "slstatus-$(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)"
|
||||
|
||||
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"
|
||||
|
||||
uninstall:
|
||||
rm -f "$(DESTDIR)$(PREFIX)/bin/slstatus"
|
||||
rm -f "$(DESTDIR)$(MANPREFIX)/man1/slstatus.1"
|
65
.suckless/slstatus/components/README
Normal file
65
.suckless/slstatus/components/README
Normal file
|
@ -0,0 +1,65 @@
|
|||
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.
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
- Battery percentage/state/time left
|
||||
- Cat (read file)
|
||||
- CPU usage
|
||||
- CPU frequency
|
||||
- Custom shell commands
|
||||
- Date and time
|
||||
- Disk status (free storage, percentage, total storage and used storage)
|
||||
- Available entropy
|
||||
- Username/GID/UID
|
||||
- Hostname
|
||||
- IP address (IPv4 and IPv6), interface status
|
||||
- Kernel version
|
||||
- Keyboard indicators
|
||||
- Keymap
|
||||
- Load average
|
||||
- Network speeds (RX and TX)
|
||||
- Number of files in a directory (hint: Maildir)
|
||||
- Memory status (free memory, percentage, total memory and used memory)
|
||||
- Swap status (free swap, percentage, total swap and used swap)
|
||||
- Temperature
|
||||
- Uptime
|
||||
- Volume percentage
|
||||
- WiFi signal percentage and ESSID
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
Currently slstatus works on FreeBSD, Linux and OpenBSD.
|
||||
In order to build slstatus you need the Xlib header files.
|
||||
|
||||
- For volume percentage on Linux the kernel module `snd-mixer-oss` must be
|
||||
loaded.
|
||||
- For volume percentage on FreeBSD, `sndio` must be installed.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
Edit config.mk to match your local setup (slstatus is installed into the
|
||||
/usr/local namespace by default).
|
||||
|
||||
Afterwards enter the following command to build and install slstatus (if
|
||||
necessary as root):
|
||||
|
||||
make clean install
|
||||
|
||||
|
||||
Running slstatus
|
||||
----------------
|
||||
See the man page for details.
|
||||
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
slstatus can be customized by creating a custom config.h and (re)compiling the
|
||||
source code. This keeps it fast, secure and simple.
|
47
.suckless/slstatus/components/slstatus.1
Normal file
47
.suckless/slstatus/components/slstatus.1
Normal file
|
@ -0,0 +1,47 @@
|
|||
.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
|
135
.suckless/slstatus/components/slstatus.c
Normal file
135
.suckless/slstatus/components/slstatus.c
Normal file
|
@ -0,0 +1,135 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "arg.h"
|
||||
#include "slstatus.h"
|
||||
#include "util.h"
|
||||
|
||||
struct arg {
|
||||
const char *(*func)(const char *);
|
||||
const char *fmt;
|
||||
const char *args;
|
||||
};
|
||||
|
||||
char buf[1024];
|
||||
static volatile sig_atomic_t done;
|
||||
static Display *dpy;
|
||||
|
||||
#include "config.h"
|
||||
|
||||
static void
|
||||
terminate(const int signo)
|
||||
{
|
||||
if (signo != SIGUSR1)
|
||||
done = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
difftimespec(struct timespec *res, struct timespec *a, struct timespec *b)
|
||||
{
|
||||
res->tv_sec = a->tv_sec - b->tv_sec - (a->tv_nsec < b->tv_nsec);
|
||||
res->tv_nsec = a->tv_nsec - b->tv_nsec +
|
||||
(a->tv_nsec < b->tv_nsec) * 1E9;
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
die("usage: %s [-v] [-s] [-1]", argv0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct sigaction act;
|
||||
struct timespec start, current, diff, intspec, wait;
|
||||
size_t i, len;
|
||||
int sflag, ret;
|
||||
char status[MAXLEN];
|
||||
const char *res;
|
||||
|
||||
sflag = 0;
|
||||
ARGBEGIN {
|
||||
case 'v':
|
||||
die("slstatus-"VERSION);
|
||||
break;
|
||||
case '1':
|
||||
done = 1;
|
||||
/* FALLTHROUGH */
|
||||
case 's':
|
||||
sflag = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
} ARGEND
|
||||
|
||||
if (argc)
|
||||
usage();
|
||||
|
||||
memset(&act, 0, sizeof(act));
|
||||
act.sa_handler = terminate;
|
||||
sigaction(SIGINT, &act, NULL);
|
||||
sigaction(SIGTERM, &act, NULL);
|
||||
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:");
|
||||
|
||||
status[0] = '\0';
|
||||
for (i = len = 0; i < LEN(args); i++) {
|
||||
if (!(res = args[i].func(args[i].args)))
|
||||
res = unknown_str;
|
||||
|
||||
if ((ret = esnprintf(status + len, sizeof(status) - len,
|
||||
args[i].fmt, res)) < 0)
|
||||
break;
|
||||
|
||||
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 (!done) {
|
||||
if (clock_gettime(CLOCK_MONOTONIC, ¤t) < 0)
|
||||
die("clock_gettime:");
|
||||
difftimespec(&diff, ¤t, &start);
|
||||
|
||||
intspec.tv_sec = interval / 1000;
|
||||
intspec.tv_nsec = (interval % 1000) * 1E6;
|
||||
difftimespec(&wait, &intspec, &diff);
|
||||
|
||||
if (wait.tv_sec >= 0 &&
|
||||
nanosleep(&wait, NULL) < 0 &&
|
||||
errno != EINTR)
|
||||
die("nanosleep:");
|
||||
}
|
||||
} while (!done);
|
||||
|
||||
if (!sflag) {
|
||||
XStoreName(dpy, DefaultRootWindow(dpy), NULL);
|
||||
if (XCloseDisplay(dpy) < 0)
|
||||
die("XCloseDisplay: Failed to close display");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
85
.suckless/slstatus/components/slstatus.h
Normal file
85
.suckless/slstatus/components/slstatus.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
/* battery */
|
||||
const char *battery_perc(const char *);
|
||||
const char *battery_remaining(const char *);
|
||||
const char *battery_state(const char *);
|
||||
|
||||
/* cat */
|
||||
const char *cat(const char *path);
|
||||
|
||||
/* cpu */
|
||||
const char *cpu_freq(const char *unused);
|
||||
const char *cpu_perc(const char *unused);
|
||||
|
||||
/* datetime */
|
||||
const char *datetime(const char *fmt);
|
||||
|
||||
/* disk */
|
||||
const char *disk_free(const char *path);
|
||||
const char *disk_perc(const char *path);
|
||||
const char *disk_total(const char *path);
|
||||
const char *disk_used(const char *path);
|
||||
|
||||
/* entropy */
|
||||
const char *entropy(const char *unused);
|
||||
|
||||
/* hostname */
|
||||
const char *hostname(const char *unused);
|
||||
|
||||
/* ip */
|
||||
const char *ipv4(const char *interface);
|
||||
const char *ipv6(const char *interface);
|
||||
const char *up(const char *interface);
|
||||
|
||||
/* kernel_release */
|
||||
const char *kernel_release(const char *unused);
|
||||
|
||||
/* keyboard_indicators */
|
||||
const char *keyboard_indicators(const char *fmt);
|
||||
|
||||
/* keymap */
|
||||
const char *keymap(const char *unused);
|
||||
|
||||
/* load_avg */
|
||||
const char *load_avg(const char *unused);
|
||||
|
||||
/* netspeeds */
|
||||
const char *netspeed_rx(const char *interface);
|
||||
const char *netspeed_tx(const char *interface);
|
||||
|
||||
/* num_files */
|
||||
const char *num_files(const char *path);
|
||||
|
||||
/* ram */
|
||||
const char *ram_free(const char *unused);
|
||||
const char *ram_perc(const char *unused);
|
||||
const char *ram_total(const char *unused);
|
||||
const char *ram_used(const char *unused);
|
||||
|
||||
/* run_command */
|
||||
const char *run_command(const char *cmd);
|
||||
|
||||
/* swap */
|
||||
const char *swap_free(const char *unused);
|
||||
const char *swap_perc(const char *unused);
|
||||
const char *swap_total(const char *unused);
|
||||
const char *swap_used(const char *unused);
|
||||
|
||||
/* temperature */
|
||||
const char *temp(const char *);
|
||||
|
||||
/* uptime */
|
||||
const char *uptime(const char *unused);
|
||||
|
||||
/* user */
|
||||
const char *gid(const char *unused);
|
||||
const char *uid(const char *unused);
|
||||
const char *username(const char *unused);
|
||||
|
||||
/* volume */
|
||||
const char *vol_perc(const char *card);
|
||||
|
||||
/* wifi */
|
||||
const char *wifi_essid(const char *interface);
|
||||
const char *wifi_perc(const char *interface);
|
Loading…
Add table
Reference in a new issue