aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclsr <clsr@clsr.net>2018-12-27 10:37:07 +0100
committerclsr <clsr@clsr.net>2018-12-27 10:37:07 +0100
commitffd6ffe68781a88d2711399ef74772b7fa0ecdcb (patch)
treecfd7ed4556ba147cd4a9abaae733d88c6c49fb53
parentcedca7b8b843413217b399ea1323c727994237ce (diff)
downloaddwmclock-1.3.0.tar.gz
dwmclock-1.3.0.zip
Restore previous root window name on exitv1.3.0
-rw-r--r--README.md3
-rw-r--r--config.def.mk2
-rw-r--r--dwmclock.c17
3 files changed, 13 insertions, 9 deletions
diff --git a/README.md b/README.md
index 06f333b..e7b1e74 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,9 @@ Install dwmclock to `~/bin`:
make DESTDIR=$HOME PREFIX= install
+Install dwmclock to `~/.local/bin`:
+
+ make DESTDIR=$HOME PREFIX=/.local install
Usage
-----
diff --git a/config.def.mk b/config.def.mk
index 4265c82..2ce7e98 100644
--- a/config.def.mk
+++ b/config.def.mk
@@ -40,4 +40,4 @@ LDFLAGS+=$(shell pkg-config --libs x11)
DESTDIR?=/
PREFIX?=/usr/local
#DESTDIR?=~
-#PREFIX?=/local
+#PREFIX?=/.local
diff --git a/dwmclock.c b/dwmclock.c
index b409555..95d9679 100644
--- a/dwmclock.c
+++ b/dwmclock.c
@@ -81,6 +81,7 @@ int main(void)
Display *disp;
int screen;
Window root;
+ char *origname = NULL;
act.sa_handler = handler;
act.sa_flags = 0;
@@ -90,19 +91,16 @@ int main(void)
sigaction(SIGQUIT, &act, NULL);
sigaction(SIGTERM, &act, NULL);
-
disp = XOpenDisplay(NULL);
+ screen = DefaultScreen(disp);
+ root = RootWindow(disp, screen);
+ XFetchName(disp, root, &origname);
+
#ifdef BATTERY
for (i=0; !stop; ++i) {
#else
while (!stop) {
#endif /* BATTERY */
- if (!disp) {
- puts("Cannot open display!");
- return 1;
- }
- screen = DefaultScreen(disp);
- root = RootWindow(disp, screen);
#ifdef BATTERY
if (i % (BAT_REFRESH_SECONDS) == 0) {
curr = getnum(ENERGY_NOW) * MUL;
@@ -151,8 +149,11 @@ int main(void)
sleep(1);
#endif /* EXACT_SLEEP */
}
- XCloseDisplay(disp);
+ if (origname) {
+ XStoreName(disp, root, origname);
+ }
+ XCloseDisplay(disp);
return 0;
}