sxss

simple x screensaver
git clone git://git.ckyln.com/~cem/sxss
Log | Files | Refs | README | LICENSE

commit b1a886832478c46d71939d1cd67d9e98c70baa28
parent 5da4ea52b7fcd0811da9ee2c56287b64cc483312
Author: Cem Keylan <cem@ckyln.com>
Date:   Thu, 23 Jul 2020 11:55:33 +0300

sxss: change C coding-style

Diffstat:
Msxss.c | 81+++++++++++++++++++++++++++++++++++++++++++------------------------------------
1 file changed, 44 insertions(+), 37 deletions(-)

diff --git a/sxss.c b/sxss.c @@ -1,60 +1,67 @@ /* * simple X screensaver */ -#include <unistd.h> -#include <stdlib.h> #include <stdio.h> +#include <stdlib.h> +#include <unistd.h> #include <X11/extensions/scrnsaver.h> +#include <xcb/xproto.h> #include "config.h" #define VERSION "0.1.0" -static void spawn(char *const argv[]) { - switch (fork()) { - case 0: - execvp(argv[0], argv); - perror("execvp"); - _exit(1); - case -1: - perror("fork"); - } +static void +spawn(char *const argv[]) +{ + switch (fork()) { + case 0: + execvp(argv[0], argv); + perror("execvp"); + _exit(1); + case -1: + perror("fork"); + } } -void die(const char *str) { - printf("%s\n", str); - exit(1); +static void +die(const char *str) +{ + printf("%s\n", str); + exit(1); } -int main(int argc, char *argv[]) { +int +main(int argc, char *argv[]) +{ - if (argc > 1) die("sxss-"VERSION); + if (argc > 1) die("sxss-"VERSION); - XScreenSaverInfo *info; - Display *dpy; - int base, errbase; + XScreenSaverInfo *info; + Display *dpy; + int base, errbase; - if(!(dpy = XOpenDisplay(0))) die("Cannot open display."); + if(!(dpy = XOpenDisplay(0))) die("Cannot open display."); - if (!XScreenSaverQueryExtension(dpy, &base, &errbase)) - die("Screensaver extension not activated."); + if (!XScreenSaverQueryExtension(dpy, &base, &errbase)) + die("Screensaver extension not activated."); - while(1) { + while(1) { - info = XScreenSaverAllocInfo(); - XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info); + info = XScreenSaverAllocInfo(); + XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info); - switch(info->state) { - case ScreenSaverDisabled: - sleep(10); - break; - case ScreenSaverOn: - break; - case ScreenSaverOff: - if (info->til_or_since < 1000) spawn(screensaver); - break; - } - sleep(1); - } + switch(info->state) { + case ScreenSaverDisabled: + sleep(10); + break; + case ScreenSaverOn: + break; + case ScreenSaverOff: + if (info->til_or_since < 1000) spawn(screensaver); + break; + } + sleep(1); + } }