aboutsummaryrefslogtreecommitdiff
path: root/util2.h
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-10-19 23:18:47 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-10-19 23:18:47 -0400
commit061085232ef35f956316812806875331f175acf7 (patch)
tree20ba4c170e48387f3f8cc45f45b9e11322bd3db3 /util2.h
parentfa7e4f7c0b1e5db1c14844535c91661504fd96bb (diff)
downloaddwm-061085232ef35f956316812806875331f175acf7.tar.gz
dwm-061085232ef35f956316812806875331f175acf7.tar.xz
Small patch to allow environment variables to be changed on the fly when DWM is reloaded.
Diffstat (limited to 'util2.h')
-rw-r--r--util2.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/util2.h b/util2.h
new file mode 100644
index 0000000..ab25acf
--- /dev/null
+++ b/util2.h
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <err.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+int
+readEnv(FILE *fh)
+{
+ int ret;
+ char name[1024], value[8192];
+
+ while (1) {
+ if ((ret = fscanf(fh, "%1023[^=]=%8191[^\n]\n", &name, &value)) == EOF)
+ break;
+ else if (ret == 0)
+ break;
+
+ fprintf(stderr, "Setting: '%s' = '%s'\n", name, value);
+ setenv(name, value, 1);
+ }
+
+ return 0;
+}