wmload: Remove trailing whitespace.

This commit is contained in:
Doug Torrance 2015-04-07 02:45:18 -05:00 committed by Carlos R. Mafra
parent d5e87688a3
commit 4aedbc5823

View file

@ -32,7 +32,7 @@ int ONLYSHAPE=0; /* default value is noshape */
int updatespeed = 4; int updatespeed = 4;
static char *help_message[] = { static char *help_message[] = {
"where options include:", "where options include:",
" -u <secs> updatespeed", " -u <secs> updatespeed",
" -exe <program> program to start on click", " -exe <program> program to start on click",
" -led <color> color of the led", " -led <color> color of the led",
" -position [+|-]x[+|-]y position of wmload", " -position [+|-]x[+|-]y position of wmload",
@ -98,7 +98,7 @@ void usage()
/* /*
* Copied from ascpu - albert@tigr.net - 09 Mar 2000 * Copied from ascpu - albert@tigr.net - 09 Mar 2000
* *
* This function executes an external command while * This function executes an external command while
* checking whether we should drop the privileges. * checking whether we should drop the privileges.
* *
* Since we might need privileges later we fork and * Since we might need privileges later we fork and
@ -127,19 +127,19 @@ void ExecuteExternal()
} }
pid = fork(); pid = fork();
if ( pid == -1 ) { if ( pid == -1 ) {
printf("asload : fork() failed (%s), command not executed", printf("asload : fork() failed (%s), command not executed",
strerror(errno)); strerror(errno));
return; return;
} }
if ( pid != 0 ) { if ( pid != 0 ) {
/* parent process simply waits for the child and continues */ /* parent process simply waits for the child and continues */
if ( waitpid(pid, 0, 0) == -1 ) { if ( waitpid(pid, 0, 0) == -1 ) {
printf("asload : waitpid() for child failed (%s)", printf("asload : waitpid() for child failed (%s)",
strerror(errno)); strerror(errno));
} }
return; return;
} }
/* /*
* child process drops the privileges * child process drops the privileges
* executes the command and dies * executes the command and dies
*/ */
@ -155,7 +155,7 @@ int main(int argc,char *argv[])
{ {
int i; int i;
unsigned int borderwidth ; unsigned int borderwidth ;
char *display_name = NULL; char *display_name = NULL;
char *wname = "wmload"; char *wname = "wmload";
XGCValues gcv; XGCValues gcv;
unsigned long gcm; unsigned long gcm;
@ -217,12 +217,12 @@ int main(int argc,char *argv[])
} }
/* Open the display */ /* Open the display */
if (!(dpy = XOpenDisplay(display_name))) if (!(dpy = XOpenDisplay(display_name)))
{ {
fprintf(stderr,"wmload: can't open display %s\n", fprintf(stderr,"wmload: can't open display %s\n",
XDisplayName(display_name)); XDisplayName(display_name));
exit (1); exit (1);
} }
screen= DefaultScreen(dpy); screen= DefaultScreen(dpy);
Root = RootWindow(dpy, screen); Root = RootWindow(dpy, screen);
@ -232,7 +232,7 @@ int main(int argc,char *argv[])
/* Convert XPM Data to XImage */ /* Convert XPM Data to XImage */
GetXPM(); GetXPM();
/* Create a window to hold the banner */ /* Create a window to hold the banner */
mysizehints.flags= USSize|USPosition; mysizehints.flags= USSize|USPosition;
mysizehints.x = 0; mysizehints.x = 0;
@ -242,7 +242,7 @@ int main(int argc,char *argv[])
fore_pix = GetColor("black"); fore_pix = GetColor("black");
XWMGeometry(dpy, screen, Geometry, NULL, (borderwidth =1), &mysizehints, XWMGeometry(dpy, screen, Geometry, NULL, (borderwidth =1), &mysizehints,
&mysizehints.x,&mysizehints.y,&mysizehints.width,&mysizehints.height, &i); &mysizehints.x,&mysizehints.y,&mysizehints.width,&mysizehints.height, &i);
mysizehints.width = wmload.attributes.width; mysizehints.width = wmload.attributes.width;
mysizehints.height= wmload.attributes.height; mysizehints.height= wmload.attributes.height;
@ -263,19 +263,19 @@ int main(int argc,char *argv[])
XSelectInput(dpy,win,MW_EVENTS); XSelectInput(dpy,win,MW_EVENTS);
XSelectInput(dpy,iconwin,MW_EVENTS); XSelectInput(dpy,iconwin,MW_EVENTS);
XSetCommand(dpy,win,argv,argc); XSetCommand(dpy,win,argv,argc);
if (XStringListToTextProperty(&wname, 1, &name) ==0) { if (XStringListToTextProperty(&wname, 1, &name) ==0) {
fprintf(stderr, "wmload: can't allocate window name\n"); fprintf(stderr, "wmload: can't allocate window name\n");
exit(-1); exit(-1);
} }
XSetWMName(dpy, win, &name); XSetWMName(dpy, win, &name);
/* Create a GC for drawing */ /* Create a GC for drawing */
gcm = GCForeground|GCBackground|GCGraphicsExposures; gcm = GCForeground|GCBackground|GCGraphicsExposures;
gcv.foreground = fore_pix; gcv.foreground = fore_pix;
gcv.background = back_pix; gcv.background = back_pix;
gcv.graphics_exposures = FALSE; gcv.graphics_exposures = FALSE;
NormalGC = XCreateGC(dpy, Root, gcm, &gcv); NormalGC = XCreateGC(dpy, Root, gcm, &gcv);
if (ONLYSHAPE) { /* try to make shaped window here */ if (ONLYSHAPE) { /* try to make shaped window here */
pixmask = XCreateBitmapFromData(dpy, win, (char *)mask2_bits, mask2_width, pixmask = XCreateBitmapFromData(dpy, win, (char *)mask2_bits, mask2_width,
@ -283,14 +283,14 @@ int main(int argc,char *argv[])
XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, pixmask, ShapeSet); XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet); XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
} }
mywmhints.icon_window = iconwin; mywmhints.icon_window = iconwin;
mywmhints.icon_x = mysizehints.x; mywmhints.icon_x = mysizehints.x;
mywmhints.icon_y = mysizehints.y; mywmhints.icon_y = mysizehints.y;
mywmhints.window_group = win; mywmhints.window_group = win;
mywmhints.flags = StateHint | IconWindowHint | IconPositionHint mywmhints.flags = StateHint | IconWindowHint | IconPositionHint
| WindowGroupHint; | WindowGroupHint;
XSetWMHints(dpy, win, &mywmhints); XSetWMHints(dpy, win, &mywmhints);
XSetWMProtocols (dpy, win, &_XA_WM_DELETE_WINDOW, 1); XSetWMProtocols (dpy, win, &_XA_WM_DELETE_WINDOW, 1);
XMapWindow(dpy,win); XMapWindow(dpy,win);
@ -302,13 +302,13 @@ int main(int argc,char *argv[])
if (actualtime != time(0)) if (actualtime != time(0))
{ {
actualtime = time(0); actualtime = time(0);
if(actualtime % updatespeed == 0) if(actualtime % updatespeed == 0)
InsertLoad(); InsertLoad();
RedrawWindow(&visible); RedrawWindow(&visible);
} }
/* read a packet */ /* read a packet */
while (XPending(dpy)) while (XPending(dpy))
{ {
@ -331,10 +331,10 @@ int main(int argc,char *argv[])
XDestroyWindow(dpy, iconwin); XDestroyWindow(dpy, iconwin);
XDestroyWindow(dpy, win); XDestroyWindow(dpy, win);
XCloseDisplay(dpy); XCloseDisplay(dpy);
exit(0); exit(0);
break ; break ;
default: default:
break; break;
} }
} }
XFlush(dpy); XFlush(dpy);
@ -370,7 +370,7 @@ void GetXPM(void)
XGetWindowAttributes(dpy,Root,&attributes); XGetWindowAttributes(dpy,Root,&attributes);
/* get user-defined color or validate the default */ /* get user-defined color or validate the default */
if (!XParseColor (dpy, attributes.colormap, LedColor, &col)) if (!XParseColor (dpy, attributes.colormap, LedColor, &col))
{ {
nocolor("parse",LedColor); nocolor("parse",LedColor);
} }
@ -398,15 +398,15 @@ void GetXPM(void)
sprintf(tempc3, "Q c #%.2x%.2x%.2x", (int)colr, (int)colg, (int)colb); sprintf(tempc3, "Q c #%.2x%.2x%.2x", (int)colr, (int)colg, (int)colb);
back_xpm[45] = tempc3; back_xpm[45] = tempc3;
} }
wmload.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions); wmload.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
ret = XpmCreatePixmapFromData(dpy, Root, alt_xpm, &wmload.pixmap, ret = XpmCreatePixmapFromData(dpy, Root, alt_xpm, &wmload.pixmap,
&wmload.mask, &wmload.attributes); &wmload.mask, &wmload.attributes);
if(ret != XpmSuccess) if(ret != XpmSuccess)
{fprintf(stderr, "%s\n", ERR_colorcells);exit(1);} {fprintf(stderr, "%s\n", ERR_colorcells);exit(1);}
visible.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions); visible.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
ret = XpmCreatePixmapFromData(dpy, Root, back_xpm, &visible.pixmap, ret = XpmCreatePixmapFromData(dpy, Root, back_xpm, &visible.pixmap,
&visible.mask, &visible.attributes); &visible.mask, &visible.attributes);
if(ret != XpmSuccess) if(ret != XpmSuccess)
{fprintf(stderr, "%s\n", ERR_colorcells);exit(1);} {fprintf(stderr, "%s\n", ERR_colorcells);exit(1);}
@ -419,7 +419,7 @@ int flush_expose (Window w)
{ {
XEvent dummy; XEvent dummy;
int i=0; int i=0;
while (XCheckTypedWindowEvent (dpy, w, Expose, &dummy))i++; while (XCheckTypedWindowEvent (dpy, w, Expose, &dummy))i++;
return i; return i;
} }
@ -445,11 +445,11 @@ Pixel GetColor(char *name)
XGetWindowAttributes(dpy,Root,&attributes); XGetWindowAttributes(dpy,Root,&attributes);
color.pixel = 0; color.pixel = 0;
if (!XParseColor (dpy, attributes.colormap, name, &color)) if (!XParseColor (dpy, attributes.colormap, name, &color))
{ {
nocolor("parse",name); nocolor("parse",name);
} }
else if(!XAllocColor (dpy, attributes.colormap, &color)) else if(!XAllocColor (dpy, attributes.colormap, &color))
{ {
nocolor("alloc",name); nocolor("alloc",name);
} }
@ -469,7 +469,7 @@ void InitLoad()
/* Remove the 4 base colors from visible */ /* Remove the 4 base colors from visible */
XCopyArea(dpy, visible.pixmap, visible.pixmap, NormalGC, XCopyArea(dpy, visible.pixmap, visible.pixmap, NormalGC,
Shape(9),Shape(6),3,52, Shape(6), Shape(6)); Shape(9),Shape(6),3,52, Shape(6), Shape(6));
} }
static char * static char *
@ -481,7 +481,7 @@ skip_token(const char *p)
} }
void GetLoad(int Maximum, int *usr, int *nice, int *sys, int *free) void GetLoad(int Maximum, int *usr, int *nice, int *sys, int *free)
{ {
char buffer[100];/*[4096+1];*/ char buffer[100];/*[4096+1];*/
int fd, len; int fd, len;
int total; int total;
@ -491,7 +491,7 @@ void GetLoad(int Maximum, int *usr, int *nice, int *sys, int *free)
len = read(fd, buffer, sizeof(buffer)-1); len = read(fd, buffer, sizeof(buffer)-1);
close(fd); close(fd);
buffer[len] = '\0'; buffer[len] = '\0';
p = skip_token(buffer); /* "cpu" */ p = skip_token(buffer); /* "cpu" */
cp_time[0] = strtoul(p, &p, 0); /* user */ cp_time[0] = strtoul(p, &p, 0); /* user */
@ -558,5 +558,5 @@ void InsertLoad()
/* Free Time */ /* Free Time */
if(FreeTime > 0) if(FreeTime > 0)
XCopyArea(dpy, wmload.pixmap, visible.pixmap, NormalGC, XCopyArea(dpy, wmload.pixmap, visible.pixmap, NormalGC,
Shape(9), Shape(6), 1, FreeTime, Shape(57), Shape(6)); Shape(9), Shape(6), 1, FreeTime, Shape(57), Shape(6));
} }