aboutsummaryrefslogtreecommitdiffstats
path: root/dwmclock.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwmclock.c')
-rw-r--r--dwmclock.c17
1 files changed, 9 insertions, 8 deletions
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;
}