adding bar directly to dwm through utils

This commit is contained in:
DarthMooMancer
2025-09-12 23:14:12 -04:00
parent 805d64bb14
commit 196178abe8
6 changed files with 26 additions and 30 deletions
+24
View File
@@ -5,6 +5,30 @@
#include "util.h"
const char* vol() {
static char buf[5];
float v;
FILE *fp = popen("wpctl get-volume @DEFAULT_AUDIO_SINK@", "r");
if (!fp || fscanf(fp, "Volume: %f", &v) != 1) return NULL;
pclose(fp);
snprintf(buf, sizeof(buf), "%d%%", (int)(v * 100));
return buf;
}
const char* age() {
static char buf[5];
int days;
FILE *fp = popen("sh -c 'echo $(( ( $(date +%s) - $(stat -c %W /) ) / 86400 ))'", "r");
if (!fp || fscanf(fp, "%d", &days) != 1) return NULL;
pclose(fp);
snprintf(buf, sizeof(buf), "%dd", days);
return buf;
}
void execute_bar(char *out, size_t len) {
snprintf(out, len, "V: %s A: %s", vol(), age());
}
void die(const char *fmt, ...) {
va_list ap;