summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2022-10-03 20:33:32 +0200
committerTom Barrett <tom@tombarrett.xyz>2022-10-03 20:33:32 +0200
commit727c5167e71e594d7f0987fd999adaf43868b910 (patch)
tree0ff6b68f8936630cb9351ce5da607a3a3bcbb070
parent2a6648d9b6202af81caf689fa5f61a54d37d59e0 (diff)
update
-rw-r--r--dwm/custom.diff4
-rw-r--r--dwmstatus/custom.diff119
2 files changed, 48 insertions, 75 deletions
diff --git a/dwm/custom.diff b/dwm/custom.diff
index b5978be..12e1096 100644
--- a/dwm/custom.diff
+++ b/dwm/custom.diff
@@ -10,10 +10,10 @@ index 9fd0286..f1373cf 100644
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
-@@ -210,7 +211,6 @@ static void spawn(const Arg *arg);
+@@ -210,7 +210,6 @@ static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
- static void tile(Monitor *);
+ static void tile(Monitor *m);
-static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg);
diff --git a/dwmstatus/custom.diff b/dwmstatus/custom.diff
index 3d283b4..e4f37f1 100644
--- a/dwmstatus/custom.diff
+++ b/dwmstatus/custom.diff
@@ -1,5 +1,5 @@
diff --git a/dwmstatus.c b/dwmstatus.c
-index d2a4b03..2df2e0a 100644
+index ce7914a..793cff9 100644
--- a/dwmstatus.c
+++ b/dwmstatus.c
@@ -17,8 +17,6 @@
@@ -11,15 +11,14 @@ index d2a4b03..2df2e0a 100644
char *tzberlin = "Europe/Berlin";
static Display *dpy;
-@@ -89,134 +87,84 @@ loadavg(void)
+@@ -89,90 +87,7 @@ loadavg(void)
if (getloadavg(avgs, 3) < 0)
return smprintf("");
- return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
-+ return smprintf("%.2f", avgs[1]);
- }
-
- char *
+-}
+-
+-char *
-readfile(char *base, char *file)
-{
- char *path, line[513];
@@ -30,27 +29,17 @@ index d2a4b03..2df2e0a 100644
- path = smprintf("%s/%s", base, file);
- fd = fopen(path, "r");
- free(path);
-+getresult(char *command) {
-+ FILE *fd = popen(command, "r");
-+ char ret[100];
- if (fd == NULL)
+- if (fd == NULL)
- return NULL;
-+ strcpy(ret, "invalid");
-
+-
- if (fgets(line, sizeof(line)-1, fd) == NULL)
- return NULL;
- fclose(fd);
-+ if (fgets(ret, 100, fd) == NULL)
-+ strcpy(ret, "invalid");
-
+-
- return smprintf("%s", line);
-+ if (pclose(fd) == -1)
-+ strcpy(ret, "invalid");
-+
-+ return smprintf("%s", ret);
- }
-
- char *
+-}
+-
+-char *
-getbattery(char *base)
-{
- char *co, status;
@@ -97,103 +86,87 @@ index d2a4b03..2df2e0a 100644
-
- if (remcap < 0 || descap < 0)
- return smprintf("invalid");
-+getpartition(char *partition) {
-+ char *co = smprintf("df -lh | grep %s | tr -s ' ' | cut -d ' ' -f 4 | tr -d '\n'", partition);
-+ return getresult(co);
-+}
-
+-
- return smprintf("%.0f%%%c", ((float)remcap / (float)descap) * 100, status);
-+char *
-+gettemp() {
-+ char *co = smprintf("sensors amdgpu-pci-0400 | grep edge | cut -c 16-22 | tr -d '\n'");
-+ return getresult(co);
- }
-
- char *
+-}
+-
+-char *
-gettemperature(char *base, char *sensor)
-{
- char *co;
-+gettrack() {
-+ char *co = smprintf("mpc -h core-a.lan | head -n 1 | tr -d '\n'");
-+ return getresult(co);
-+}
-
+-
- co = readfile(base, sensor);
- if (co == NULL)
- return smprintf("");
- return smprintf("%02.0f°C", atof(co) / 1000);
-+char *
-+getips() {
-+ char *co = smprintf("ip a | grep 'inet ' | grep -v 127.0.0.1 | tr -s ' ' | cut -f 3 -d ' ' | tr '\n' ' '");
-+ return getresult(co);
++ return smprintf("%.2f", avgs[1]);
}
-+
- int
+ char *
+@@ -200,46 +115,38 @@ int
main(void)
{
char *status;
- char *avgs;
+- char *avgs;
- char *bat;
-- char *bat1;
- char *tmar;
- char *tmutc;
++ char *avg;
char *tmbln;
-- char *t0, *t1, *t2;
-+ char *partition;
-+ char *temp;
-+ char *track;
+- char *t0;
+- char *t1;
+- char *kbmap;
+ char *ips;
++ char *track;
++ char *temp;
++ char *partition;
if (!(dpy = XOpenDisplay(NULL))) {
fprintf(stderr, "dwmstatus: cannot open display.\n");
return 1;
}
-- for (;;sleep(60)) {
-+ for (;;sleep(1)) {
- avgs = loadavg();
+- for (;;sleep(30)) {
+- avgs = loadavg();
- bat = getbattery("/sys/class/power_supply/BAT0");
-- bat1 = getbattery("/sys/class/power_supply/BAT1");
- tmar = mktimes("%H:%M", tzargentina);
- tmutc = mktimes("%H:%M", tzutc);
- tmbln = mktimes("KW %W %a %d %b %H:%M %Z %Y", tzberlin);
-- t0 = gettemperature("/sys/devices/virtual/hwmon/hwmon0", "temp1_input");
-- t1 = gettemperature("/sys/devices/virtual/hwmon/hwmon2", "temp1_input");
-- t2 = gettemperature("/sys/devices/virtual/hwmon/hwmon4", "temp1_input");
+- kbmap = execscript("setxkbmap -query | grep layout | cut -d':' -f 2- | tr -d ' '");
+- t0 = gettemperature("/sys/devices/virtual/thermal/thermal_zone0", "temp");
+- t1 = gettemperature("/sys/devices/virtual/thermal/thermal_zone1", "temp");
-
-- status = smprintf("T:%s|%s|%s L:%s B:%s|%s A:%s U:%s %s",
-- t0, t1, t2, avgs, bat, bat1, tmar, tmutc,
+- status = smprintf("K:%s T:%s|%s L:%s B:%s A:%s U:%s %s",
+- kbmap, t0, t1, avgs, bat, tmar, tmutc,
- tmbln);
++ for (;;sleep(1)) {
++ avg = loadavg();
+ tmbln = mktimes("%a %d %b %H:%M", tzberlin);
-+ partition = getpartition("/$");
-+ temp = gettemp();
-+ track = gettrack();
-+ ips = getips();
++ ips = execscript("ip a | grep 'inet ' | grep -v 127.0.0.1 | tr -s ' ' |cut -f3 -d' '");
++ temp = execscript("sensors amdgpu-pci-0400 | grep edge | cut -c 16-22");
++ track = execscript("mpc -h core-a.lan | head -n 1 | grep -v volume || echo");
++ partition = execscript("df -lh | grep /dev/sda2 | tr -s ' ' | cut -d ' ' -f 4");
+
+ status = smprintf(" %s | %s | %s | %s | %s",
-+ track, avgs, temp, partition, tmbln);
++ track, avg, temp, partition, tmbln);
setstatus(status);
+- free(kbmap);
- free(t0);
- free(t1);
-- free(t2);
- free(avgs);
- free(bat);
-- free(bat1);
- free(tmar);
- free(tmutc);
++ free(avg);
+ free(tmbln);
+ free(ips);
+ free(track);
+ free(temp);
+ free(partition);
- free(tmbln);
-+ free(avgs);
free(status);
}
-
-@@ -224,4 +172,3 @@ main(void)
+-
+ XCloseDisplay(dpy);
return 0;
- }
--