summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dwmstatus/custom.diff55
1 files changed, 19 insertions, 36 deletions
diff --git a/dwmstatus/custom.diff b/dwmstatus/custom.diff
index 6b82e5f..14db8a7 100644
--- a/dwmstatus/custom.diff
+++ b/dwmstatus/custom.diff
@@ -1,5 +1,5 @@
diff --git a/dwmstatus.c b/dwmstatus.c
-index d2a4b03..307d290 100644
+index d2a4b03..4f09dde 100644
--- a/dwmstatus.c
+++ b/dwmstatus.c
@@ -17,8 +17,6 @@
@@ -29,59 +29,42 @@ index d2a4b03..307d290 100644
}
if (remcap < 0 || descap < 0)
-@@ -175,47 +173,86 @@ gettemperature(char *base, char *sensor)
+@@ -175,47 +173,69 @@ gettemperature(char *base, char *sensor)
return smprintf("%02.0f°C", atof(co) / 1000);
}
+char *
-+getpartition(char *partition) {
-+ char *co = smprintf("df -lh | grep %s | tr -s ' ' | cut -d ' ' -f 4 | tr -d '\n'", partition);
-+ FILE *fd = popen(co, "r");
++getresult(char *command) {
++ FILE *fd = popen(command, "r");
++ char ret[100];
+ if (fd == NULL)
-+ return smprintf("invalid");
++ strcpy(ret, "invalid");
+
-+ char ret[8];
-+ if (fgets(ret, 8, fd) == NULL)
-+ return smprintf("invalid");
++ if (fgets(ret, 100, fd) == NULL)
++ strcpy(ret, "invalid");
+
+ if (pclose(fd) == -1)
-+ return smprintf("invalid");
++ strcpy(ret, "invalid");
+
+ return smprintf("%s", ret);
+}
+
+char *
-+gettemp() {
-+ char *co = smprintf("sensors amdgpu-pci-0400 | grep edge | cut -c 16-22");
-+ FILE *fd = popen(co, "r");
-+ if (fd == NULL)
-+ return smprintf("invalid");
-+
-+ char ret[8];
-+ if (fgets(ret, 8, fd) == NULL)
-+ return smprintf("invalid");
-+
-+ if (pclose(fd) == -1)
-+ 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("%s", ret);
++char *
++gettemp() {
++ char *co = smprintf("sensors amdgpu-pci-0400 | grep edge | cut -c 16-22 | tr -d '\n'");
++ return getresult(co);
+}
+
+char *
+gettrack() {
-+ char *co = smprintf("mpc -h core-a.lan | head -n 1 | tr -d '\n'" );
-+ FILE *fd = popen(co, "r");
-+ if (fd == NULL)
-+ return smprintf("invalid");
-+
-+ char ret[100];
-+ if (fgets(ret, 100, fd) == NULL)
-+ return smprintf("invalid");
-+
-+ if (pclose(fd) == -1)
-+ return smprintf("invalid");
-+
-+ return smprintf("%s", ret);
++ char *co = smprintf("mpc -h core-a.lan | head -n 1 | tr -d '\n'");
++ return getresult(co);
+}
+
int