diff --git a/LICENSE b/LICENSE index 859df8b..9fae663 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ ISC License -Copyright 2016-2026 Aaron Marcher +Copyright 2016-2025 Aaron Marcher Copyright 2016 Roy Freytag Copyright 2016 Vincent Loupmon @@ -21,7 +21,7 @@ Copyright 2018 Ian Remmler Copyright 2016-2019 Joerg Jung Copyright 2019 Ryan Kes Copyright 2019 Cem Keylan -Copyright 2019 Spiros Thanasoulas +Copyright 2019 Dimitris Papastamos Copyright 2019-2022 Ingo Feinerer Copyright 2020 Alexandre Ratchov Copyright 2020 Mart Lubbers diff --git a/components/battery.c b/components/battery.c index f2dc393..1c753f9 100644 --- a/components/battery.c +++ b/components/battery.c @@ -62,7 +62,7 @@ { "Not charging", "o" }, }; size_t i; - char path[PATH_MAX], state[13]; + char path[PATH_MAX], state[12]; if (esnprintf(path, sizeof(path), POWER_SUPPLY_STATUS, bat) < 0) return NULL; @@ -81,7 +81,7 @@ { uintmax_t charge_now, current_now, m, h; double timeleft; - char path[PATH_MAX], state[13]; + char path[PATH_MAX], state[12]; if (esnprintf(path, sizeof(path), POWER_SUPPLY_STATUS, bat) < 0) return NULL; diff --git a/components/battery.o b/components/battery.o deleted file mode 100644 index dea927a..0000000 Binary files a/components/battery.o and /dev/null differ diff --git a/components/cat.o b/components/cat.o deleted file mode 100644 index ffc6a18..0000000 Binary files a/components/cat.o and /dev/null differ diff --git a/components/cpu.o b/components/cpu.o deleted file mode 100644 index 3d5efac..0000000 Binary files a/components/cpu.o and /dev/null differ diff --git a/components/datetime.o b/components/datetime.o deleted file mode 100644 index bedc621..0000000 Binary files a/components/datetime.o and /dev/null differ diff --git a/components/disk.o b/components/disk.o deleted file mode 100644 index b051fdd..0000000 Binary files a/components/disk.o and /dev/null differ diff --git a/components/entropy.o b/components/entropy.o deleted file mode 100644 index 0611d9c..0000000 Binary files a/components/entropy.o and /dev/null differ diff --git a/components/hostname.o b/components/hostname.o deleted file mode 100644 index ed8e54a..0000000 Binary files a/components/hostname.o and /dev/null differ diff --git a/components/ip.o b/components/ip.o deleted file mode 100644 index 7c75c70..0000000 Binary files a/components/ip.o and /dev/null differ diff --git a/components/kernel_release.o b/components/kernel_release.o deleted file mode 100644 index d214b3c..0000000 Binary files a/components/kernel_release.o and /dev/null differ diff --git a/components/keyboard_indicators.o b/components/keyboard_indicators.o deleted file mode 100644 index fddf659..0000000 Binary files a/components/keyboard_indicators.o and /dev/null differ diff --git a/components/keymap.o b/components/keymap.o deleted file mode 100644 index bd690f8..0000000 Binary files a/components/keymap.o and /dev/null differ diff --git a/components/load_avg.o b/components/load_avg.o deleted file mode 100644 index 946966e..0000000 Binary files a/components/load_avg.o and /dev/null differ diff --git a/components/netspeeds.o b/components/netspeeds.o deleted file mode 100644 index ffcb639..0000000 Binary files a/components/netspeeds.o and /dev/null differ diff --git a/components/num_files.o b/components/num_files.o deleted file mode 100644 index 4fdd111..0000000 Binary files a/components/num_files.o and /dev/null differ diff --git a/components/ram.c b/components/ram.c index bf71dcf..15c4b74 100644 --- a/components/ram.c +++ b/components/ram.c @@ -11,45 +11,36 @@ ram_free(const char *unused) { uintmax_t free; - FILE *fp; - if (!(fp = fopen("/proc/meminfo", "r"))) + if (pscanf("/proc/meminfo", + "MemTotal: %ju kB\n" + "MemFree: %ju kB\n" + "MemAvailable: %ju kB\n", + &free, &free, &free) != 3) return NULL; - if (lscanf(fp, "MemFree:", "%ju kB", &free) != 1) { - fclose(fp); - return NULL; - } - - fclose(fp); return fmt_human(free * 1024, 1024); } const char * ram_perc(const char *unused) { - uintmax_t total, free, buffers, cached, shmem, sreclaimable; + uintmax_t total, free, buffers, cached; int percent; - FILE *fp; - if (!(fp = fopen("/proc/meminfo", "r"))) + if (pscanf("/proc/meminfo", + "MemTotal: %ju kB\n" + "MemFree: %ju kB\n" + "MemAvailable: %ju kB\n" + "Buffers: %ju kB\n" + "Cached: %ju kB\n", + &total, &free, &buffers, &buffers, &cached) != 5) return NULL; - if (lscanf(fp, "MemTotal:", "%ju kB", &total) != 1 || - lscanf(fp, "MemFree:", "%ju kB", &free) != 1 || - lscanf(fp, "Buffers:", "%ju kB", &buffers) != 1 || - lscanf(fp, "Cached:", "%ju kB", &cached) != 1 || - lscanf(fp, "Shmem:", "%ju kB", &shmem) != 1 || - lscanf(fp, "SReclaimable:", "%ju kB", &sreclaimable) != 1) { - fclose(fp); - return NULL; - } - fclose(fp); - if (total == 0) return NULL; - percent = 100 * (total - free - buffers - cached - sreclaimable + shmem) / total; + percent = 100 * ((total - free) - (buffers + cached)) / total; return bprintf("%d", percent); } @@ -68,24 +59,18 @@ const char * ram_used(const char *unused) { - uintmax_t total, free, buffers, cached, used, shmem, sreclaimable; - FILE *fp; + uintmax_t total, free, buffers, cached, used; - if (!(fp = fopen("/proc/meminfo", "r"))) + if (pscanf("/proc/meminfo", + "MemTotal: %ju kB\n" + "MemFree: %ju kB\n" + "MemAvailable: %ju kB\n" + "Buffers: %ju kB\n" + "Cached: %ju kB\n", + &total, &free, &buffers, &buffers, &cached) != 5) return NULL; - if (lscanf(fp, "MemTotal:", "%ju kB", &total) != 1 || - lscanf(fp, "MemFree:", "%ju kB", &free) != 1 || - lscanf(fp, "Buffers:", "%ju kB", &buffers) != 1 || - lscanf(fp, "Cached:", "%ju kB", &cached) != 1 || - lscanf(fp, "Shmem:", "%ju kB", &shmem) != 1 || - lscanf(fp, "SReclaimable:", "%ju kB", &sreclaimable) != 1) { - fclose(fp); - return NULL; - } - fclose(fp); - - used = total - free - buffers - cached - sreclaimable + shmem; + used = (total - free - buffers - cached); return fmt_human(used * 1024, 1024); } #elif defined(__OpenBSD__) diff --git a/components/ram.o b/components/ram.o deleted file mode 100644 index a3d7f78..0000000 Binary files a/components/ram.o and /dev/null differ diff --git a/components/run_command.o b/components/run_command.o deleted file mode 100644 index 2beb247..0000000 Binary files a/components/run_command.o and /dev/null differ diff --git a/components/swap.o b/components/swap.o deleted file mode 100644 index acb689c..0000000 Binary files a/components/swap.o and /dev/null differ diff --git a/components/temperature.o b/components/temperature.o deleted file mode 100644 index baa2598..0000000 Binary files a/components/temperature.o and /dev/null differ diff --git a/components/uptime.o b/components/uptime.o deleted file mode 100644 index 63cdc0d..0000000 Binary files a/components/uptime.o and /dev/null differ diff --git a/components/user.o b/components/user.o deleted file mode 100644 index 32644f5..0000000 Binary files a/components/user.o and /dev/null differ diff --git a/components/volume.c b/components/volume.c index 692742a..6cec556 100644 --- a/components/volume.c +++ b/components/volume.c @@ -89,8 +89,6 @@ if (c->addr == addr) break; } - if (c == NULL) - return; c->val = val; } @@ -219,33 +217,3 @@ return bprintf("%d", v & 0xff); } #endif - -const char * -vol_perc_pw(const char *sink) -{ - FILE *fp; - char buf[64], cmd[64]; - double v; - - if (esnprintf(cmd, sizeof(cmd), "wpctl get-volume %s", sink) < 0) - return NULL; - - if (!(fp = popen(cmd, "r"))) { - warn("popen '%s':", cmd); - return NULL; - } - - if (!fgets(buf, sizeof(buf), fp)) { - pclose(fp); - return NULL; - } - pclose(fp); - - if (strstr(buf, "[MUTED]")) - return "mute"; - - if (sscanf(buf, "Volume: %lf", &v) != 1) - return NULL; - - return bprintf("%d%%", (int)(v * 100 + 0.5)); -} diff --git a/components/volume.o b/components/volume.o deleted file mode 100644 index a63a146..0000000 Binary files a/components/volume.o and /dev/null differ diff --git a/components/wifi.c b/components/wifi.c index 8b33baa..23af201 100644 --- a/components/wifi.c +++ b/components/wifi.c @@ -110,10 +110,10 @@ } if (strcmp(ifr.ifr_name, interface) != 0) { strcpy(ifr.ifr_name, interface); - } - if (ioctl(ifsock, SIOCGIFINDEX, &ifr) != 0) { - warn("ioctl 'SIOCGIFINDEX':"); - return -1; + if (ioctl(ifsock, SIOCGIFINDEX, &ifr) != 0) { + warn("ioctl 'SIOCGIFINDEX':"); + return -1; + } } return ifr.ifr_ifindex; } diff --git a/components/wifi.o b/components/wifi.o deleted file mode 100644 index ab8776a..0000000 Binary files a/components/wifi.o and /dev/null differ diff --git a/config.def.h b/config.def.h index 557a9d6..100093e 100644 --- a/config.def.h +++ b/config.def.h @@ -65,9 +65,6 @@ static const char unknown_str[] = "n/a"; * wifi_perc WiFi signal in percent interface name (wlan0) */ static const struct arg args[] = { - /* function format argument */ - { wifi_perc, " wifi %s%% |", "wlan0" }, - { battery_perc, " bat %s%% |", "BAT0" }, - { vol_perc_pw, " vol %s |", "@DEFAULT_AUDIO_SINK@" }, - { datetime, " %s", "%F %T" }, + /* function format argument */ + { datetime, "%s", "%F %T" }, }; diff --git a/config.h b/config.h deleted file mode 100644 index e39941e..0000000 --- a/config.h +++ /dev/null @@ -1,74 +0,0 @@ -/* 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) - * 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 - * up interface is running interface name (eth0) - * 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 */ - {run_command, "%s | ", "playerctl metadata --player=spotify --format '{{artist}} - {{title}}'"}, - {battery_perc, " bat %s%%", "BAT0"}, - {battery_state, "%s |", "BAT0"}, - {vol_perc_pw, " vol %s |", "@DEFAULT_AUDIO_SINK@"}, - {datetime, " %s", "%d.%m.%Y | %H:%M"}, -}; diff --git a/slstatus b/slstatus deleted file mode 100755 index 53cd485..0000000 Binary files a/slstatus and /dev/null differ diff --git a/slstatus.h b/slstatus.h index d58dda9..394281c 100644 --- a/slstatus.h +++ b/slstatus.h @@ -79,7 +79,6 @@ const char *username(const char *unused); /* volume */ const char *vol_perc(const char *card); -const char *vol_perc_pw(const char *sink); /* wifi */ const char *wifi_essid(const char *interface); diff --git a/slstatus.o b/slstatus.o deleted file mode 100644 index b541cd5..0000000 Binary files a/slstatus.o and /dev/null differ diff --git a/util.c b/util.c index d33cf9d..bca9b2e 100644 --- a/util.c +++ b/util.c @@ -139,20 +139,3 @@ pscanf(const char *path, const char *fmt, ...) return (n == EOF) ? -1 : n; } - -int -lscanf(FILE *fp, const char *key, const char *fmt, void *res) -{ - int n; - char line[256]; - - n = -1; - while (fgets(line, sizeof(line), fp)) - if (strncmp(line, key, strlen(key)) == 0) { - n = sscanf(line + strlen(key), fmt, res); - break; - } - - rewind(fp); - return (n == 1) ? 1 : -1; -} diff --git a/util.h b/util.h index 7a960aa..cf4b027 100644 --- a/util.h +++ b/util.h @@ -1,6 +1,5 @@ /* See LICENSE file for copyright and license details. */ #include -#include extern char buf[1024]; @@ -15,4 +14,3 @@ int esnprintf(char *str, size_t size, const char *fmt, ...); const char *bprintf(const char *fmt, ...); const char *fmt_human(uintmax_t num, int base); int pscanf(const char *path, const char *fmt, ...); -int lscanf(FILE *fp, const char *key, const char *fmt, void *res); diff --git a/util.o b/util.o deleted file mode 100644 index 1c4a2f0..0000000 Binary files a/util.o and /dev/null differ