From 7de30ddd9d2711f84f051a803d039e4757b4b3b2 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Sat, 20 Feb 2021 15:53:53 +0100 Subject: [PATCH] Remove slstatus --- .suckless/slstatus/LICENSE | 34 --- .suckless/slstatus/Makefile | 67 ----- .suckless/slstatus/README | 63 ---- .suckless/slstatus/arg.h | 33 -- .suckless/slstatus/components/battery.c | 251 ---------------- .suckless/slstatus/components/battery.o | Bin 5184 -> 0 bytes .suckless/slstatus/components/cpu.c | 164 ---------- .suckless/slstatus/components/cpu.o | Bin 3192 -> 0 bytes .suckless/slstatus/components/datetime.c | 19 -- .suckless/slstatus/components/datetime.o | Bin 1992 -> 0 bytes .suckless/slstatus/components/disk.c | 58 ---- .suckless/slstatus/components/disk.o | Bin 3192 -> 0 bytes .suckless/slstatus/components/entropy.c | 27 -- .suckless/slstatus/components/entropy.o | Bin 1848 -> 0 bytes .suckless/slstatus/components/hostname.c | 16 - .suckless/slstatus/components/hostname.o | Bin 1704 -> 0 bytes .suckless/slstatus/components/ip.c | 60 ---- .suckless/slstatus/components/ip.o | Bin 2608 -> 0 bytes .../slstatus/components/kernel_release.c | 18 -- .../slstatus/components/kernel_release.o | Bin 1880 -> 0 bytes .../slstatus/components/keyboard_indicators.c | 48 --- .../slstatus/components/keyboard_indicators.o | Bin 2448 -> 0 bytes .suckless/slstatus/components/keymap.c | 87 ------ .suckless/slstatus/components/keymap.o | Bin 4104 -> 0 bytes .suckless/slstatus/components/load_avg.c | 18 -- .suckless/slstatus/components/load_avg.o | Bin 1912 -> 0 bytes .suckless/slstatus/components/netspeeds.c | 139 --------- .suckless/slstatus/components/netspeeds.o | Bin 2784 -> 0 bytes .suckless/slstatus/components/num_files.c | 31 -- .suckless/slstatus/components/num_files.o | Bin 2200 -> 0 bytes .suckless/slstatus/components/ram.c | 222 -------------- .suckless/slstatus/components/ram.o | Bin 3136 -> 0 bytes .suckless/slstatus/components/run_command.c | 30 -- .suckless/slstatus/components/run_command.o | Bin 2200 -> 0 bytes .suckless/slstatus/components/swap.c | 284 ------------------ .suckless/slstatus/components/swap.o | Bin 3952 -> 0 bytes .suckless/slstatus/components/temperature.c | 71 ----- .suckless/slstatus/components/temperature.o | Bin 1760 -> 0 bytes .suckless/slstatus/components/uptime.c | 33 -- .suckless/slstatus/components/uptime.o | Bin 2016 -> 0 bytes .suckless/slstatus/components/user.c | 32 -- .suckless/slstatus/components/user.o | Bin 2240 -> 0 bytes .suckless/slstatus/components/volume.c | 109 ------- .suckless/slstatus/components/volume.o | Bin 3624 -> 0 bytes .suckless/slstatus/components/wifi.c | 272 ----------------- .suckless/slstatus/components/wifi.o | Bin 4400 -> 0 bytes .suckless/slstatus/config.def.h | 67 ----- .suckless/slstatus/config.h | 70 ----- .suckless/slstatus/config.mk | 20 -- .suckless/slstatus/slstatus.1 | 25 -- .suckless/slstatus/slstatus.c | 137 --------- .suckless/slstatus/slstatus.h | 81 ----- .suckless/slstatus/util.c | 146 --------- .suckless/slstatus/util.h | 16 - 54 files changed, 2748 deletions(-) delete mode 100644 .suckless/slstatus/LICENSE delete mode 100644 .suckless/slstatus/Makefile delete mode 100644 .suckless/slstatus/README delete mode 100644 .suckless/slstatus/arg.h delete mode 100644 .suckless/slstatus/components/battery.c delete mode 100644 .suckless/slstatus/components/battery.o delete mode 100644 .suckless/slstatus/components/cpu.c delete mode 100644 .suckless/slstatus/components/cpu.o delete mode 100644 .suckless/slstatus/components/datetime.c delete mode 100644 .suckless/slstatus/components/datetime.o delete mode 100644 .suckless/slstatus/components/disk.c delete mode 100644 .suckless/slstatus/components/disk.o delete mode 100644 .suckless/slstatus/components/entropy.c delete mode 100644 .suckless/slstatus/components/entropy.o delete mode 100644 .suckless/slstatus/components/hostname.c delete mode 100644 .suckless/slstatus/components/hostname.o delete mode 100644 .suckless/slstatus/components/ip.c delete mode 100644 .suckless/slstatus/components/ip.o delete mode 100644 .suckless/slstatus/components/kernel_release.c delete mode 100644 .suckless/slstatus/components/kernel_release.o delete mode 100644 .suckless/slstatus/components/keyboard_indicators.c delete mode 100644 .suckless/slstatus/components/keyboard_indicators.o delete mode 100644 .suckless/slstatus/components/keymap.c delete mode 100644 .suckless/slstatus/components/keymap.o delete mode 100644 .suckless/slstatus/components/load_avg.c delete mode 100644 .suckless/slstatus/components/load_avg.o delete mode 100644 .suckless/slstatus/components/netspeeds.c delete mode 100644 .suckless/slstatus/components/netspeeds.o delete mode 100644 .suckless/slstatus/components/num_files.c delete mode 100644 .suckless/slstatus/components/num_files.o delete mode 100644 .suckless/slstatus/components/ram.c delete mode 100644 .suckless/slstatus/components/ram.o delete mode 100644 .suckless/slstatus/components/run_command.c delete mode 100644 .suckless/slstatus/components/run_command.o delete mode 100644 .suckless/slstatus/components/swap.c delete mode 100644 .suckless/slstatus/components/swap.o delete mode 100644 .suckless/slstatus/components/temperature.c delete mode 100644 .suckless/slstatus/components/temperature.o delete mode 100644 .suckless/slstatus/components/uptime.c delete mode 100644 .suckless/slstatus/components/uptime.o delete mode 100644 .suckless/slstatus/components/user.c delete mode 100644 .suckless/slstatus/components/user.o delete mode 100644 .suckless/slstatus/components/volume.c delete mode 100644 .suckless/slstatus/components/volume.o delete mode 100644 .suckless/slstatus/components/wifi.c delete mode 100644 .suckless/slstatus/components/wifi.o delete mode 100644 .suckless/slstatus/config.def.h delete mode 100644 .suckless/slstatus/config.h delete mode 100644 .suckless/slstatus/config.mk delete mode 100644 .suckless/slstatus/slstatus.1 delete mode 100644 .suckless/slstatus/slstatus.c delete mode 100644 .suckless/slstatus/slstatus.h delete mode 100644 .suckless/slstatus/util.c delete mode 100644 .suckless/slstatus/util.h diff --git a/.suckless/slstatus/LICENSE b/.suckless/slstatus/LICENSE deleted file mode 100644 index 0eec587..0000000 --- a/.suckless/slstatus/LICENSE +++ /dev/null @@ -1,34 +0,0 @@ -ISC License - -Copyright 2016-2019 Aaron Marcher - -Copyright 2016 Roy Freytag -Copyright 2016 Vincent Loupmon -Copyright 2016 Daniel Walter -Copyright 2016-2018 Ali H. Fardan -Copyright 2016 Jody Leonard -Copyright 2016-2018 Quentin Rameau -Copyright 2016 Mike Coddington -Copyright 2016-2018 parazyd -Copyright 2017 Tobias Stoeckmann -Copyright 2017-2018 Laslo Hunhold -Copyright 2018 Darron Anderson -Copyright 2018 Josuah Demangeon -Copyright 2018 Tobias Tschinkowitz -Copyright 2018 David Demelier -Copyright 2018-2019 Michael Buch -Copyright 2018 Ian Remmler -Copyright 2016-2019 Joerg Jung -Copyright 2019 Ingo Feinerer - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/.suckless/slstatus/Makefile b/.suckless/slstatus/Makefile deleted file mode 100644 index 945b5e3..0000000 --- a/.suckless/slstatus/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# See LICENSE file for copyright and license details -# slstatus - suckless status monitor -.POSIX: - -include config.mk - -REQ = util -COM =\ - components/battery\ - 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.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) - -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) \ - slstatus.1 "slstatus-$(VERSION)" - 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" diff --git a/.suckless/slstatus/README b/.suckless/slstatus/README deleted file mode 100644 index d55f23b..0000000 --- a/.suckless/slstatus/README +++ /dev/null @@ -1,63 +0,0 @@ -slstatus - suckless status -========================== -slstatus is a suckless status monitor for window managers that use WM_NAME -(e.g. dwm) or stdin to fill the status bar. - - -Features --------- -- Battery percentage/state/time left -- 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) -- 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 (OSS/ALSA) -- 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. - - -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. - - -Todo ----- -Cleaning up the whole codebase it the goal before thinking about a release. diff --git a/.suckless/slstatus/arg.h b/.suckless/slstatus/arg.h deleted file mode 100644 index e0adb9f..0000000 --- a/.suckless/slstatus/arg.h +++ /dev/null @@ -1,33 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#ifndef ARG_H -#define ARG_H - -extern char *argv0; - -/* int main(int argc, char *argv[]) */ -#define ARGBEGIN for (argv0 = *argv, *argv ? (argc--, argv++) : ((void *)0); \ - *argv && (*argv)[0] == '-' && (*argv)[1]; argc--, argv++) { \ - int i_, argused_; \ - if ((*argv)[1] == '-' && !(*argv)[2]) { \ - argc--, argv++; \ - break; \ - } \ - for (i_ = 1, argused_ = 0; (*argv)[i_]; i_++) { \ - switch((*argv)[i_]) -#define ARGEND if (argused_) { \ - if ((*argv)[i_ + 1]) { \ - break; \ - } else { \ - argc--, argv++; \ - break; \ - } \ - } \ - } \ - } -#define ARGC() ((*argv)[i_]) -#define ARGF_(x) (((*argv)[i_ + 1]) ? (argused_ = 1, &((*argv)[i_ + 1])) : \ - (*(argv + 1)) ? (argused_ = 1, *(argv + 1)) : (x)) -#define EARGF(x) ARGF_(((x), exit(1), (char *)0)) -#define ARGF() ARGF_((char *)0) - -#endif diff --git a/.suckless/slstatus/components/battery.c b/.suckless/slstatus/components/battery.c deleted file mode 100644 index 07b6ac1..0000000 --- a/.suckless/slstatus/components/battery.c +++ /dev/null @@ -1,251 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include - -#include "../util.h" - -#if defined(__linux__) - #include - #include - #include - - static const char * - pick(const char *bat, const char *f1, const char *f2, char *path, - size_t length) - { - if (esnprintf(path, length, f1, bat) > 0 && - access(path, R_OK) == 0) { - return f1; - } - - if (esnprintf(path, length, f2, bat) > 0 && - access(path, R_OK) == 0) { - return f2; - } - - return NULL; - } - - const char * - battery_perc(const char *bat) - { - int perc; - char path[PATH_MAX]; - - if (esnprintf(path, sizeof(path), - "/sys/class/power_supply/%s/capacity", bat) < 0) { - return NULL; - } - if (pscanf(path, "%d", &perc) != 1) { - return NULL; - } - - return bprintf("%d", perc); - } - - const char * - battery_state(const char *bat) - { - static struct { - char *state; - char *symbol; - } map[] = { - { "Charging", "+" }, - { "Discharging", "-" }, - }; - size_t i; - char path[PATH_MAX], state[12]; - - if (esnprintf(path, sizeof(path), - "/sys/class/power_supply/%s/status", bat) < 0) { - return NULL; - } - if (pscanf(path, "%12s", state) != 1) { - return NULL; - } - - for (i = 0; i < LEN(map); i++) { - if (!strcmp(map[i].state, state)) { - break; - } - } - return (i == LEN(map)) ? "?" : map[i].symbol; - } - - const char * - battery_remaining(const char *bat) - { - uintmax_t charge_now, current_now, m, h; - double timeleft; - char path[PATH_MAX], state[12]; - - if (esnprintf(path, sizeof(path), - "/sys/class/power_supply/%s/status", bat) < 0) { - return NULL; - } - if (pscanf(path, "%12s", state) != 1) { - return NULL; - } - - if (!pick(bat, "/sys/class/power_supply/%s/charge_now", - "/sys/class/power_supply/%s/energy_now", path, - sizeof(path)) || - pscanf(path, "%ju", &charge_now) < 0) { - return NULL; - } - - if (!strcmp(state, "Discharging")) { - if (!pick(bat, "/sys/class/power_supply/%s/current_now", - "/sys/class/power_supply/%s/power_now", path, - sizeof(path)) || - pscanf(path, "%ju", ¤t_now) < 0) { - return NULL; - } - - if (current_now == 0) { - return NULL; - } - - timeleft = (double)charge_now / (double)current_now; - h = timeleft; - m = (timeleft - (double)h) * 60; - - return bprintf("%juh %jum", h, m); - } - - return ""; - } -#elif defined(__OpenBSD__) - #include - #include - #include - #include - - static int - load_apm_power_info(struct apm_power_info *apm_info) - { - int fd; - - fd = open("/dev/apm", O_RDONLY); - if (fd < 0) { - warn("open '/dev/apm':"); - return 0; - } - - memset(apm_info, 0, sizeof(struct apm_power_info)); - if (ioctl(fd, APM_IOC_GETPOWER, apm_info) < 0) { - warn("ioctl 'APM_IOC_GETPOWER':"); - close(fd); - return 0; - } - return close(fd), 1; - } - - const char * - battery_perc(const char *unused) - { - struct apm_power_info apm_info; - - if (load_apm_power_info(&apm_info)) { - return bprintf("%d", apm_info.battery_life); - } - - return NULL; - } - - const char * - battery_state(const char *unused) - { - struct { - unsigned int state; - char *symbol; - } map[] = { - { APM_AC_ON, "+" }, - { APM_AC_OFF, "-" }, - }; - struct apm_power_info apm_info; - size_t i; - - if (load_apm_power_info(&apm_info)) { - for (i = 0; i < LEN(map); i++) { - if (map[i].state == apm_info.ac_state) { - break; - } - } - return (i == LEN(map)) ? "?" : map[i].symbol; - } - - return NULL; - } - - const char * - battery_remaining(const char *unused) - { - struct apm_power_info apm_info; - - if (load_apm_power_info(&apm_info)) { - if (apm_info.ac_state != APM_AC_ON) { - return bprintf("%uh %02um", - apm_info.minutes_left / 60, - apm_info.minutes_left % 60); - } else { - return ""; - } - } - - return NULL; - } -#elif defined(__FreeBSD__) - #include - - const char * - battery_perc(const char *unused) - { - int cap; - size_t len; - - len = sizeof(cap); - if (sysctlbyname("hw.acpi.battery.life", &cap, &len, NULL, 0) == -1 - || !len) - return NULL; - - return bprintf("%d", cap); - } - - const char * - battery_state(const char *unused) - { - int state; - size_t len; - - len = sizeof(state); - if (sysctlbyname("hw.acpi.battery.state", &state, &len, NULL, 0) == -1 - || !len) - return NULL; - - switch(state) { - case 0: - case 2: - return "+"; - case 1: - return "-"; - default: - return "?"; - } - } - - const char * - battery_remaining(const char *unused) - { - int rem; - size_t len; - - len = sizeof(rem); - if (sysctlbyname("hw.acpi.battery.time", &rem, &len, NULL, 0) == -1 - || !len - || rem == -1) - return NULL; - - return bprintf("%uh %02um", rem / 60, rem % 60); - } -#endif diff --git a/.suckless/slstatus/components/battery.o b/.suckless/slstatus/components/battery.o deleted file mode 100644 index 1c276dfb0b8c59189e0c4ad3e902a7b0c685d326..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5184 zcmbuCe{2**6vyZ8iWIGThoBzdk3(B6Qm$Qo`76p@OX;E)DAE!^@VdQTY2|u%x!s1= z7zvgl8>m12^A8hE^bdl@7)^}Pgq+31ia*k-F^VK28U>ChRAZtM>wB{^cdvVQ5OtcH zo&C)By?OIyc6Pg~IkLv>axqz4>|R#5la#TLkF|xja-cb*iLt!^}&c;+Wv}~TJCXAbtM2btBoY8D+>b* zR;bxr9pbj?3T3+pUE6)O))|eTM-v(8s`f{$pF{?DG}|%6Dh!E71HGDch6^B|Z#C;@5s$DjYaA$S zf$0p4xOq6+Kksc^#+)1cy>|kp!gHkUU+u2MiC`2ZCW6sIVvmF|uXHN7zJK9-8l3Y% z6Fa-LGJnI_!I^6I^wSVP1g3Odeo7#S6sB}sgUuk~%1`;!D;K7wwBf9I7_Hi1$)>N( zaCYG3e1hx^G;QAAVLuF8((?w}vv*I&)YO#i-B;w@yRQ*?Ay3slh{C&PIlsd=hCdsa zIjMPX8_ivuQ|wSy4Wgq5ust~X1~E|)TIV%>d`aXdz0JQ>Ruxz+ZQvAC*zszgVAJa=fzaq zRh+A89_hcB(w@bo-1TQN@uVsJ^#s6aA6v|p-~;u4%ZVo2!@3Y_X==JFP}{PueNjMd z2rdma*gbQ_5UxibV6Fk5YeCh_%4c9FF9&{|=-Y+YM#VScZc+RPJgb$!-ij8bc4)@^ zN`rfoQVSrg_(9O9R0crWhI%LmunH@_y&!rq;5HOrSg8b53%>#EgYpqpV0ysas`&SM zT9jc4@xyZ`L>|VUnrSAOV;8$D&jR@tj$7aa1INr17Z1C<7y|JyjB0whiQg8- zbF1Lh)8(vA@I?-;3Vy$XuN1u1!S5D)vxA2Ox5qDZHVfWeK)iLI;CzpfzV(8?K^QjM z1&=%U7Qx?g@D9Phad111;`}GLuCi!lGQy7=H=d(-*enOJp9?q$V>l9Bzh=$G=C){CxG~ZkWpN{!&h#eDZl=d#al??&Mbq&N1Zc$cWH;*+l4um( zHnAPiSkI1Vx89q`i}58CXNH-H^`-ML6YtY|llVH~rN+MS6XXVH{{`=REcce-8wkIV z=zGiXy@I>pT1E8oxxkZ)jyp#5R}%fW;HY0n__uFe3%$0&O9s<94|Bv%ZYv=^vQ7>iGB{@YYE410jcjI9KReTPn7Y$ljv#Q zb`d?zvqkjR5dY5;el6iI5$-2^lyDm7QNf-2cA0pUWA{AbXE)*V34e+31%w|G+_}$3 z3BQ@>p~(v_^JVaBwQuw93(2d*K9Fa<E=#*`$8xr=EVcV%45{y2psM{y( zzrq_*WZV)x4vkXzYsHrVln!3o`NJ(K?dAT%c${OSNe3ny%0aQPxE$BR&uNceu0jH> bLa7x0g8W)Qyycufz9UN6zb@h*xrF^cYBk~t diff --git a/.suckless/slstatus/components/cpu.c b/.suckless/slstatus/components/cpu.c deleted file mode 100644 index 9e28003..0000000 --- a/.suckless/slstatus/components/cpu.c +++ /dev/null @@ -1,164 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include - -#include "../util.h" - -#if defined(__linux__) - const char * - cpu_freq(void) - { - uintmax_t freq; - - /* in kHz */ - if (pscanf("/sys/devices/system/cpu/cpu0/cpufreq/" - "scaling_cur_freq", "%ju", &freq) != 1) { - return NULL; - } - - return fmt_human(freq * 1000, 1000); - } - - const char * - cpu_perc(void) - { - static long double a[7]; - long double b[7], sum; - - memcpy(b, a, sizeof(b)); - /* cpu user nice system idle iowait irq softirq */ - if (pscanf("/proc/stat", "%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf", - &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6]) - != 7) { - return NULL; - } - if (b[0] == 0) { - return NULL; - } - - sum = (b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6]) - - (a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6]); - - if (sum == 0) { - return NULL; - } - - return bprintf("%d", (int)(100 * - ((b[0] + b[1] + b[2] + b[5] + b[6]) - - (a[0] + a[1] + a[2] + a[5] + a[6])) / sum)); - } -#elif defined(__OpenBSD__) - #include - #include - #include - - const char * - cpu_freq(void) - { - int freq, mib[2]; - size_t size; - - mib[0] = CTL_HW; - mib[1] = HW_CPUSPEED; - - size = sizeof(freq); - - /* in MHz */ - if (sysctl(mib, 2, &freq, &size, NULL, 0) < 0) { - warn("sysctl 'HW_CPUSPEED':"); - return NULL; - } - - return fmt_human(freq * 1E6, 1000); - } - - const char * - cpu_perc(void) - { - int mib[2]; - static uintmax_t a[CPUSTATES]; - uintmax_t b[CPUSTATES], sum; - size_t size; - - mib[0] = CTL_KERN; - mib[1] = KERN_CPTIME; - - size = sizeof(a); - - memcpy(b, a, sizeof(b)); - if (sysctl(mib, 2, &a, &size, NULL, 0) < 0) { - warn("sysctl 'KERN_CPTIME':"); - return NULL; - } - if (b[0] == 0) { - return NULL; - } - - sum = (a[CP_USER] + a[CP_NICE] + a[CP_SYS] + a[CP_INTR] + a[CP_IDLE]) - - (b[CP_USER] + b[CP_NICE] + b[CP_SYS] + b[CP_INTR] + b[CP_IDLE]); - - if (sum == 0) { - return NULL; - } - - return bprintf("%d", 100 * - ((a[CP_USER] + a[CP_NICE] + a[CP_SYS] + - a[CP_INTR]) - - (b[CP_USER] + b[CP_NICE] + b[CP_SYS] + - b[CP_INTR])) / sum); - } -#elif defined(__FreeBSD__) - #include - #include - #include - - const char * - cpu_freq(void) - { - int freq; - size_t size; - - size = sizeof(freq); - /* in MHz */ - if (sysctlbyname("hw.clockrate", &freq, &size, NULL, 0) == -1 - || !size) { - warn("sysctlbyname 'hw.clockrate':"); - return NULL; - } - - return fmt_human(freq * 1E6, 1000); - } - - const char * - cpu_perc(void) - { - size_t size; - static long a[CPUSTATES]; - long b[CPUSTATES], sum; - - size = sizeof(a); - memcpy(b, a, sizeof(b)); - if (sysctlbyname("kern.cp_time", &a, &size, NULL, 0) == -1 - || !size) { - warn("sysctlbyname 'kern.cp_time':"); - return NULL; - } - if (b[0] == 0) { - return NULL; - } - - sum = (a[CP_USER] + a[CP_NICE] + a[CP_SYS] + a[CP_INTR] + a[CP_IDLE]) - - (b[CP_USER] + b[CP_NICE] + b[CP_SYS] + b[CP_INTR] + b[CP_IDLE]); - - if (sum == 0) { - return NULL; - } - - return bprintf("%d", 100 * - ((a[CP_USER] + a[CP_NICE] + a[CP_SYS] + - a[CP_INTR]) - - (b[CP_USER] + b[CP_NICE] + b[CP_SYS] + - b[CP_INTR])) / sum); - } -#endif diff --git a/.suckless/slstatus/components/cpu.o b/.suckless/slstatus/components/cpu.o deleted file mode 100644 index f67460cc5d88627a9297b067b765ee964e44ac13..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3192 zcmb7FO>7%g5Pr5>V%pR(p@={$)rU2t(5~Zoy%l?aig95^5$AtWw2Z~)Gzb$$*7aR9`@k%?6*Ath>6(OVBlVP^M@vw5*4nALkT z^SzmQ^XC2R$MM9l*W+PC9`-WZ)d*$mp?_D7*`53!_ojr2b3s#E>$v>ey-)g&B2kil6e!XK& zxq5F2qm>R~6h2q=w4>NFR%fNO1AuhCE-7{COkL`%OC5E|Kc>uY1$kFeeo;zeno7O{KJ;E>o-7v!Liy3^fBn|{G6UN z;(RP4bye2EI%N9<|5&M>l4`3PKf)S?Td}7PHpQ`8L#rkfzF1@tbHe5NVD?)BY-DioY^ZbO)i+LtqFr*g+{M^Yo|otH zYs_;g=sDKf;$MOTjQDXrmP9@j2zlQN_)me@!|{1M=p%v8J>Cm}uRQUu6i$>1hw5& zXM2wU>xSm!y4PN5f{!-A-)@3m1RUq3`Rp?UnAyah!TFbUroma26N7daMX4LR7qEK~ zyI!<&?u9y%7#-+OsH4NfugA}+=lTZ{ah2ua{^U|Dm9^A#F{|a6s>0RKr&K*XrKYsW zj2$3v6m*u%7bbI73K9aM%6UOP1nr+4hXObVggEXw;m;rlg!}wBG{R#bBO#7=i*T$H z65@Ck2+tr0gz<6g0xCdQCnUsMp^^Ozf z;P?(8Ejz4k-^cau1w6s^9|WA%b%*1ai@R=5;X?r=uIq$=Q~u8iIOQJ^aLT7wz$u^e z0#5547w|qOJ$B87=20205?6K8>S3}zoy{6Ku+L3fh73Q7)Al6+ zD-30%;f85h@#&#V{ud8{HI_hpv0{KB{l)9!XpSw($d5t8+Qp!`={A3Q^SpR?H!&2w z;2qo;?8{YCRK2gcn&L8kp9 z7@y}x`#;7FX -#include - -#include "../util.h" - -const char * -datetime(const char *fmt) -{ - time_t t; - - t = time(NULL); - if (!strftime(buf, sizeof(buf), fmt, localtime(&t))) { - warn("strftime: Result string exceeds buffer size"); - return NULL; - } - - return buf; -} diff --git a/.suckless/slstatus/components/datetime.o b/.suckless/slstatus/components/datetime.o deleted file mode 100644 index 600a682d53df5e75bfa8daf5b3ec83e5d0acfb4d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1992 zcmbu8&ubGw6vtnF)JARNsujd~*h7_yI&^!n1guGFn+>cMYD9$UvPmW;G(RM}#oB`& zieRV({}lg%64AfJi$%P6uf+FuXVP)Ax#%}c=FR8*nB~pP+f{2V9*cog43^AgDZPjdyjovC9DpD=Qg&zVPtz4c%B^i)?|moS{EdY%cr#u@nTw!zf5cSbc#@vsCP;DHHh*hB0CF^z+aRS)T{_4!0*V7OLoxSt%X7-Wum{0hmsXcI9p>>J4;XgW0akWhVBHQa zDBNHMuu7-Z;%y9RcRbGU_1*THhjEn6>vpZ{V3+?_Iu@X}7rwb!WF&cCgH;eKZJK9s zP_ME$RGH#w_60nHGwmZ^)Mdf13m$&Shr%D8sD`RrxS*Q5b}BU=*te-iUqWU>aD!@8%@4xb(Qk3`XDv`{3<4GF!)sC->~e|;Dk H7~%Xs&-T=n diff --git a/.suckless/slstatus/components/disk.c b/.suckless/slstatus/components/disk.c deleted file mode 100644 index 15a221b..0000000 --- a/.suckless/slstatus/components/disk.c +++ /dev/null @@ -1,58 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include - -#include "../util.h" - -const char * -disk_free(const char *path) -{ - struct statvfs fs; - - if (statvfs(path, &fs) < 0) { - warn("statvfs '%s':", path); - return NULL; - } - - return fmt_human(fs.f_frsize * fs.f_bavail, 1024); -} - -const char * -disk_perc(const char *path) -{ - struct statvfs fs; - - if (statvfs(path, &fs) < 0) { - warn("statvfs '%s':", path); - return NULL; - } - - return bprintf("%d", (int)(100 * - (1.0f - ((float)fs.f_bavail / (float)fs.f_blocks)))); -} - -const char * -disk_total(const char *path) -{ - struct statvfs fs; - - if (statvfs(path, &fs) < 0) { - warn("statvfs '%s':", path); - return NULL; - } - - return fmt_human(fs.f_frsize * fs.f_blocks, 1024); -} - -const char * -disk_used(const char *path) -{ - struct statvfs fs; - - if (statvfs(path, &fs) < 0) { - warn("statvfs '%s':", path); - return NULL; - } - - return fmt_human(fs.f_frsize * (fs.f_blocks - fs.f_bfree), 1024); -} diff --git a/.suckless/slstatus/components/disk.o b/.suckless/slstatus/components/disk.o deleted file mode 100644 index e95f5571abb7fcaee7db51650e0eb62cafe5a6b5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3192 zcmcIl&2Jk;6d%V)<3j2+p%E5EXb%oGv|Yt15>my7^SwxhN^OEb0+x-vmP2AE@@|5Q zBGo7=!ZMY5gi8-S_16CYnZO|+4)oAFM+69|@})wc@_yqP^15ClRN!aL?#%Cf&Aj(! zeR-j)vfIOxSrXW-`Aj3%v9AW1 z#E($C(z!H2>(;OK)t9iAWUlk`gx%iFq-^8XZYKMM7*+ziy_{*3>{G|3vtUGO+k3w> z-}&m{L+#k@`ApWn(rJu#ZR0t_Ztd^=5VLRpWFOrJwcj<~>_991m)1eQ*0-efP1kt$ z%dU|+hO?+6ASscw+r$tWB=t@SlZJ6bK0Inh0^w^-Ha(C$y%k< z(FT^u58PmUSE0E%uQL-)|3#(AtuB=ydYwY zRP4mqXyO_*ph?_Q5D?b!m`SES9$HFXiw(KS)J!r#lu08`1NaV)L!EuDBey`}zw`46 z>p|;~JKe9H&Jwqc!Ba9b`h~no5@UITwFAm_* zBiN7LhwLZfY6J9ll>Q570D`vri01HfL-Deopio-#*R7(k3UgC<CA;z^&Irxf(c??W$W7jzfatx>KyIJ7srmqvvPK zs~5%UR(-7&lzU9D8MsQg?R)AnJdHgO&~eD?@ArGKKoW*%pj$M579;`skI~S40VDxD zdPDOrNCNoBX=uI$k`Rvjd5`XkdtLG2xW6&|M`*77>%TJW|53&psvh9S7@t-={7*3c z4CDF!R~XOp<}v>~Z|^gGp0_>5^Sph=cpkUIcpmqA#fR&4hw1aUUB>gc2{<5x>t#x| z*AGfXGV>u`_kShC>-+I(h}ZW+SpKDI;I7g;sQ2C#J*#^gt`&HVKv*R=aD}z%`@*Vk zVgdD>MYl*Ti+=FDu!@`2s#hcZ+GgNc^ha|>UJ=rQE3ZPg%&mHAEC1?ck~LBp{sQNT z1IBr>XsyyNWq6#Rfn4WlaNJX$;;gbq55rb}(bGy9-%0S{f07HKxJtb*{%I1x=fm3P z$QJRZX>jQH=s6C3e*Mmq5Oee(M@j8ppI6I}D?qkxXGQ;Jba!qaZ&X*mEwEK9`(ofMBD57N5zIoRuwd__JMC5{;R|G f@ENW>QKF*yuZ;ymI9I4|lzmeL+Ge(xhVB0Z?!x!w diff --git a/.suckless/slstatus/components/entropy.c b/.suckless/slstatus/components/entropy.c deleted file mode 100644 index 2a485de..0000000 --- a/.suckless/slstatus/components/entropy.c +++ /dev/null @@ -1,27 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#if defined(__linux__) - #include - #include - - #include "../util.h" - - const char * - entropy(void) - { - uintmax_t num; - - if (pscanf("/proc/sys/kernel/random/entropy_avail", "%ju", &num) - != 1) { - return NULL; - } - - return bprintf("%ju", num); - } -#elif defined(__OpenBSD__) | defined(__FreeBSD__) - const char * - entropy(void) - { - /* Unicode Character 'INFINITY' (U+221E) */ - return "\xe2\x88\x9e"; - } -#endif diff --git a/.suckless/slstatus/components/entropy.o b/.suckless/slstatus/components/entropy.o deleted file mode 100644 index 1234758d29eef39d4aa7d50f1d5261cdb6d79c54..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1848 zcmbW1&2JJx6u=+QT2zYom5@{u4%F1IfvtL}(eP1VO^8iwd+5c@0!yfTW_N4AizYo0 z(uBXjzlB5({U5v-Pd#|?=D`Ht+nu4)Wx4bvkN4&`@4cCQGsEXXxfl!tKu7>y!}&;1 zfWM)0KjXL=ScM3v$G_w1$qORt$tyB7b+oj;LF3_eGOSG0;jc5|+2KT)WT&S`F?IAj z$%CC4byQA)xd{Xz-;NQNnkFTNu#%sIVA&62m6Zj2e!JJ5$oV=k&iz&n!IioCcahwZ zzRT$mviqoRt&1to7VxbFJhy-YKUP)+R?esCM-dFPQh6trEo(c);%;G2+so$41r2&u zRqxcH(lZY`b{#a$vh`|Ht2UZi-MJdHQ_;a7`qZ_5Q&*xii9-A;s^AX@qENq9Q3ZcV z5XD<3<4`xAYKr)MiQkZTf^(`vIum9M+O}Q+X4$4|8^SYvU~{;d^-Mv;*TP+h}NYQ*Rry -#include - -#include "../util.h" - -const char * -hostname(void) -{ - if (gethostname(buf, sizeof(buf)) < 0) { - warn("gethostbyname:"); - return NULL; - } - - return buf; -} diff --git a/.suckless/slstatus/components/hostname.o b/.suckless/slstatus/components/hostname.o deleted file mode 100644 index 2bf33582bae7dd32442a61a6d22cd1bf724f0650..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1704 zcmbtU&x_Mg5T0ySchzpKzd%?IJ&B_GXx4+UsH9ukt`J<*^`HksTC)bUttJs$FM{B~ z!-5yVzeWmP{8RSoU0CN!-`Ho8Ui5?aX6Ab{^WK|z$@{j~S+Xn=SagTxmas&TJ=fh# zb!m+%bpIPI6YU(_26u?5`Dwaya12`e<8)GU*qSdo()ivg#x-lbva!ICrs8=kndhQB#|wEBGiQzSXSHDN43ApDo9My< z{@Mcm<^rD3Iy6r8NqMaX_1^50-}QF4o1VYh={#)j`FqW6ukDlWGo0yd5D&9coycaQ zC6=dn{5qPUs(Dm+&EPL;KJS0o;89JU&?Qc&r>ubc>+P}q zRXgO*CH2?K^q7^h{vGOs(kJu}u@WzQ+1|+g0}~_C2gWxkIlxOizT157u-?%7--2Nv Re}DX!%HoBLj994o_}?wWh~oeN diff --git a/.suckless/slstatus/components/ip.c b/.suckless/slstatus/components/ip.c deleted file mode 100644 index 70724eb..0000000 --- a/.suckless/slstatus/components/ip.c +++ /dev/null @@ -1,60 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include -#include -#if defined(__OpenBSD__) - #include - #include -#elif defined(__FreeBSD__) - #include - #include -#endif - -#include "../util.h" - -static const char * -ip(const char *interface, unsigned short sa_family) -{ - struct ifaddrs *ifaddr, *ifa; - int s; - char host[NI_MAXHOST]; - - if (getifaddrs(&ifaddr) < 0) { - warn("getifaddrs:"); - return NULL; - } - - for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { - if (!ifa->ifa_addr) { - continue; - } - s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), - host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); - if (!strcmp(ifa->ifa_name, interface) && - (ifa->ifa_addr->sa_family == sa_family)) { - freeifaddrs(ifaddr); - if (s != 0) { - warn("getnameinfo: %s", gai_strerror(s)); - return NULL; - } - return bprintf("%s", host); - } - } - - freeifaddrs(ifaddr); - - return NULL; -} - -const char * -ipv4(const char *interface) -{ - return ip(interface, AF_INET); -} - -const char * -ipv6(const char *interface) -{ - return ip(interface, AF_INET6); -} diff --git a/.suckless/slstatus/components/ip.o b/.suckless/slstatus/components/ip.o deleted file mode 100644 index 6e4384ad30f84a44b8e7cd721f4de8d2b8314955..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2608 zcmbuAPiz}S6vm(Jq%|eohEjy3g0PT_f+#CHAk;>p@;Y&{sWxpP2~vU7+Su#HZEQ#D zEhMM{RgJ5zj1fmph$AO1oXR1xL_p$(1P8>S>Y)dsfcPW91%!Fu?u@c*)))Aa*?IHZ z_hx2i-i+TV8q@JujHF_8hW1*L68&;u&(3>ho(|IpX|HIDn)|!9usE-~f9f}WOb-!N z^v=+UG4|5k%}k0xuBUgeXOc$O$vpZ4qK!@^lWg}kj_KVO(a!Zeyt_Wv$z)T+~111udc+3x!%@e{N9U!Q&M;Dx?gzBS1-1E*Y3=ArZTDO z)akKnpXhk+y=wpDJnsJNnPOPo{Zfov%-!Ej8}1+fp3khiy?bb{1HI#aPDOvl|2}8f z@9oAmKHG5by|$#it}SVoKHrM-{C4jC-S2N5g7qz1mo2AOH7ganH9>4Q%(_);RGSm& z6D{I@nwgxONRQ2&TYNg5%c|pQmIIG*fnsmHOtJOR*zu8r$@h7KE-=FqKq+ikK^c87 zUQklqL{UkGJ_Y|cB4e!H9&v>AJZ%u?(f)4KU z2S^ZqbVv_)?fv~Lf{%p!9~NBhMeuck0*6MtNO6sI4ohVa#ZM35X9n=I1Nch=_|gD= zWdOGa@SDt!^7_klm-%yB@F&HkB01I8)G|LvH72uoPSO z1G2!6a*_N~Ko&T1O!ChFS(p#jQu1v;7W{+r`NpHZ|ATBx|L+BdKhC)1I{_Y?kNk;% z|04nawD8A#P^27TNG|gN`2a~S^McgYM%^)&xpr*7UXhktdoo5D}6nXBq zd|zp!KF$SenCB8yQd~Kw0_Oy#yrFP!Ku>W258s%pp>g30h4D#d=<~nE=R}|5Tn8n` ze -#include - -#include "../util.h" - -const char * -kernel_release(void) -{ - struct utsname udata; - - if (uname(&udata) < 0) { - warn("uname:"); - return NULL; - } - - return bprintf("%s", udata.release); -} diff --git a/.suckless/slstatus/components/kernel_release.o b/.suckless/slstatus/components/kernel_release.o deleted file mode 100644 index 81e8eb3b94382ae689c1d750726fad29f544c74b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1880 zcmbW2&ubG=5XUD!YNNKb#-fFK$RU+V?IYWh6qKYP$qK=O#)B7^O|l^+$)@bC*oq*9 z3Q8&T;GxI<2|al76ws^SpCRbQyHMx5d9PhJ8xQ@4**EXAGxK(5-y?5J)p9%*Bc&KU zr1P1gMDxjWKkvJFnx-kzcYhsmd{f^~E-o?GKkQ}SGtdV5!JBOS2SVQscG8$Xz{Dro z;O9;K;8S*wf#ll2zoYMe^z)ng@|<7Ln;7!luUO~HOWW*OYqaPRRf@&6%u?m?v%48B zCssuc<>zo=#a=(5*!FB}VQMmU$ceX^!JsW%Dl^B4czY%V|3BhXO49GssE|Ztr-%~# zi&BCsMJYiOQJAYtj^U$Eo%SO~>)et&s#1b3jnqev(t-E#d&O*-ZFVG@s4#|C#_;MG zUK_)yV>!0fH5{vJnXV-oB&x+6E?Vdo8I|hBdZB7;l*>;`HKSHoua*q*Hw?Wp9h>S~ z&Zh0P$S_>bY;=r9yJNJ>%`PuZ8C+QSLep%2PKR0nWX0Lgb;VZ!S%{xuQ@jMoLi}Ym z#qr({;;*qO-UMWUqrZx0*oRODb|&HO^gOdp!u6ct*j66*$P}Kn?U87jo=Kwax+I)F zCJ5JrMxxR0^(>o1?7n9SK0PabGdK>}R@-Pfe8SF_yQq`lM4X-Q4$Cux)V>eL$|tR~*k1UYil6LqHPol HD4hQn{u;44 diff --git a/.suckless/slstatus/components/keyboard_indicators.c b/.suckless/slstatus/components/keyboard_indicators.c deleted file mode 100644 index b35eba1..0000000 --- a/.suckless/slstatus/components/keyboard_indicators.c +++ /dev/null @@ -1,48 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include -#include - -#include "../util.h" - -/* - * fmt consists of uppercase or lowercase 'c' for caps lock and/or 'n' for num - * lock, each optionally followed by '?', in the order of indicators desired. - * If followed by '?', the letter with case preserved is included in the output - * if the corresponding indicator is on. Otherwise, the letter is always - * included, lowercase when off and uppercase when on. - */ -const char * -keyboard_indicators(const char *fmt) -{ - Display *dpy; - XKeyboardState state; - size_t fmtlen, i, n; - int togglecase, isset; - char key; - - if (!(dpy = XOpenDisplay(NULL))) { - warn("XOpenDisplay: Failed to open display"); - return NULL; - } - XGetKeyboardControl(dpy, &state); - XCloseDisplay(dpy); - - fmtlen = strnlen(fmt, 4); - for (i = n = 0; i < fmtlen; i++) { - key = tolower(fmt[i]); - if (key != 'c' && key != 'n') { - continue; - } - togglecase = (i + 1 >= fmtlen || fmt[i + 1] != '?'); - isset = (state.led_mask & (1 << (key == 'n'))); - if (togglecase) { - buf[n++] = isset ? toupper(key) : key; - } else if (isset) { - buf[n++] = fmt[i]; - } - } - buf[n] = 0; - return buf; -} diff --git a/.suckless/slstatus/components/keyboard_indicators.o b/.suckless/slstatus/components/keyboard_indicators.o deleted file mode 100644 index 8f33bc78969305f651ef89bb546075ac0fcf8351..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2448 zcmbW2(Qn&S6o*fmv<;9sVMAKQrpZVd3W8ek7}BT>&JU?|WQg2rat#8s*~c9h(* z7ELfzby^kz2*C?adqLs}@fUQFIv9_LCnR2YKrl2A+S?vBg>xL=&IJ2qzv{&2e)pVn zeXsAm{a{uvkHuoZ6@%yDUW-$JS10cI1pe$JpZ>XrzSd*eDXnu|{$*DF+Y8n^f9SnuD9&r{ zCMc@&kJl)5&u4Q~IjKKuXOnExqc5g+*)+@#zSFuGd8^dTep~ANu3WfNWfS=8Z2WYU zX62>4o013Wh4a(!LLvRdb-7Rd>CgLve(AB>I|KIUPM>AGqA#a+f5Up}<&#&GODB)r zOk&SvW5qI0{-9XIj&q9L}4Kd+FNtwYuK<_4FC#ZRLz|Rx$P} z3r))@t+kuBxiuq}%{AMqiOdyU#A0p80p^Ou88J8a%JLJUoR>~Wc^c*s`a#9sdmUn% znb?ukWb#v-l8)@C*8?z3Q&fe_Cu6EG^>JJk#9l%bavzN=LjK}JSva*lSrV?q;;EQ$ zswCtUA%`ItiYcm)^ovA1sB{8u4Z^zPp*sd3j(=f_W2G>~VLS|DmB|SH|Cc`OMMl*L zY+}D6t=+-E`+IAMj21oP#{?hc2)-D>D-qm|;LQmBegwZ5!M}{)-$Za&x3*SXvsE+J zoZ4E|WNxc1RYB5=`LHf9=JW+s(T#<2d2x2hSW;Ad)_~v!hjV7jfy$i4Uh+#9U5B+? z8&)<}p;ENnw&kA%XtS1MTMigTm2EXGgSobQ&T1L9TMe*{W^ z7UxBxos~knGZ^Y=f~YYx+AW;V5JXY@0W{8EBZwj{pmBbhAd2dw(KvqxeG -#include -#include -#include -#include - -#include "../util.h" - -static int -valid_layout_or_variant(char *sym) -{ - size_t i; - /* invalid symbols from xkb rules config */ - static const char *invalid[] = { "evdev", "inet", "pc", "base" }; - - for (i = 0; i < LEN(invalid); i++) { - if (!strncmp(sym, invalid[i], strlen(invalid[i]))) { - return 0; - } - } - - return 1; -} - -static char * -get_layout(char *syms, int grp_num) -{ - char *tok, *layout; - int grp; - - layout = NULL; - tok = strtok(syms, "+:"); - for (grp = 0; tok && grp <= grp_num; tok = strtok(NULL, "+:")) { - if (!valid_layout_or_variant(tok)) { - continue; - } else if (strlen(tok) == 1 && isdigit(tok[0])) { - /* ignore :2, :3, :4 (additional layout groups) */ - continue; - } - layout = tok; - grp++; - } - - return layout; -} - -const char * -keymap(void) -{ - Display *dpy; - XkbDescRec *desc; - XkbStateRec state; - char *symbols, *layout; - - layout = NULL; - - if (!(dpy = XOpenDisplay(NULL))) { - warn("XOpenDisplay: Failed to open display"); - return NULL; - } - if (!(desc = XkbAllocKeyboard())) { - warn("XkbAllocKeyboard: Failed to allocate keyboard"); - goto end; - } - if (XkbGetNames(dpy, XkbSymbolsNameMask, desc)) { - warn("XkbGetNames: Failed to retrieve key symbols"); - goto end; - } - if (XkbGetState(dpy, XkbUseCoreKbd, &state)) { - warn("XkbGetState: Failed to retrieve keyboard state"); - goto end; - } - if (!(symbols = XGetAtomName(dpy, desc->names->symbols))) { - warn("XGetAtomName: Failed to get atom name"); - goto end; - } - layout = (char *)bprintf("%s", get_layout(symbols, state.group)); - XFree(symbols); -end: - XkbFreeKeyboard(desc, XkbSymbolsNameMask, 1); - if (XCloseDisplay(dpy)) { - warn("XCloseDisplay: Failed to close display"); - } - - return layout; -} diff --git a/.suckless/slstatus/components/keymap.o b/.suckless/slstatus/components/keymap.o deleted file mode 100644 index 89ae293aed97b5ce3cbba5561d3bf86472ad6922..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4104 zcmbuBO>7%Q6vxML(gX;b(3BDgAKNyGf=X9$AT*5tWgR=2sHUk%3PDiZwY?#hKe0C< zp_Ljn6tTFbNPLJZoDdQp7eGQ))izDl3kOsrB#KldkZ4t;Di^o_=Dpb&XT0@Z%CmOo z?Qj0?&Fswj?H&zB#u|J+BFsmgA{$qN5<*)y{1N7kkT#+a{kcFze^x)BPal|~D}T@g zEj9M^fq>ef?xDb$tEi>N&&+S7Z10!(~THu z-(cOq>Llo332xBxba(G*oVJ`ww=cl3-%pgn{g8#0^6jj5!ak4F>8MVJ(Q6lBu(q#5 z-MzFth|`SNzlQ@AxQA9Jr@cy#Uv7K-7<7g9Slz8h4%70TD5RwTwIkh~)c%XwR<|<< zErCbvD{vbu9Hu`=OQ`E#Ig@>ed-FF0P?=?+>Ve}?w^TC6yqO`sxX zac#a*sYL95Yo`yhrS>Y*OxQn1>>J}oC-hoYx0KcF2t>Y#K zmG+YjA*J(ee^61&jX|aFM3b)czp+VIhE|$G%CgUY$)^m3lzv_514&Tngpi=p!jpJ3 zn7WaySL${9>sAOt{P3%1e#lhM{Dl1(YPxQRD<9cZWop&K{2N@tz;BZ;tG=ILwpw%6 z_2zN!WwIvHQ!6JAaz5qaJ2*e;;(eTd?&7;R|G~uvIRDYbcXR%ei{quA+`M^D0N*U_ z3wt(zjl$6mhufY9P>;`g@RSEX;=$ka;O}|xk39G%9{dXr{*4D;^Wfik@Jk;2R}a4K z!3k8kjFH#kP%##abTR>da4j;*P66}=@boC29>dcho*u{3ZXQaa6gqoU)VJm8TZQX=OsJ!u1G(MM#&cfRP)&*^w)38c#H~4?UYYff#Ul7s& z4F9cyJI_DXAVRiEJOn-(@_XPA`n?FjFwY%u2p&fWhWbu81kWM_Lp^@l2)>9A%suW& z2Q!YfLg+u>9P{A!fZ(5Tj(P5r_$kg&uSk5AbN9HSUZB2B(&KZ8hWaiz#JK+;1Veo@ z9D;Agf)0jye18bOUE&W&e1LP22V>AiCB2;IX^CUa6!~LP9(n#rNiWa;u%yTOB=Q`S z^bbkAEOAxhA4`0j#6Okzc8Pz*Io|JG5&CS#CJ$~aG7B@zGcLxwW!#FH}iN= zg9UHp9G_J*!P_`j8Fls-=UO!lzK|>}7SCleW)?!TIm^`GJ7pL9fAauyE;?JlPpJQEDkQ*Lbid(8 zfT4-^nRDf6g^w*hL-=fuz#-clU-+whvGBi+)gw^Uk(O8P_xJzoqRj0;1TdJ z=dH#EAQp2v-vi)q6XS1j4Ja-}8wNf4?(q+Cpz?g8abJ%>N4@pikHr-15IZ}y68Ffx zelx&u{C=(z%`zXqLjc~2d5hKnE__+~uKR{u@j|=6 -#include - -#include "../util.h" - -const char * -load_avg(void) -{ - double avgs[3]; - - if (getloadavg(avgs, 3) < 0) { - warn("getloadavg: Failed to obtain load average"); - return NULL; - } - - return bprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]); -} diff --git a/.suckless/slstatus/components/load_avg.o b/.suckless/slstatus/components/load_avg.o deleted file mode 100644 index 36b9f4c577c5548a2280057f98c611bca856f62f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1912 zcmbW1OK;Oa5P&C-(g0~1N`)d7R3B0lUP~Ma2`YiyrgIB?`&0D=pgE0q~%H%V>h(vik9`|ZrEJ-h37IXxc?1VBmvp1^n{ zDZs<<*w-9agE@#oasN;1a|l7Tco<$up;J8ANG8-l@!-c#ihDoUTfotW$24$=I{3Z( zZ$4g1#__2qBVz72gu`&s2`L_yl8I{Z&Z1M%o*BaZucQdWopXk0Z_;J1A$h2VmRUPH1l@m)@jkS(LeJ<$LUrf_Wv&rRXarf{IWH}F`n3NSsJriVI$ zU=;Mt^)=nt%;#U^N=9jIUC$XXK1}e2TU{t`Tg|Rr1HIQ3O>1$`2#Lpl=H z-|N`C46JWkL)(y^Wwtr9&0QNr1N%mUhMc6632bF7u>)D)L=n zaN-7HEc4{_YjlX6IeRoI0^RQ=`%fVxuTcH=?~`b#+$Y*U%9Z(&`>u^~X|euCVJ{;i kb?4LFbMGA@_$EGxzHd@Qxe=oOrC -#include - -#include "../util.h" - -#if defined(__linux__) - #include - - const char * - netspeed_rx(const char *interface) - { - uintmax_t oldrxbytes; - static uintmax_t rxbytes; - extern const unsigned int interval; - char path[PATH_MAX]; - - oldrxbytes = rxbytes; - - if (esnprintf(path, sizeof(path), - "/sys/class/net/%s/statistics/rx_bytes", - interface) < 0) { - return NULL; - } - if (pscanf(path, "%ju", &rxbytes) != 1) { - return NULL; - } - if (oldrxbytes == 0) { - return NULL; - } - - return fmt_human((rxbytes - oldrxbytes) * 1000 / interval, - 1024); - } - - const char * - netspeed_tx(const char *interface) - { - uintmax_t oldtxbytes; - static uintmax_t txbytes; - extern const unsigned int interval; - char path[PATH_MAX]; - - oldtxbytes = txbytes; - - if (esnprintf(path, sizeof(path), - "/sys/class/net/%s/statistics/tx_bytes", - interface) < 0) { - return NULL; - } - if (pscanf(path, "%ju", &txbytes) != 1) { - return NULL; - } - if (oldtxbytes == 0) { - return NULL; - } - - return fmt_human((txbytes - oldtxbytes) * 1000 / interval, - 1024); - } -#elif defined(__OpenBSD__) | defined(__FreeBSD__) - #include - #include - #include - #include - #include - - const char * - netspeed_rx(const char *interface) - { - struct ifaddrs *ifal, *ifa; - struct if_data *ifd; - uintmax_t oldrxbytes; - static uintmax_t rxbytes; - extern const unsigned int interval; - int if_ok = 0; - - oldrxbytes = rxbytes; - - if (getifaddrs(&ifal) == -1) { - warn("getifaddrs failed"); - return NULL; - } - rxbytes = 0; - for (ifa = ifal; ifa; ifa = ifa->ifa_next) { - if (!strcmp(ifa->ifa_name, interface) && - (ifd = (struct if_data *)ifa->ifa_data)) { - rxbytes += ifd->ifi_ibytes, if_ok = 1; - } - } - freeifaddrs(ifal); - if (!if_ok) { - warn("reading 'if_data' failed"); - return NULL; - } - if (oldrxbytes == 0) { - return NULL; - } - - return fmt_human((rxbytes - oldrxbytes) * 1000 / interval, - 1024); - } - - const char * - netspeed_tx(const char *interface) - { - struct ifaddrs *ifal, *ifa; - struct if_data *ifd; - uintmax_t oldtxbytes; - static uintmax_t txbytes; - extern const unsigned int interval; - int if_ok = 0; - - oldtxbytes = txbytes; - - if (getifaddrs(&ifal) == -1) { - warn("getifaddrs failed"); - return NULL; - } - txbytes = 0; - for (ifa = ifal; ifa; ifa = ifa->ifa_next) { - if (!strcmp(ifa->ifa_name, interface) && - (ifd = (struct if_data *)ifa->ifa_data)) { - txbytes += ifd->ifi_obytes, if_ok = 1; - } - } - freeifaddrs(ifal); - if (!if_ok) { - warn("reading 'if_data' failed"); - return NULL; - } - if (oldtxbytes == 0) { - return NULL; - } - - return fmt_human((txbytes - oldtxbytes) * 1000 / interval, - 1024); - } -#endif diff --git a/.suckless/slstatus/components/netspeeds.o b/.suckless/slstatus/components/netspeeds.o deleted file mode 100644 index 1a9810974faa2ec8544e5667dc20bef6cc4dfde7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2784 zcmdUwPiS0K6voeF(spXoA=VZHRT&{EsjY7^fr6;Wq#?;u23wjID%Cz-CU2NAGn4e) zn=)~uMXQ7%P|$@-H;PNaor@As(3J~ULKk&eu(Wigf)LO5-aV7+&5VLO58OHD{qA?} zpLfr@^X^<_ekhY6u?)RJyH7%iK0B}*my@tehiQZ^`I~?ETgO0d(B@(sC1|sN;j&i7S(ed39$TdhUWvhu1FcapO9N~BFRMP6k#`6(fq?#Y9= zL%~Aj+}W8*aBhBnaqePpapr7gE}%%Y*WyN7*Jw>u!*-20j^gWKlWHv;)Yn^Kn}UG9 zrs_&it*->Nu+iKdR(E)zY;wXw96!eG&z;ncqmvCB)gcw~5+EC%@!myW0c3Oaiz!a{ zA&y0V#c+)CxW!itcgMMA@gtUg%W#bIgvCF%IKF+E_Z!18{)okYv^d5R{R6|@{mKU{ z>lFQd^Ctst?>BF_yWeLly*=-^#qIr;t#R!AUbeWs--1~`)`KQypBH$qPCd2J(%}+$ zO2?_MOB6@V(9=;zleZk|kh~?O$ctC;0C|ZE+N-X%T2Y%N?NuFld=EdLlpyPn9o2(c z9JV4^#((w&&cv48o1)ANRx|G-eM+?w!=t|OzRTQfn>1J0FD4(~1VXv-#*7&E8Mu2h zf8oq)X|>~|wTZP_My z;$P)XiEZ5>yU45#S9{guyYf*3)~sBF?*89k*6;js=0cNw;rx&*`Eq_(k2^Obde1;v p2fpDvH#h$vGxzKm(Jd^B?c>z-e%<}!&g+-|f?0pPmzf4`{$H?Aj-dbm diff --git a/.suckless/slstatus/components/num_files.c b/.suckless/slstatus/components/num_files.c deleted file mode 100644 index fb55df9..0000000 --- a/.suckless/slstatus/components/num_files.c +++ /dev/null @@ -1,31 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include - -#include "../util.h" - -const char * -num_files(const char *path) -{ - struct dirent *dp; - DIR *fd; - int num; - - if (!(fd = opendir(path))) { - warn("opendir '%s':", path); - return NULL; - } - - num = 0; - while ((dp = readdir(fd))) { - if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) { - continue; /* skip self and parent */ - } - num++; - } - - closedir(fd); - - return bprintf("%d", num); -} diff --git a/.suckless/slstatus/components/num_files.o b/.suckless/slstatus/components/num_files.o deleted file mode 100644 index a8afcfb0f232ee0092ffe05f1354fd5005dd5989..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2200 zcmbW1%TE(g6vj_m5acmd@X-WK>H?`jCoRT>B$`eiFeD8`9tOl(hjvICX-nE6q8np~ zBu#AM!at~qE?l~B;YQ=mS47>hkl^{IbK7z3Z1|cp_uSt-=iKJLo+MLKUXO=_Jam)V zJwb_YIco$ZrC2`Q*bfrR9bNxjMbc_|c^ zf{GO26b4oimj-LyMZXU_4f{Io1d)$_o#f+6o#Z3i=Gg*#)MM+lT_64brw7g9Zj#zz zrZ;49zk{E(_^^XF*VOI*9CJhyU0^a~TL*J5n2obJ=R~sN!e?CgEf>D*!ZjCOaN$(i zDrVLT8+ujFlAMZ1@R`8pDn8-%IAx|&b1@~AnVXtgNG@g;l~^j7A?q+xMb~nCsHtjH zvc*lxZj`G!`fHn&LdjUChgzk?|KS818=7qB+Xl%w&Cp0*t5!*_l+i(WMCRSgmWxHb#37}! zq09W5T&Wsb_5sHsThC|KD_T)+O?Ol$$cY{{=Z%OmgTy^(_L{N6M?1oXHHos>_11bi zdQqH(wTCNid;pMjkqzAW(!9f92U+D>BbV7j&7;LClkxj>${}-XQ B0fGPk diff --git a/.suckless/slstatus/components/ram.c b/.suckless/slstatus/components/ram.c deleted file mode 100644 index 47e6fda..0000000 --- a/.suckless/slstatus/components/ram.c +++ /dev/null @@ -1,222 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include - -#include "../util.h" - -#if defined(__linux__) - #include - - const char * - ram_free(void) - { - uintmax_t free; - - if (pscanf("/proc/meminfo", - "MemTotal: %ju kB\n" - "MemFree: %ju kB\n" - "MemAvailable: %ju kB\n", - &free, &free, &free) != 3) { - return NULL; - } - - return fmt_human(free * 1024, 1024); - } - - const char * - ram_perc(void) - { - uintmax_t total, free, buffers, cached; - - 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 (total == 0) { - return NULL; - } - - return bprintf("%d", 100 * ((total - free) - (buffers + cached)) - / total); - } - - const char * - ram_total(void) - { - uintmax_t total; - - if (pscanf("/proc/meminfo", "MemTotal: %ju kB\n", &total) - != 1) { - return NULL; - } - - return fmt_human(total * 1024, 1024); - } - - const char * - ram_used(void) - { - uintmax_t total, free, buffers, cached; - - 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; - } - - return fmt_human((total - free - buffers - cached) * 1024, - 1024); - } -#elif defined(__OpenBSD__) - #include - #include - #include - #include - - #define LOG1024 10 - #define pagetok(size, pageshift) (size_t)(size << (pageshift - LOG1024)) - - inline int - load_uvmexp(struct uvmexp *uvmexp) - { - int uvmexp_mib[] = {CTL_VM, VM_UVMEXP}; - size_t size; - - size = sizeof(*uvmexp); - - if (sysctl(uvmexp_mib, 2, uvmexp, &size, NULL, 0) >= 0) { - return 1; - } - - return 0; - } - - const char * - ram_free(void) - { - struct uvmexp uvmexp; - int free_pages; - - if (load_uvmexp(&uvmexp)) { - free_pages = uvmexp.npages - uvmexp.active; - return fmt_human(pagetok(free_pages, uvmexp.pageshift) * - 1024, 1024); - } - - return NULL; - } - - const char * - ram_perc(void) - { - struct uvmexp uvmexp; - int percent; - - if (load_uvmexp(&uvmexp)) { - percent = uvmexp.active * 100 / uvmexp.npages; - return bprintf("%d", percent); - } - - return NULL; - } - - const char * - ram_total(void) - { - struct uvmexp uvmexp; - - if (load_uvmexp(&uvmexp)) { - return fmt_human(pagetok(uvmexp.npages, - uvmexp.pageshift) * 1024, - 1024); - } - - return NULL; - } - - const char * - ram_used(void) - { - struct uvmexp uvmexp; - - if (load_uvmexp(&uvmexp)) { - return fmt_human(pagetok(uvmexp.active, - uvmexp.pageshift) * 1024, - 1024); - } - - return NULL; - } -#elif defined(__FreeBSD__) - #include - #include - #include - #include - - const char * - ram_free(void) { - struct vmtotal vm_stats; - int mib[] = {CTL_VM, VM_TOTAL}; - size_t len; - - len = sizeof(struct vmtotal); - if (sysctl(mib, 2, &vm_stats, &len, NULL, 0) == -1 - || !len) - return NULL; - - return fmt_human(vm_stats.t_free * getpagesize(), 1024); - } - - const char * - ram_total(void) { - long npages; - size_t len; - - len = sizeof(npages); - if (sysctlbyname("vm.stats.vm.v_page_count", &npages, &len, NULL, 0) == -1 - || !len) - return NULL; - - return fmt_human(npages * getpagesize(), 1024); - } - - const char * - ram_perc(void) { - long npages; - long active; - size_t len; - - len = sizeof(npages); - if (sysctlbyname("vm.stats.vm.v_page_count", &npages, &len, NULL, 0) == -1 - || !len) - return NULL; - - if (sysctlbyname("vm.stats.vm.v_active_count", &active, &len, NULL, 0) == -1 - || !len) - return NULL; - - return bprintf("%d", active * 100 / npages); - } - - const char * - ram_used(void) { - long active; - size_t len; - - len = sizeof(active); - if (sysctlbyname("vm.stats.vm.v_active_count", &active, &len, NULL, 0) == -1 - || !len) - return NULL; - - return fmt_human(active * getpagesize(), 1024); - } -#endif diff --git a/.suckless/slstatus/components/ram.o b/.suckless/slstatus/components/ram.o deleted file mode 100644 index 06c78dfd063be54119e32a4d6dc25d1bc4b28b7b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3136 zcmchYO>7%Q6vxMQ(wdO2LWoeLa@d1|9HngI5K2@Pu=C+eB$q}sNVEc$wY|n^vbI^T ztAZkNhVc8n8H%h zyhjUq)lqhqfhcaie)4Jy1|Ra zIyZR1$S1EFY1qDqF_JP0*uEUuw$LYe8-;GWW~71R1b1?X-93mKOU2(9wOr?Hb)kX0MhmEfz}lrDE~&%7(pBSS+pBtkteKjT)s`0J4T z3?K<|3ltV{g~h5s!Ng2RuRhoZvOJlG0X^UzfMt9iJta5e6SiXS!Z zcM4bI{-SU-u1WKTV7>UHEQp5W^8CM~ae2-IjmvY+to9pT;FPHj{HU(WmhWymR^Z+U zm{oNGhgs!zn^}Gn9jNClx(=15=eZ41X*2`ZqL=^i@PLyZtlc`@4##ulw2xhzWQi2% zFHfErhJ$?{diwsKcFrWvadR& zw#>i8SEv!Ue+xqKRiTLe1CsV~|6*g4-oA*R6%)hTgf~^U$KBTVju87;`~}}cM-e?& Rxa)ED?}$Kk#THH7{x6|-^DO`X diff --git a/.suckless/slstatus/components/run_command.c b/.suckless/slstatus/components/run_command.c deleted file mode 100644 index e00b478..0000000 --- a/.suckless/slstatus/components/run_command.c +++ /dev/null @@ -1,30 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include - -#include "../util.h" - -const char * -run_command(const char *cmd) -{ - char *p; - FILE *fp; - - if (!(fp = popen(cmd, "r"))) { - warn("popen '%s':", cmd); - return NULL; - } - p = fgets(buf, sizeof(buf) - 1, fp); - if (pclose(fp) < 0) { - warn("pclose '%s':", cmd); - return NULL; - } - if (!p) { - return NULL; - } - if ((p = strrchr(buf, '\n'))) { - p[0] = '\0'; - } - - return buf[0] ? buf : NULL; -} diff --git a/.suckless/slstatus/components/run_command.o b/.suckless/slstatus/components/run_command.o deleted file mode 100644 index cff227f72ab8ece462c522309f04b0149beb1738..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2200 zcmbW1QA-q26vxl*XjT1gDV6gB)e<7jx;2sl99EH>*zx6uFcGr_EJy= zOA38~pid%_(Ps!E@F6G&qTYfEJO7z`cc7)xK-nS3#1y?!>nhG1h8t zcMcRHm+G}IT5ZoYH+MHeqEv13qcgN~j29B|t~2l9DDR1$x?7OGJ%FvMN;dgfukGKt zn_k$nXsxnlmJ=5S>grrWnxV#Kc%)aPr37P$D_3j;OqEri>Yr(I#;L|PmTnoO?f|FG(=L?lm$tW+W1yc2iVLXy}jQA%hKdDb= z(t3V6mz&AX=4aCxJ)8FqCOtB&GA&k@X?ewTY;i)#b}Xw~?yN`4QJ z72NlMhnx0&C^-Ckxyf~&2mF7FJZuHH^iTLW-l;Ct-Y7Z7BB`8ZuP;i=GFJ`NG1nbZ zmkh@sb9o9&2AnuCb zmy==!$?wG*dA`y{-_H#>OmXw;jkroiu{aC0f+=r+K0wxaZs5V2=MyGFB$lhs;J(C~ zhmFU%#F``A{F3|Q|M?~Nmwk#SVT)_M?)pnuI9qh}SVCF_LxAy&pq9=12)=EeT|qVHnX9TJbbBUn2|G%DZ{20n@9 U>I8R2So{z1{>8edX9VN_0T5{g^#A|> diff --git a/.suckless/slstatus/components/swap.c b/.suckless/slstatus/components/swap.c deleted file mode 100644 index 2509db1..0000000 --- a/.suckless/slstatus/components/swap.c +++ /dev/null @@ -1,284 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include -#include - -#include "../util.h" - -#if defined(__linux__) - static int - get_swap_info(long *s_total, long *s_free, long *s_cached) - { - FILE *fp; - struct { - const char *name; - const size_t len; - long *var; - } ent[] = { - { "SwapTotal", sizeof("SwapTotal") - 1, s_total }, - { "SwapFree", sizeof("SwapFree") - 1, s_free }, - { "SwapCached", sizeof("SwapCached") - 1, s_cached }, - }; - size_t line_len = 0, i, left; - char *line = NULL; - - /* get number of fields we want to extract */ - for (i = 0, left = 0; i < LEN(ent); i++) { - if (ent[i].var) { - left++; - } - } - - if (!(fp = fopen("/proc/meminfo", "r"))) { - warn("fopen '/proc/meminfo':"); - return 1; - } - - /* read file line by line and extract field information */ - while (left > 0 && getline(&line, &line_len, fp) >= 0) { - for (i = 0; i < LEN(ent); i++) { - if (ent[i].var && - !strncmp(line, ent[i].name, ent[i].len)) { - sscanf(line + ent[i].len + 1, - "%ld kB\n", ent[i].var); - left--; - break; - } - } - } - free(line); - if (ferror(fp)) { - warn("getline '/proc/meminfo':"); - return 1; - } - - fclose(fp); - return 0; - } - - const char * - swap_free(void) - { - long free; - - if (get_swap_info(NULL, &free, NULL)) { - return NULL; - } - - return fmt_human(free * 1024, 1024); - } - - const char * - swap_perc(void) - { - long total, free, cached; - - if (get_swap_info(&total, &free, &cached) || total == 0) { - return NULL; - } - - return bprintf("%d", 100 * (total - free - cached) / total); - } - - const char * - swap_total(void) - { - long total; - - if (get_swap_info(&total, NULL, NULL)) { - return NULL; - } - - return fmt_human(total * 1024, 1024); - } - - const char * - swap_used(void) - { - long total, free, cached; - - if (get_swap_info(&total, &free, &cached)) { - return NULL; - } - - return fmt_human((total - free - cached) * 1024, 1024); - } -#elif defined(__OpenBSD__) - #include - #include - #include - #include - - static int - getstats(int *total, int *used) - { - struct swapent *sep, *fsep; - int rnswap, nswap, i; - - if ((nswap = swapctl(SWAP_NSWAP, 0, 0)) < 1) { - warn("swaptctl 'SWAP_NSWAP':"); - return 1; - } - if (!(fsep = sep = calloc(nswap, sizeof(*sep)))) { - warn("calloc 'nswap':"); - return 1; - } - if ((rnswap = swapctl(SWAP_STATS, (void *)sep, nswap)) < 0) { - warn("swapctl 'SWAP_STATA':"); - return 1; - } - if (nswap != rnswap) { - warn("getstats: SWAP_STATS != SWAP_NSWAP"); - return 1; - } - - *total = 0; - *used = 0; - - for (i = 0; i < rnswap; i++) { - *total += sep->se_nblks >> 1; - *used += sep->se_inuse >> 1; - } - - free(fsep); - - return 0; - } - - const char * - swap_free(void) - { - int total, used; - - if (getstats(&total, &used)) { - return NULL; - } - - return fmt_human((total - used) * 1024, 1024); - } - - const char * - swap_perc(void) - { - int total, used; - - if (getstats(&total, &used)) { - return NULL; - } - - if (total == 0) { - return NULL; - } - - return bprintf("%d", 100 * used / total); - } - - const char * - swap_total(void) - { - int total, used; - - if (getstats(&total, &used)) { - return NULL; - } - - return fmt_human(total * 1024, 1024); - } - - const char * - swap_used(void) - { - int total, used; - - if (getstats(&total, &used)) { - return NULL; - } - - return fmt_human(used * 1024, 1024); - } -#elif defined(__FreeBSD__) - #include - #include - #include - #include - #include - - static int getswapinfo(struct kvm_swap *swap_info, size_t size) - { - kvm_t *kd; - - kd = kvm_openfiles(NULL, "/dev/null", NULL, 0, NULL); - if(kd == NULL) { - warn("kvm_openfiles '/dev/null':"); - return 0; - } - - if(kvm_getswapinfo(kd, swap_info, size, 0 /* Unused flags */) == -1) { - warn("kvm_getswapinfo:"); - kvm_close(kd); - return 0; - } - - kvm_close(kd); - return 1; - } - - const char * - swap_free(void) - { - struct kvm_swap swap_info[1]; - long used, total; - - if(!getswapinfo(swap_info, 1)) - return NULL; - - total = swap_info[0].ksw_total; - used = swap_info[0].ksw_used; - - return fmt_human((total - used) * getpagesize(), 1024); - } - - const char * - swap_perc(void) - { - struct kvm_swap swap_info[1]; - long used, total; - - if(!getswapinfo(swap_info, 1)) - return NULL; - - total = swap_info[0].ksw_total; - used = swap_info[0].ksw_used; - - return bprintf("%d", used * 100 / total); - } - - const char * - swap_total(void) - { - struct kvm_swap swap_info[1]; - long total; - - if(!getswapinfo(swap_info, 1)) - return NULL; - - total = swap_info[0].ksw_total; - - return fmt_human(total * getpagesize(), 1024); - } - - const char * - swap_used(void) - { - struct kvm_swap swap_info[1]; - long used; - - if(!getswapinfo(swap_info, 1)) - return NULL; - - used = swap_info[0].ksw_used; - - return fmt_human(used * getpagesize(), 1024); - } -#endif diff --git a/.suckless/slstatus/components/swap.o b/.suckless/slstatus/components/swap.o deleted file mode 100644 index f97e2ea6be47a6df01f9ac4531f85fd5d1d9c090..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3952 zcmb`KU5pb|6o7BHyHIf%DuPxarX~YhMN5mIyNG0``*$}fKT1J~!Z@^3yV?F_Ix7p= zM3S;3lTtKB6HR>6L?1L_VxkYmlmH6&Mtm_C!-J7UHbGu65~ZGV=U(@AXcJ>RoBQ|O zbI$!g(|v6uIojp(5g|UZl`OObB_!6nP#??GKU+oaBn8l&}Ru(|B*)3kcqM;%+Gw7!XHR4+AY^_Gu*JFG_T0+OuT zY7kq40ccU|hQ#WqAGpO+vYPd$%W@sI>sPk*mx#{Z8Hm1+gI;=8T%d4SeJp&VRy47vq zEx2vAX+J$)OR0hJ+D0|$T*pZVTsx$*jj7e+^_i7EzW$_hi#ESw{a16%W^=rHCX^gd z)v3>}?uBN&p?!s?!W6CrD4!;+!RQ&f&fRgl$Ms)5Gd=8FesQ1nlD1FVuj#Pa^P%{~ zc(dhf0`UfQewo{HyV=y7M!YcsQ(8`IThy;fH>~>9l_h+(Ni_gN^s+-;7$SsTBP||7 z;IW>9Q-h;}DPEbo{FmfAMr*w)ojq^&QRf_8Hw-F}1?glX!?&2eOMm}^I^V<_eB_iG zf{|BvMvjQ}+-w=0t>?;IULNy*UQbZ=y&Ct5uA5NO;mFwb-H(LhvFL_q44(j5!E!=;ho2+9>7Z{_@8ZB4aJ4A#)x7TmylM$0 z_AD)07CPfGU_Ilz=-%j{Dk! z<**X&dR7VG*hjDpau_o(?wWG>JJ<%1_3`DNWR#FBmZ)#w2%QC|-c4>a+iCdQMm9qH z@YhcK_!8QPpRlOb(u0%glKith@xguaSxq$l-sZc@)06M4d>mBmPzE!cW)s$djdRyM6PIZ(DHigwl|HjAvx zV5$P~l#qvU6F_j;_`Bjy_?n``5P~4bHzGLRM-=3DLlXQ5)KQS*Pa(mNBLqRd6q4Y0 zPf;*}VB8b@Q-mO>uRs#~0zwefUkOR@iwHrGV{8!oXM`Z=XBi~HZz2Ri{re#a9_9B3 zImT7Nhd4(+c%KB{F6loY@sh+Jl=vZuW2_Q>PDmWTFM|Ilag1Gp-;lVhKZX+o!QviB zLVpkExUR6oCnYZX`B>uexThp8>o4b@2J|oM_eosV$2p*&JMNOT^DJNB;{6}>aPiLH z^KkK=KlgC)o=LQFs9+lhptLQw%!!(1=8dRrPTM4!F>HfG4^%27YL&2o>hUPN?sTb8 zFpHp4EZJrhel|SLo+0R=wVBhimQgVI=>NS4gDD=d_e(Gc3?;_*)or=DqK+lrEj)`s zNU~h!pVBhlbbQk|j`+f|{{o=BmUGWAr0fNthr+L;+kpHrNa)k6{%`H$V2eICK$1n+ zPskAJVti2!awg)JQ2&8X$opLvcA^}YdR$W50rcCq;{X5v diff --git a/.suckless/slstatus/components/temperature.c b/.suckless/slstatus/components/temperature.c deleted file mode 100644 index 8462d0f..0000000 --- a/.suckless/slstatus/components/temperature.c +++ /dev/null @@ -1,71 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include - -#include "../util.h" - - -#if defined(__linux__) - #include - - const char * - temp(const char *file) - { - uintmax_t temp; - - if (pscanf(file, "%ju", &temp) != 1) { - return NULL; - } - - return bprintf("%ju", temp / 1000); - } -#elif defined(__OpenBSD__) - #include - #include /* before for struct timeval */ - #include - #include - - const char * - temp(const char *unused) - { - int mib[5]; - size_t size; - struct sensor temp; - - mib[0] = CTL_HW; - mib[1] = HW_SENSORS; - mib[2] = 0; /* cpu0 */ - mib[3] = SENSOR_TEMP; - mib[4] = 0; /* temp0 */ - - size = sizeof(temp); - - if (sysctl(mib, 5, &temp, &size, NULL, 0) < 0) { - warn("sysctl 'SENSOR_TEMP':"); - return NULL; - } - - /* kelvin to celsius */ - return bprintf("%d", (temp.value - 273150000) / 1E6); - } -#elif defined(__FreeBSD__) - #include - #include - #include - - const char * - temp(const char *zone) - { - char buf[256]; - int temp; - size_t len; - - len = sizeof(temp); - snprintf(buf, sizeof(buf), "hw.acpi.thermal.%s.temperature", zone); - if (sysctlbyname(buf, &temp, &len, NULL, 0) == -1 - || !len) - return NULL; - - /* kelvin to decimal celcius */ - return bprintf("%d.%d", (temp - 2731) / 10, abs((temp - 2731) % 10)); - } -#endif diff --git a/.suckless/slstatus/components/temperature.o b/.suckless/slstatus/components/temperature.o deleted file mode 100644 index 3b467c6aa58017eb52adea1e897e5c69c367e448..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1760 zcmbVM&ubGw6n>kuHfkE{k3*z_5mKqBW455EU`d)LSz$4t74+h=*=*R_<_EhQh+aJO z6iUHA!DA2p1D*^h;@LmJQ$Y{*y%5 zYKE<`48SF-gQmQF3QA{5S&lEn-s1s?zY;_M9P*oqRK!ZeI5pwu%yV$up9mlko!SxN zrKU*2C{~(gQJ9}bW0i#&{N#4e1(~zzoSLXZeYha)Kj;N=mvJmjWCPrp!QY#~ug~DY zx9ct2HT|}0GYgoW&jb`0CB3|n(~WYm_^hyHY~?oef&nehG8;9hwA}56UjxJNeAC)7 zEN924ncKTC>`(;Pqptkx59}&pGU|97hu|L&i5AW;4(K3%5wXZOBt9YWDb7&{ zQrnJEbIrOvT<)YGg+hAU;g^v`j!e9V!EBH#F!^O1)Y~i$*$#O#I-ER%p4JgBHp%(x zoDY8~hdds3R718~IH8&+)vKtbnrk>@6YGb+RI$GBSrie*znU@o$Y&SF*irw4{xQY{ zmQz2=6A6cNUvd4|+e5C$HQ{}U{_`-rL@@3CQoNz!p6LEaEA)b={e;&>3jWX!n!`7I m7O|*7ywIOU9KJh>zu-m7G?6TP{__}{roYcgN751u>;D6JVWDII diff --git a/.suckless/slstatus/components/uptime.c b/.suckless/slstatus/components/uptime.c deleted file mode 100644 index 7c23c98..0000000 --- a/.suckless/slstatus/components/uptime.c +++ /dev/null @@ -1,33 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include - -#include "../util.h" - -#if defined(CLOCK_BOOTTIME) - #define UPTIME_FLAG CLOCK_BOOTTIME -#elif defined(CLOCK_UPTIME) - #define UPTIME_FLAG CLOCK_UPTIME -#else - #define UPTIME_FLAG CLOCK_MONOTONIC -#endif - -const char * -uptime(void) -{ - char warn_buf[256]; - uintmax_t h, m; - struct timespec uptime; - - if (clock_gettime(UPTIME_FLAG, &uptime) < 0) { - snprintf(warn_buf, 256, "clock_gettime %d", UPTIME_FLAG); - warn(warn_buf); - return NULL; - } - - h = uptime.tv_sec / 3600; - m = uptime.tv_sec % 3600 / 60; - - return bprintf("%juh %jum", h, m); -} diff --git a/.suckless/slstatus/components/uptime.o b/.suckless/slstatus/components/uptime.o deleted file mode 100644 index 8672ff1305c7afe6ba6fbc3123dd6719f0db4747..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2016 zcmbW1&ubGw6vtnZ)<$h(`~`)2*h4Ccx@3D2t(vs9T_sx3_TWL+ZL%@3`B9QBwqB&5 zVkiNxUZh7aLaznUpyJs-Lr@VxHKMe3nU;CkOR6$?w8$E?}>uGA3f!5L6b}If20na+Cs@|@o zhPRxE_HjV1^B(2&)-T70{XOe@T3^4Kif<(o{Jeb$-uf&3&)=#MWYTOYNK z6RoembE+2fGvm%{*!?bF`;51{`zc?k=NF9!mTi}-mNHtP(TB?=g}qIh}h>K^v zCQdwv5!Z5 zzsuP(W+Ob3UEX{!dhjbfxZZ=`=)vcEa9Uo%;ZXCW<|fnl(gY%7CO12g%^9=P)3>MQ zjJfPYZpxrtXNsD&rAE1C7wM7NsL_I07)H}J`Q+tGi$>8bSGe{`9uPV=#N*$#tBZiF zC=YZ)^6P*s`16JE_#7Y$96gc#Wk444?B^l*3qTh9vG0;^unmEur;;mdL&$^SNo}rH zZF7OtrrmJolC&CD#Z+x;#U{02+9s(B%_gahIu>x(RE^Ypy;`+u>{6@Smdf|;oU=#l zhiI#06dPvM^2+ViP&g2GEqEd`%piFV-IePrZOk~I*pmzozgEOmd?O(43F@F{(6Bo> zeFhKS+@IokaDuO2XL*5~dyU6ELe4QBe#!dyeSXRMa?bEW*y8WdbBzm!qaJY$87Jp! zjHT^&9SMUWzV`&%b@rGkB0j^mUvmE?yTe9U{}e!$>=XKjSQ#%l$^>gOqWhx$rkD>h k!wAOX?ge|th>`*pvG7Tx^9b%@Sp0eM{w2@THG=W~0UwCgKL7v# diff --git a/.suckless/slstatus/components/user.c b/.suckless/slstatus/components/user.c deleted file mode 100644 index 71a0c9d..0000000 --- a/.suckless/slstatus/components/user.c +++ /dev/null @@ -1,32 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include -#include - -#include "../util.h" - -const char * -gid(void) -{ - return bprintf("%d", getgid()); -} - -const char * -username(void) -{ - struct passwd *pw; - - if (!(pw = getpwuid(geteuid()))) { - warn("getpwuid '%d':", geteuid()); - return NULL; - } - - return bprintf("%s", pw->pw_name); -} - -const char * -uid(void) -{ - return bprintf("%d", geteuid()); -} diff --git a/.suckless/slstatus/components/user.o b/.suckless/slstatus/components/user.o deleted file mode 100644 index 25b2f002b3de3dc4c4db7d7be883456cc2ede796..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2240 zcmbuAO-~b16oyYJ2=Y-8HDYkl4WfyRoyJ5$)D)TmCPj<_0gN;Q9cY6sWI6=sul{ zG$nf7brR=9n4U5Da`sI#9GZKZQ7X5&Dl}#$62;hU zu6=4#bF@s`ezyWSpF7XB%!b#ZV-v+ZdgMNy3+$Hc49R3QU6r$nbCg351dVMiunv~S=?MI z%@!A?r;4S8nVBbr#nR%`bg@vvw%x9lX=5*_*2684TK8%`xX-&e+SYX71$7iB>X1%! zKE?5$V`*m<$2@wc`4z>nQ_dSaZE*Bb>u)KJI;g2R))Qve$xAHWtCwS~FDefG1%qQf zVRoHo5{o+K`y&?y{W-pL{X2kcHs6-Gg{KwAcj+|*ny|RuFDn+;eI}>zq854^?889% zijD&Rx#xubVMtEd3q5i+8Vz!ST?`<19haQV-CE7Bv!uQo`VOB@Vk80j_ z_VaJD05$(L-{oA?%<^TLe*PsBa;%@PeNHj;w-KqED$@H>Pv|`DaX#o+Yv8|`10%Mz z>pTZ$?p4UYcaFjX!hIIH6Fht*$FB~r@3&i@N80qxoV diff --git a/.suckless/slstatus/components/volume.c b/.suckless/slstatus/components/volume.c deleted file mode 100644 index 61cec90..0000000 --- a/.suckless/slstatus/components/volume.c +++ /dev/null @@ -1,109 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include -#include -#include - -#include "../util.h" - -#if defined(__OpenBSD__) - #include - - const char * - vol_perc(const char *card) - { - static int cls = -1; - mixer_devinfo_t mdi; - mixer_ctrl_t mc; - int afd = -1, m = -1, v = -1; - - if ((afd = open(card, O_RDONLY)) < 0) { - warn("open '%s':", card); - return NULL; - } - - for (mdi.index = 0; cls == -1; mdi.index++) { - if (ioctl(afd, AUDIO_MIXER_DEVINFO, &mdi) < 0) { - warn("ioctl 'AUDIO_MIXER_DEVINFO':"); - close(afd); - return NULL; - } - if (mdi.type == AUDIO_MIXER_CLASS && - !strncmp(mdi.label.name, - AudioCoutputs, - MAX_AUDIO_DEV_LEN)) - cls = mdi.index; - } - for (mdi.index = 0; v == -1 || m == -1; mdi.index++) { - if (ioctl(afd, AUDIO_MIXER_DEVINFO, &mdi) < 0) { - warn("ioctl 'AUDIO_MIXER_DEVINFO':"); - close(afd); - return NULL; - } - if (mdi.mixer_class == cls && - ((mdi.type == AUDIO_MIXER_VALUE && - !strncmp(mdi.label.name, - AudioNmaster, - MAX_AUDIO_DEV_LEN)) || - (mdi.type == AUDIO_MIXER_ENUM && - !strncmp(mdi.label.name, - AudioNmute, - MAX_AUDIO_DEV_LEN)))) { - mc.dev = mdi.index, mc.type = mdi.type; - if (ioctl(afd, AUDIO_MIXER_READ, &mc) < 0) { - warn("ioctl 'AUDIO_MIXER_READ':"); - close(afd); - return NULL; - } - if (mc.type == AUDIO_MIXER_VALUE) - v = mc.un.value.num_channels == 1 ? - mc.un.value.level[AUDIO_MIXER_LEVEL_MONO] : - (mc.un.value.level[AUDIO_MIXER_LEVEL_LEFT] > - mc.un.value.level[AUDIO_MIXER_LEVEL_RIGHT] ? - mc.un.value.level[AUDIO_MIXER_LEVEL_LEFT] : - mc.un.value.level[AUDIO_MIXER_LEVEL_RIGHT]); - else if (mc.type == AUDIO_MIXER_ENUM) - m = mc.un.ord; - } - } - - close(afd); - - return bprintf("%d", m ? 0 : v * 100 / 255); - } -#else - #include - - const char * - vol_perc(const char *card) - { - size_t i; - int v, afd, devmask; - char *vnames[] = SOUND_DEVICE_NAMES; - - if ((afd = open(card, O_RDONLY | O_NONBLOCK)) < 0) { - warn("open '%s':", card); - return NULL; - } - - if (ioctl(afd, (int)SOUND_MIXER_READ_DEVMASK, &devmask) < 0) { - warn("ioctl 'SOUND_MIXER_READ_DEVMASK':"); - close(afd); - return NULL; - } - for (i = 0; i < LEN(vnames); i++) { - if (devmask & (1 << i) && !strcmp("vol", vnames[i])) { - if (ioctl(afd, MIXER_READ(i), &v) < 0) { - warn("ioctl 'MIXER_READ(%ld)':", i); - close(afd); - return NULL; - } - } - } - - close(afd); - - return bprintf("%d", v & 0xff); - } -#endif diff --git a/.suckless/slstatus/components/volume.o b/.suckless/slstatus/components/volume.o deleted file mode 100644 index 91c86039a137570759b882ffac4809b7815b1b3f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3624 zcmds)O>7%Q6o8-Oq;(;F4huNMRm946fQIsyP3&Ytouo>fDu{+=U3-%3&y!dv*^%1T z)TDahw_ni8sjIDBF;vvro6+yEPHd`c=c186Kl~Cx0GZm)@B%SzC`2x`9;gQ|3x7F2Dv^`b3b@T6yfHU;s z>JvXO2Ntl9bjQm^L$y1Z1HbcbI`_Vw*ye1}gz8e+$wS2`LA7G) z^QH~OLfM2;!2lzN)grYe!8Q#joY4zqu-uZI60U2~EqftXIFq0vNkuPI^5|R1TMG`H zE#yoKY&}=7pk$Q`j%9;YG0ReSSGD^%6fDCjO5Ky=Q)4M@bYwa`p-rTfl$J`L8dWAw z?0D?7#kz{Qqu9`u0~j70JTAqC$EJ=-iMX7US87KeyeEgb^`^UY> zIE{O^&;NU$zkmL>e4Ne-KJH&lIKO(S|8}2$h!P)#=J^0VydTNODTg>m)fH;?XF1Pc z&Z$2Vo&%iojPCH7-OQnWxSu3&FMk1I0)L3vae+U=>^^~0o|5#tCDh05VYVu8nb{`= zPQN}#roF1(&oO4dD)48Rofo*m?25pLnY}1*zQ30RKFRDAfxpD;b%DRa?8^eD^MT}j zx7_(YeBK)ZFERUyz^lyuOyEn*-W2$GW=pK5{Yg(<U z#1&RQhIOOyZ?LOxnk^2EPh*JVCm0jQS9dKcIx%6>;wC(W8Zn+{yn)Am%K@u-Jg?Kp zNskMD9c)5$7W;+A@p=p!x$gJt5nqTkioOPm7hgBd;-~$cqRzh`$CRIqzQ4r&FXHP= z-=EG>9?v<=M;sdwtg!K8tdZ`3Fg{{D_1WlEuh1cla?Y#jrTG4IM>UG?WAo?d2Jb+O F{}&S0wEX}8 diff --git a/.suckless/slstatus/components/wifi.c b/.suckless/slstatus/components/wifi.c deleted file mode 100644 index 92c252e..0000000 --- a/.suckless/slstatus/components/wifi.c +++ /dev/null @@ -1,272 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include -#include -#include -#include - -#include "../util.h" - -#define RSSI_TO_PERC(rssi) \ - rssi >= -50 ? 100 : \ - (rssi <= -100 ? 0 : \ - (2 * (rssi + 100))) - -#if defined(__linux__) - #include - #include - - const char * - wifi_perc(const char *interface) - { - int cur; - size_t i; - char *p, *datastart; - char path[PATH_MAX]; - char status[5]; - FILE *fp; - - if (esnprintf(path, sizeof(path), "/sys/class/net/%s/operstate", - interface) < 0) { - return NULL; - } - if (!(fp = fopen(path, "r"))) { - warn("fopen '%s':", path); - return NULL; - } - p = fgets(status, 5, fp); - fclose(fp); - if (!p || strcmp(status, "up\n") != 0) { - return NULL; - } - - if (!(fp = fopen("/proc/net/wireless", "r"))) { - warn("fopen '/proc/net/wireless':"); - return NULL; - } - - for (i = 0; i < 3; i++) { - if (!(p = fgets(buf, sizeof(buf) - 1, fp))) - break; - } - fclose(fp); - if (i < 2 || !p) { - return NULL; - } - - if (!(datastart = strstr(buf, interface))) { - return NULL; - } - - datastart = (datastart+(strlen(interface)+1)); - sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t " - "%*d\t\t%*d\t\t %*d\t %*d\t\t %*d", &cur); - - /* 70 is the max of /proc/net/wireless */ - return bprintf("%d", (int)((float)cur / 70 * 100)); - } - - const char * - wifi_essid(const char *interface) - { - static char id[IW_ESSID_MAX_SIZE+1]; - int sockfd; - struct iwreq wreq; - - memset(&wreq, 0, sizeof(struct iwreq)); - wreq.u.essid.length = IW_ESSID_MAX_SIZE+1; - if (esnprintf(wreq.ifr_name, sizeof(wreq.ifr_name), "%s", - interface) < 0) { - return NULL; - } - - if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - warn("socket 'AF_INET':"); - return NULL; - } - wreq.u.essid.pointer = id; - if (ioctl(sockfd,SIOCGIWESSID, &wreq) < 0) { - warn("ioctl 'SIOCGIWESSID':"); - close(sockfd); - return NULL; - } - - close(sockfd); - - if (!strcmp(id, "")) { - return NULL; - } - - return id; - } -#elif defined(__OpenBSD__) - #include - #include - #include - #include /* before for NBBY */ - #include - #include - #include - - static int - load_ieee80211_nodereq(const char *interface, struct ieee80211_nodereq *nr) - { - struct ieee80211_bssid bssid; - int sockfd; - uint8_t zero_bssid[IEEE80211_ADDR_LEN]; - - memset(&bssid, 0, sizeof(bssid)); - memset(nr, 0, sizeof(struct ieee80211_nodereq)); - if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - warn("socket 'AF_INET':"); - return 0; - } - strlcpy(bssid.i_name, interface, sizeof(bssid.i_name)); - if ((ioctl(sockfd, SIOCG80211BSSID, &bssid)) < 0) { - warn("ioctl 'SIOCG80211BSSID':"); - close(sockfd); - return 0; - } - memset(&zero_bssid, 0, sizeof(zero_bssid)); - if (memcmp(bssid.i_bssid, zero_bssid, - IEEE80211_ADDR_LEN) == 0) { - close(sockfd); - return 0; - } - strlcpy(nr->nr_ifname, interface, sizeof(nr->nr_ifname)); - memcpy(&nr->nr_macaddr, bssid.i_bssid, sizeof(nr->nr_macaddr)); - if ((ioctl(sockfd, SIOCG80211NODE, nr)) < 0 && nr->nr_rssi) { - warn("ioctl 'SIOCG80211NODE':"); - close(sockfd); - return 0; - } - - return close(sockfd), 1; - } - - const char * - wifi_perc(const char *interface) - { - struct ieee80211_nodereq nr; - int q; - - if (load_ieee80211_nodereq(interface, &nr)) { - if (nr.nr_max_rssi) { - q = IEEE80211_NODEREQ_RSSI(&nr); - } else { - q = RSSI_TO_PERC(nr.nr_rssi); - } - return bprintf("%d", q); - } - - return NULL; - } - - const char * - wifi_essid(const char *interface) - { - struct ieee80211_nodereq nr; - - if (load_ieee80211_nodereq(interface, &nr)) { - return bprintf("%s", nr.nr_nwid); - } - - return NULL; - } -#elif defined(__FreeBSD__) - #include - #include - - int - load_ieee80211req(int sock, const char *interface, void *data, int type, size_t *len) - { - char warn_buf[256]; - struct ieee80211req ireq; - memset(&ireq, 0, sizeof(ireq)); - ireq.i_type = type; - ireq.i_data = (caddr_t) data; - ireq.i_len = *len; - - strlcpy(ireq.i_name, interface, sizeof(ireq.i_name)); - if (ioctl(sock, SIOCG80211, &ireq) < 0) { - snprintf(warn_buf, sizeof(warn_buf), - "ioctl: 'SIOCG80211': %d", type); - warn(warn_buf); - return 0; - } - - *len = ireq.i_len; - return 1; - } - - const char * - wifi_perc(const char *interface) - { - union { - struct ieee80211req_sta_req sta; - uint8_t buf[24 * 1024]; - } info; - uint8_t bssid[IEEE80211_ADDR_LEN]; - int rssi_dbm; - int sockfd; - size_t len; - const char *fmt; - - if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - warn("socket 'AF_INET':"); - return NULL; - } - - /* Retreive MAC address of interface */ - len = IEEE80211_ADDR_LEN; - fmt = NULL; - if (load_ieee80211req(sockfd, interface, &bssid, IEEE80211_IOC_BSSID, &len)) - { - /* Retrieve info on station with above BSSID */ - memset(&info, 0, sizeof(info)); - memcpy(info.sta.is_u.macaddr, bssid, sizeof(bssid)); - - len = sizeof(info); - if (load_ieee80211req(sockfd, interface, &info, IEEE80211_IOC_STA_INFO, &len)) { - rssi_dbm = info.sta.info[0].isi_noise + - info.sta.info[0].isi_rssi / 2; - - fmt = bprintf("%d", RSSI_TO_PERC(rssi_dbm)); - } - } - - close(sockfd); - return fmt; - } - - const char * - wifi_essid(const char *interface) - { - char ssid[IEEE80211_NWID_LEN + 1]; - size_t len; - int sockfd; - const char *fmt; - - if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - warn("socket 'AF_INET':"); - return NULL; - } - - fmt = NULL; - len = sizeof(ssid); - memset(&ssid, 0, len); - if (load_ieee80211req(sockfd, interface, &ssid, IEEE80211_IOC_SSID, &len )) { - if (len < sizeof(ssid)) - len += 1; - else - len = sizeof(ssid); - - ssid[len - 1] = '\0'; - fmt = bprintf("%s", ssid); - } - - close(sockfd); - return fmt; - } -#endif diff --git a/.suckless/slstatus/components/wifi.o b/.suckless/slstatus/components/wifi.o deleted file mode 100644 index 4c5b14be12b2d77debe05629cfce40a1a34507b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4400 zcmbuBeQZ-z6u?hc3LC=PNR+nwdJUBU+aQFG+I6q4+1Ad!x4^_i z$v%?jRzv(sG)AM*7$Y(MVN48WR5yb9mmx91Xd*F2K$u|mhZxa$&U^Q6m$$yZJn6e1 zzkANP_uTt>-hH+y)?DIp0T&lM2J<~m0X|+n-wv705J<2b!uu5CuL-CCQ1YvZhdaXU zQR7xen{wisjJQh~TU1qp1Bx;1^CAcqV)H<<-;;I zV#cq`BeS5u%7;DX&?SrI+kMOC*7l62gvB~jUfW0mEdH7DBNQ*plpkRA<{NW9$E*$R zQZ`vTu6wMZ6H{~$igEei;qamG;qZ}3I-;AOm7=2w9DxpYc5TYgwSaJ7jlP;-A!_^* zGcL`17&E@WI(4qm=dA?O@krrVE_i;T1U;Og!i2_IJkg4|1)J>ZP9=XADu8h=X8as1 zOspTH^&Ik5Fh7H9Z#Q6Dd37agJZFZFCKm>9W0bLWUkygN%6zYQltWViif@wUnU^|k zP^(M!CN!-sqv~~4T3xnZ&1rf}2HXDy@1u4D>IBy8c`?X(}E~=hR+R)40mQ z5j2sjYP)1vuEN4>VNq6Qwy`8sR%Rh886XT*_|rhkCVNy}t`0ZHqq~~g(P289)O+RX zwrFcZOLTuzTU)ddDZqFH;HwCgpw`B%^?JZ>259Ygz>>xgrs_gOI;ejf7+I*5>B6ruKMyI1+1$ zgQ{ivbLotpvNAIqP2@6=dQ#OfRVRD1nhKhpOZN3c=Rk^@_@k;<%|JY!#+18lTU^tU ziA)MQnWK0dzX!>lc(S`Eo=T*9tuU;k+fn_R*+*XN&K@*~Feji4_J`riw@T;LZOCqH7m z{|a1;S8`bc_INijPV1NP;p+?t`jrB26!^UY-_1Drp?t&r91`^J6L?zCzf<6v!08*o z{TvtgN`Vgx{(S;}OW;)k|61@vcLVPKrl2prpUWvA6xz3He7OEP#;IB@@Jc~nJeOKQ zpL}sYAwj=J;5!BVH3Hu&=!^aj2z;ZU-|4`+1^=|3zpcON?1-Q*?wgD{Bs9!a%zl?y z&U2ne!LJSW>4{FP^_*3A^A_G56MkJirh~sLp(nuKiT6ljV`b&8|6B(J?har@2gylq~lzF_{%I6yw__7|CbB{yWXZ0iTH zPxIH?IJcj&andE>b%?dC`yGu~@-ABtkC$`WD-vEmj&1T4ASlQwW>5cpQTV*P-iL#{ zE$W@IZwMQ->-I2v`*s(Y{YlX&w(aqxkQF=sQublwanbqHE5Ysg`O|vrb0dP?Y=dsF lbrvskDhrZ|n`qS)i7TwKh4D_j47XpC*U{eQzu5q$sv diff --git a/.suckless/slstatus/config.def.h b/.suckless/slstatus/config.def.h deleted file mode 100644 index 67ba964..0000000 --- a/.suckless/slstatus/config.def.h +++ /dev/null @@ -1,67 +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_state battery charging state battery name (BAT0) - * NULL on OpenBSD/FreeBSD - * battery_remaining battery remaining HH:MM battery name (BAT0) - * NULL on OpenBSD/FreeBSD - * cpu_perc cpu usage in percent NULL - * cpu_freq cpu frequency in MHz 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/bar/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 bar) - * 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) - * wifi_perc WiFi signal in percent interface name (wlan0) - * wifi_essid WiFi ESSID interface name (wlan0) - */ -static const struct arg args[] = { - /* function format argument */ - { datetime, "%s", "%F %T" }, -}; diff --git a/.suckless/slstatus/config.h b/.suckless/slstatus/config.h deleted file mode 100644 index fb100b4..0000000 --- a/.suckless/slstatus/config.h +++ /dev/null @@ -1,70 +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_state battery charging state battery name (BAT0) - * NULL on OpenBSD/FreeBSD - * battery_remaining battery remaining HH:MM battery name (BAT0) - * NULL on OpenBSD/FreeBSD - * cpu_perc cpu usage in percent NULL - * cpu_freq cpu frequency in MHz 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 - * getmpdstat retrieve mpd status 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/bar/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 bar) - * 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) - * wifi_perc WiFi signal in percent interface name (wlan0) - * wifi_essid WiFi ESSID interface name (wlan0) - */ -static const struct arg args[] = { - /* function format argument */ - { wifi_essid, "%s | ", "wlan0" }, - { battery_perc, "%s% | ", "BAT0" }, - { datetime, "%s", "%a %d %R" }, -}; diff --git a/.suckless/slstatus/config.mk b/.suckless/slstatus/config.mk deleted file mode 100644 index 3b32b7c..0000000 --- a/.suckless/slstatus/config.mk +++ /dev/null @@ -1,20 +0,0 @@ -# slstatus version -VERSION = 0 - -# customize below to fit your system - -# paths -PREFIX = /usr/local -MANPREFIX = $(PREFIX)/share/man - -X11INC = /usr/X11R6/include -X11LIB = /usr/X11R6/lib - -# flags -CPPFLAGS = -I$(X11INC) -D_DEFAULT_SOURCE -CFLAGS = -std=c99 -pedantic -Wall -Wextra -Os -LDFLAGS = -L$(X11LIB) -s -LDLIBS = -lX11 - -# compiler and linker -CC = cc diff --git a/.suckless/slstatus/slstatus.1 b/.suckless/slstatus/slstatus.1 deleted file mode 100644 index da1a99a..0000000 --- a/.suckless/slstatus/slstatus.1 +++ /dev/null @@ -1,25 +0,0 @@ -.Dd 2017-08-10 -.Dt SLSTATUS 1 -.Os -.Sh NAME -.Nm slstatus -.Nd suckless status monitor -.Sh SYNOPSIS -.Nm -.Op Fl s -.Sh DESCRIPTION -.Nm -is a suckless status monitor for window managers that use WM_NAME (e.g. dwm) or -stdin to fill the status bar. -By default, -.Nm -outputs to WM_NAME. -.Sh OPTIONS -.Bl -tag -width Ds -.It Fl s -Write to stdout instead of WM_NAME. -.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. diff --git a/.suckless/slstatus/slstatus.c b/.suckless/slstatus/slstatus.c deleted file mode 100644 index 96fa5b6..0000000 --- a/.suckless/slstatus/slstatus.c +++ /dev/null @@ -1,137 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include -#include -#include -#include -#include - -#include "arg.h" -#include "slstatus.h" -#include "util.h" - -struct arg { - const char *(*func)(); - const char *fmt; - const char *args; -}; - -char buf[1024]; -static int done; -static Display *dpy; - -#include "config.h" - -static void -terminate(const int signo) -{ - (void)signo; - - 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 [-s]", 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 '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); - - if (!sflag && !(dpy = XOpenDisplay(NULL))) { - die("XOpenDisplay: Failed to open display"); - } - - while (!done) { - 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) { - if (nanosleep(&wait, NULL) < 0 && - errno != EINTR) { - die("nanosleep:"); - } - } - } - } - - if (!sflag) { - XStoreName(dpy, DefaultRootWindow(dpy), NULL); - if (XCloseDisplay(dpy) < 0) { - die("XCloseDisplay: Failed to close display"); - } - } - - return 0; -} diff --git a/.suckless/slstatus/slstatus.h b/.suckless/slstatus/slstatus.h deleted file mode 100644 index 08f610a..0000000 --- a/.suckless/slstatus/slstatus.h +++ /dev/null @@ -1,81 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* battery */ -const char *battery_perc(const char *); -const char *battery_state(const char *); -const char *battery_remaining(const char *); - -/* cpu */ -const char *cpu_freq(void); -const char *cpu_perc(void); - -/* 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(void); - -/* hostname */ -const char *hostname(void); - -/* ip */ -const char *ipv4(const char *interface); -const char *ipv6(const char *interface); - -/* kernel_release */ -const char *kernel_release(void); - -/* keyboard_indicators */ -const char *keyboard_indicators(void); - -/* keymap */ -const char *keymap(void); - -/* load_avg */ -const char *load_avg(void); - -/* 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(void); -const char *ram_perc(void); -const char *ram_total(void); -const char *ram_used(void); - -/* run_command */ -const char *run_command(const char *cmd); - -/* swap */ -const char *swap_free(void); -const char *swap_perc(void); -const char *swap_total(void); -const char *swap_used(void); - -/* temperature */ -const char *temp(const char *); - -/* uptime */ -const char *uptime(void); - -/* user */ -const char *gid(void); -const char *username(void); -const char *uid(void); - -/* volume */ -const char *vol_perc(const char *card); - -/* wifi */ -const char *wifi_perc(const char *interface); -const char *wifi_essid(const char *interface); diff --git a/.suckless/slstatus/util.c b/.suckless/slstatus/util.c deleted file mode 100644 index 85366bf..0000000 --- a/.suckless/slstatus/util.c +++ /dev/null @@ -1,146 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include -#include -#include -#include -#include -#include - -#include "util.h" - -char *argv0; - -static void -verr(const char *fmt, va_list ap) -{ - if (argv0 && strncmp(fmt, "usage", sizeof("usage") - 1)) { - fprintf(stderr, "%s: ", argv0); - } - - vfprintf(stderr, fmt, ap); - - if (fmt[0] && fmt[strlen(fmt) - 1] == ':') { - fputc(' ', stderr); - perror(NULL); - } else { - fputc('\n', stderr); - } -} - -void -warn(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - verr(fmt, ap); - va_end(ap); -} - -void -die(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - verr(fmt, ap); - va_end(ap); - - exit(1); -} - -static int -evsnprintf(char *str, size_t size, const char *fmt, va_list ap) -{ - int ret; - - ret = vsnprintf(str, size, fmt, ap); - - if (ret < 0) { - warn("vsnprintf:"); - return -1; - } else if ((size_t)ret >= size) { - warn("vsnprintf: Output truncated"); - return -1; - } - - return ret; -} - -int -esnprintf(char *str, size_t size, const char *fmt, ...) -{ - va_list ap; - int ret; - - va_start(ap, fmt); - ret = evsnprintf(str, size, fmt, ap); - va_end(ap); - - return ret; -} - -const char * -bprintf(const char *fmt, ...) -{ - va_list ap; - int ret; - - va_start(ap, fmt); - ret = evsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - - return (ret < 0) ? NULL : buf; -} - -const char * -fmt_human(uintmax_t num, int base) -{ - double scaled; - size_t i, prefixlen; - const char **prefix; - const char *prefix_1000[] = { "", "k", "M", "G", "T", "P", "E", "Z", - "Y" }; - const char *prefix_1024[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", - "Zi", "Yi" }; - - switch (base) { - case 1000: - prefix = prefix_1000; - prefixlen = LEN(prefix_1000); - break; - case 1024: - prefix = prefix_1024; - prefixlen = LEN(prefix_1024); - break; - default: - warn("fmt_human: Invalid base"); - return NULL; - } - - scaled = num; - for (i = 0; i < prefixlen && scaled >= base; i++) { - scaled /= base; - } - - return bprintf("%.1f %s", scaled, prefix[i]); -} - -int -pscanf(const char *path, const char *fmt, ...) -{ - FILE *fp; - va_list ap; - int n; - - if (!(fp = fopen(path, "r"))) { - warn("fopen '%s':", path); - return -1; - } - va_start(ap, fmt); - n = vfscanf(fp, fmt, ap); - va_end(ap); - fclose(fp); - - return (n == EOF) ? -1 : n; -} diff --git a/.suckless/slstatus/util.h b/.suckless/slstatus/util.h deleted file mode 100644 index 7f1f26c..0000000 --- a/.suckless/slstatus/util.h +++ /dev/null @@ -1,16 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include - -extern char buf[1024]; - -#define LEN(x) (sizeof (x) / sizeof *(x)) - -extern char *argv0; - -void warn(const char *, ...); -void die(const char *, ...); - -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, ...);