commit f26de94210d313b434b04b1a2085c078488e00a1
parent fcf2d39546f1208c0d7c470b614631045d373412
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 9 Dec 2017 14:00:22 +0100
whitespace fixes
Diffstat:
pomodoro.c | | | 85 | +++++++++++++++++++++++++++++++++++++++---------------------------------------- |
1 file changed, 42 insertions(+), 43 deletions(-)
diff --git a/pomodoro.c b/pomodoro.c
@@ -31,21 +31,19 @@ enum {FALSE, TRUE};
extern char *optarg;
-void usage (void);
-void take_break (unsigned int);
-Bool evpredicate (void);
-void record (FILE *);
+void usage(void);
+void take_break(unsigned int);
+Bool evpredicate(void);
+void record(FILE *);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
-
unsigned int break_period;
- int ch;
+ int ch;
unsigned int interactive_mode;
unsigned int pomodoro_period;
FILE *fp;
-
const char *str;
break_period = 15;
@@ -58,7 +56,7 @@ main (int argc, char **argv)
switch (ch) {
case 'b':
interactive_mode = FALSE;
- break_period = atoi(optarg);
+ break_period = atoi(optarg);
break;
case 'p':
interactive_mode = FALSE;
@@ -113,18 +111,18 @@ main (int argc, char **argv)
}
void
-usage (void)
+usage(void)
{
- fprintf(stderr,
- "usage: pomodoro [-b break_period] [-p pomodoro_period]\n"
- "-p\tspecify pomodoro period\n"
- "-b\tspecify break period\n"
- "-v\tshow version\n"
- );
+ fprintf(stderr,
+ "usage: pomodoro [-b break_period] [-p pomodoro_period]\n"
+ "-p\tspecify pomodoro period\n"
+ "-b\tspecify break period\n"
+ "-v\tshow version\n"
+ );
}
-void
-take_break (unsigned int bp)
+void
+take_break(unsigned int bp)
{
Display *d;
int dfd;
@@ -137,10 +135,11 @@ take_break (unsigned int bp)
const char *n = "pomodoro";
char *m = malloc(1024);
snprintf(m, 1024, "Take a %d min break!", bp);
- int s = DefaultScreen(d), ww = 128, wh = 64;
- Window w = XCreateSimpleWindow(d, RootWindow(d, s),
- DisplayWidth(d, s) / 2, DisplayHeight(d, s) / 2, ww, wh, 1,
- BlackPixel(d, s), 0x202020L);
+ int s = DefaultScreen(d), ww = 128, wh = 64;
+ Window w = XCreateSimpleWindow(d, RootWindow(d, s),
+ DisplayWidth(d, s) / 2,
+ DisplayHeight(d, s) / 2, ww, wh, 1,
+ BlackPixel(d, s), 0x202020L);
Atom ad = XInternAtom(d, "WM_DELETE_WINDOW", False),
an = XInternAtom(d, "_NET_WM_NAME", False),
ai = XInternAtom(d, "_NET_WM_ICON_NAME", False),
@@ -150,14 +149,14 @@ take_break (unsigned int bp)
XFontStruct *f = XLoadQueryFont(d, "-*-terminus-medium-*");
XEvent e;
XChangeProperty(d, w, an, au, 8, 0, (unsigned char *)n, strlen(n));
- XChangeProperty(d, w, ai, au, 8, 0, (unsigned char *)n, strlen(n));
- XSetTransientForHint(d, w, RootWindow(d, s));
- XSetWMProtocols(d , w, &ad, 1);
- XSelectInput(d, w, ExposureMask);
- if (f)
+ XChangeProperty(d, w, ai, au, 8, 0, (unsigned char *)n, strlen(n));
+ XSetTransientForHint(d, w, RootWindow(d, s));
+ XSetWMProtocols(d , w, &ad, 1);
+ XSelectInput(d, w, ExposureMask);
+ if (f)
XSetFont(d, gc, f->fid);
- XSetForeground(d, gc, 0xc0c0c0L);
- XMapWindow(d, w);
+ XSetForeground(d, gc, 0xc0c0c0L);
+ XMapWindow(d, w);
prevtime = time(NULL);
dfd = ConnectionNumber(d);
@@ -170,13 +169,13 @@ take_break (unsigned int bp)
err(1, "poll");
break;
case 0:
- fprintf(stderr, "case 0\n");
+ fprintf(stderr, "case 0\n");
break;
default:
- curtime = time(NULL);
+ curtime = time(NULL);
if (difftime(curtime,prevtime) >= bp * 60) {
free(m);
- XFreeGC(d, gc);
+ XFreeGC(d, gc);
XDestroyWindow(d, w);
XCloseDisplay(d);
return;
@@ -186,16 +185,16 @@ take_break (unsigned int bp)
while (XCheckIfEvent(d, &e, evpredicate, NULL)) {
switch (e.type) {
case Expose:
- XDrawString(d, w, gc, (ww - XTextWidth(f, m,
- strlen(m))) / 2, (wh + f->ascent +
- f->descent) / 2, m, strlen(m));
- break;
+ XDrawString(d, w, gc, (ww - XTextWidth(f, m,
+ strlen(m))) / 2, (wh + f->ascent +
+ f->descent) / 2, m, strlen(m));
+ break;
case ClientMessage:
- free(m);
- XFreeGC(d, gc);
- XDestroyWindow(d, w);
- XCloseDisplay(d);
- return;
+ free(m);
+ XFreeGC(d, gc);
+ XDestroyWindow(d, w);
+ XCloseDisplay(d);
+ return;
}
break;
}
@@ -204,13 +203,13 @@ take_break (unsigned int bp)
}
Bool
-evpredicate (void)
+evpredicate(void)
{
return True;
}
void
-record (FILE *f)
+record(FILE *f)
{
const char *cmd = "date";
char *timestamp = malloc(128);