Compare commits
10 Commits
e0c155e9ab
...
f227db9662
Author | SHA1 | Date |
---|---|---|
Sky Hearn | f227db9662 | |
Sky Hearn | 7045c6bb8d | |
Sky Hearn | b0f33c6d3d | |
Sky Hearn | 97661ce321 | |
Sky Hearn | 3f2d2b2dc1 | |
Sky Hearn | 72fb2fa2ae | |
Sky Hearn | 4ed2def931 | |
drkhsh | f68f49273e | |
drkhsh | 86c7a84c23 | |
drkhsh | 483169021b |
6
Makefile
6
Makefile
|
@ -14,6 +14,7 @@ COM =\
|
|||
components/entropy\
|
||||
components/hostname\
|
||||
components/ip\
|
||||
components/kanji\
|
||||
components/kernel_release\
|
||||
components/keyboard_indicators\
|
||||
components/keymap\
|
||||
|
@ -44,14 +45,15 @@ 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)
|
||||
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.c $(COM:=.c) $(REQ:=.c) $(REQ:=.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)"
|
||||
|
||||
|
|
6
README
6
README
|
@ -63,9 +63,3 @@ Configuration
|
|||
-------------
|
||||
slstatus can be customized by creating a custom config.h and (re)compiling the
|
||||
source code. This keeps it fast, secure and simple.
|
||||
|
||||
|
||||
Upcoming
|
||||
--------
|
||||
A first feature-complete release with official packages for common distributions
|
||||
will come soon.
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
/* Written by Madison Lynch <madi@mxdi.xyz> */
|
||||
#include <time.h>
|
||||
|
||||
const char *
|
||||
kanji(const char *unused) {
|
||||
char *kanji[] = {"日", "月", "火", "水", "木", "金", "土"};
|
||||
time_t t=time(NULL);
|
||||
struct tm tm=*localtime(&t);
|
||||
int map[]={0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4},
|
||||
m=tm.tm_mon+1,
|
||||
y=tm.tm_year+1900-(m<3),
|
||||
wd=(y+y/4-y/100+y/400+map[m-1]+tm.tm_mday)%7;
|
||||
return kanji[wd];
|
||||
}
|
11
config.def.h
11
config.def.h
|
@ -31,6 +31,7 @@ static const char unknown_str[] = "n/a";
|
|||
* hostname hostname NULL
|
||||
* ipv4 IPv4 address interface name (eth0)
|
||||
* ipv6 IPv6 address interface name (eth0)
|
||||
* kanji japanese day of week kanji NULL
|
||||
* kernel_release `uname -r` NULL
|
||||
* keyboard_indicators caps/num lock indicators format string (c?n?)
|
||||
* see keyboard_indicators.c
|
||||
|
@ -64,6 +65,12 @@ static const char unknown_str[] = "n/a";
|
|||
* wifi_perc WiFi signal in percent interface name (wlan0)
|
||||
*/
|
||||
static const struct arg args[] = {
|
||||
/* function format argument */
|
||||
{ datetime, "%s", "%F %T" },
|
||||
/* function format argument */
|
||||
{ battery_state, "BAT1 : %s, ", "BAT1"},
|
||||
{ battery_perc, "%s%% ", "BAT1"},
|
||||
{ battery_remaining, "BAT1 : %s |", "BAT1"},
|
||||
{ cpu_freq, "cpu : %s MHz ",NULL},
|
||||
{ cpu_perc, "%s%% | ", NULL},
|
||||
{ datetime, "%s ", "%F %T" },
|
||||
{ kanji, "%s", NULL},
|
||||
};
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
/* interval between updates (in ms) */
|
||||
const unsigned int interval = 1000;
|
||||
|
||||
/* text to show if no value can be retrieved */
|
||||
static const char unknown_str[] = "n/a";
|
||||
|
||||
/* maximum output string length */
|
||||
#define MAXLEN 2048
|
||||
|
||||
/*
|
||||
* function description argument (example)
|
||||
*
|
||||
* battery_perc battery percentage battery name (BAT0)
|
||||
* NULL on OpenBSD/FreeBSD
|
||||
* battery_remaining battery remaining HH:MM battery name (BAT0)
|
||||
* NULL on OpenBSD/FreeBSD
|
||||
* battery_state battery charging state battery name (BAT0)
|
||||
* NULL on OpenBSD/FreeBSD
|
||||
* cat read arbitrary file path
|
||||
* cpu_freq cpu frequency in MHz NULL
|
||||
* cpu_perc cpu usage in percent NULL
|
||||
* datetime date and time format string (%F %T)
|
||||
* disk_free free disk space in GB mountpoint path (/)
|
||||
* disk_perc disk usage in percent mountpoint path (/)
|
||||
* disk_total total disk space in GB mountpoint path (/)
|
||||
* disk_used used disk space in GB mountpoint path (/)
|
||||
* entropy available entropy NULL
|
||||
* gid GID of current user NULL
|
||||
* hostname hostname NULL
|
||||
* ipv4 IPv4 address interface name (eth0)
|
||||
* ipv6 IPv6 address interface name (eth0)
|
||||
* kanji japanese day of week kanji NULL
|
||||
* kernel_release `uname -r` NULL
|
||||
* keyboard_indicators caps/num lock indicators format string (c?n?)
|
||||
* see keyboard_indicators.c
|
||||
* keymap layout (variant) of current NULL
|
||||
* keymap
|
||||
* load_avg load average NULL
|
||||
* netspeed_rx receive network speed interface name (wlan0)
|
||||
* netspeed_tx transfer network speed interface name (wlan0)
|
||||
* num_files number of files in a directory path
|
||||
* (/home/foo/Inbox/cur)
|
||||
* ram_free free memory in GB NULL
|
||||
* ram_perc memory usage in percent NULL
|
||||
* ram_total total memory size in GB NULL
|
||||
* ram_used used memory in GB NULL
|
||||
* run_command custom shell command command (echo foo)
|
||||
* swap_free free swap in GB NULL
|
||||
* swap_perc swap usage in percent NULL
|
||||
* swap_total total swap size in GB NULL
|
||||
* swap_used used swap in GB NULL
|
||||
* temp temperature in degree celsius sensor file
|
||||
* (/sys/class/thermal/...)
|
||||
* NULL on OpenBSD
|
||||
* thermal zone on FreeBSD
|
||||
* (tz0, tz1, etc.)
|
||||
* uid UID of current user NULL
|
||||
* uptime system uptime NULL
|
||||
* username username of current user NULL
|
||||
* vol_perc OSS/ALSA volume in percent mixer file (/dev/mixer)
|
||||
* NULL on OpenBSD/FreeBSD
|
||||
* wifi_essid WiFi ESSID interface name (wlan0)
|
||||
* wifi_perc WiFi signal in percent interface name (wlan0)
|
||||
*/
|
||||
static const struct arg args[] = {
|
||||
/* function format argument */
|
||||
{ battery_state, "BAT1 : %s", "BAT1"},
|
||||
{ battery_perc, "%s%% ", "BAT1"},
|
||||
{ battery_remaining, "%s | ", "BAT1"},
|
||||
{ cpu_freq, "cpu : %sHz ",NULL},
|
||||
{ cpu_perc, "%s%% | ", NULL},
|
||||
{ datetime, "%s ", "%F %T" },
|
||||
{ kanji, "%s ", NULL},
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
# slstatus version
|
||||
VERSION = 0
|
||||
VERSION = 1.0
|
||||
|
||||
# customize below to fit your system
|
||||
|
||||
|
@ -11,7 +11,7 @@ X11INC = /usr/X11R6/include
|
|||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -I$(X11INC) -D_DEFAULT_SOURCE
|
||||
CPPFLAGS = -I$(X11INC) -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\"
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wextra -Wno-unused-parameter -Os
|
||||
LDFLAGS = -L$(X11LIB) -s
|
||||
# OpenBSD: add -lsndio
|
||||
|
|
|
@ -22,6 +22,8 @@ By default,
|
|||
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
|
||||
|
|
|
@ -41,7 +41,7 @@ difftimespec(struct timespec *res, struct timespec *a, struct timespec *b)
|
|||
static void
|
||||
usage(void)
|
||||
{
|
||||
die("usage: %s [-s] [-1]", argv0);
|
||||
die("usage: %s [-v] [-s] [-1]", argv0);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -56,6 +56,8 @@ main(int argc, char *argv[])
|
|||
|
||||
sflag = 0;
|
||||
ARGBEGIN {
|
||||
case 'v':
|
||||
die("slstatus-"VERSION);
|
||||
case '1':
|
||||
done = 1;
|
||||
/* FALLTHROUGH */
|
||||
|
|
|
@ -31,6 +31,9 @@ const char *hostname(const char *unused);
|
|||
const char *ipv4(const char *interface);
|
||||
const char *ipv6(const char *interface);
|
||||
|
||||
/* kanji */
|
||||
const char *kanji(const char *unused);
|
||||
|
||||
/* kernel_release */
|
||||
const char *kernel_release(const char *unused);
|
||||
|
||||
|
|
Loading…
Reference in New Issue