removed slstatus and just built it into dwm instead as it is really simple
This commit is contained in:
@@ -15,7 +15,7 @@ LDFLAGS = ${LIBS}
|
||||
|
||||
CC = gcc
|
||||
|
||||
SRC = drw.c dwm.c util.c
|
||||
SRC = bar.c drw.c dwm.c util.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: dwm
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "bar.h"
|
||||
#include <stdio.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());
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "util.h"
|
||||
void execute_bar(char *out, size_t len);
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#include "bar.h"
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -649,6 +650,7 @@ drawbar(Monitor *m)
|
||||
return;
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||
execute_bar(stext, sizeof(stext));
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
||||
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <stddef.h>
|
||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
||||
|
||||
Reference in New Issue
Block a user