/[antiright]/antiright/src/wmarmon/wmarmon.c
ViewVC logotype

Diff of /antiright/src/wmarmon/wmarmon.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by jefbed, Sun Jul 3 18:05:33 2005 UTC revision 1.5 by jefbed, Mon Jul 4 03:37:16 2005 UTC
# Line 1  Line 1 
1  /*  /*
2    AntiRight    AntiRight
3    (c) 2003-2005 Jeffrey Bedard    (c) 2003-2005 Jeffrey Bedard
4    jefbed@e-list.net    antiright@gmail.com
5        
6    This file is part of AntiRight.    This file is part of AntiRight.
7        
# Line 17  Line 17 
17        
18    You should have received a copy of the GNU General Public License    You should have received a copy of the GNU General Public License
19    along with AntiRight; if not, write to the Free Software    along with AntiRight; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
21      02110-1301  USA
22  */  */
23    
24  #include <X11/Xlib.h>  #include <X11/Xlib.h>
# Line 76  unsigned long Line 77  unsigned long
77  arshell_get_pixel(int red, int green, int blue)  arshell_get_pixel(int red, int green, int blue)
78  {  {
79    XColor color;    XColor color;
80    Colormap colormap=DefaultColormap(display, DefaultScreen(display));    Colormap colormap=DefaultColormap(display,
81                                        DefaultScreen(display));
82    color.flags=DoRed|DoGreen|DoBlue;    color.flags=DoRed|DoGreen|DoBlue;
83    color.red=red*256;    color.red=red*256;
84    color.green=green*256;    color.green=green*256;
# Line 133  expose() Line 135  expose()
135    XFillRectangle(display, iconwin, gc, 4, 4, 56, 56);    XFillRectangle(display, iconwin, gc, 4, 4, 56, 56);
136    arshell_set_font("5x7");    arshell_set_font("5x7");
137    arshell_set_foreground(250, 250, 250);    arshell_set_foreground(250, 250, 250);
138    XDrawString(display, iconwin, gc, 6, 16, hostname, strlen(hostname));    XDrawString(display, iconwin, gc, 6, 16,
139                  hostname, strlen(hostname));
140    asprintf(&string, "%sM fr/sw", swap);    asprintf(&string, "%sM fr/sw", swap);
141    arshell_set_foreground(250, 200, 200);    arshell_set_foreground(250, 200, 200);
142    XDrawString(display, iconwin, gc, 6, 24, string, strlen(string));    XDrawString(display, iconwin, gc, 6, 24,
143                  string, strlen(string));
144    free(string);    free(string);
145    asprintf(&string, "%s users", users);    asprintf(&string, "%s users", users);
146    arshell_set_foreground(200, 200, 250);    arshell_set_foreground(200, 200, 250);
147    XDrawString(display, iconwin, gc, 6, 32, string, strlen(string));    XDrawString(display, iconwin, gc, 6, 32,
148                  string, strlen(string));
149    free(string);    free(string);
150    arshell_set_foreground(200, 250, 200);    arshell_set_foreground(200, 250, 200);
151    asprintf(&string, "%d%% 1m", (int)(load[0]*100));    asprintf(&string, "%d%% 1m", (int)(load[0]*100));
152    XDrawString(display, iconwin, gc, 6, 40, string, strlen(string));    XDrawString(display, iconwin, gc, 6, 40,
153                  string, strlen(string));
154    free(string);    free(string);
155    asprintf(&string, "%d%% 5m", (int)(load[1]*100));    asprintf(&string, "%d%% 5m", (int)(load[1]*100));
156    XDrawString(display, iconwin, gc, 6, 48, string, strlen(string));    XDrawString(display, iconwin, gc, 6, 48,
157                  string, strlen(string));
158    free(string);    free(string);
159    asprintf(&string, "%d%% 15m", (int)(load[2]*100));    asprintf(&string, "%d%% 15m", (int)(load[2]*100));
160    XDrawString(display, iconwin, gc, 6, 56, string, strlen(string));    XDrawString(display, iconwin, gc, 6, 56,
161                  string, strlen(string));
162    free(string);    free(string);
163        
164    XFlush(display);    XFlush(display);
# Line 212  main(int argc, char **argv) Line 220  main(int argc, char **argv)
220    mysizehints.flags=USSize | USPosition;    mysizehints.flags=USSize | USPosition;
221    mysizehints.x = 0;    mysizehints.x = 0;
222    mysizehints.y = 0;    mysizehints.y = 0;
223    XWMGeometry(display, DefaultScreen(display), Geometry, NULL, 0, &mysizehints,    XWMGeometry(display, DefaultScreen(display), Geometry,
224                  NULL, 0, &mysizehints,
225                &mysizehints.x, &mysizehints.y,                &mysizehints.x, &mysizehints.y,
226                &mysizehints.width, &mysizehints.height, &dummy);                &mysizehints.width, &mysizehints.height, &dummy);
227    
228    mysizehints.width=64;    mysizehints.width=64;
229    mysizehints.height=64;    mysizehints.height=64;
230        
231    window=XCreateSimpleWindow(display, DefaultRootWindow(display),    window=XCreateSimpleWindow(display,
232                               mysizehints.x, mysizehints.y, mysizehints.width,                               DefaultRootWindow(display),
233                                 mysizehints.x, mysizehints.y,
234                                 mysizehints.width,
235                               mysizehints.height, 0,                               mysizehints.height, 0,
236                               BlackPixel(display, DefaultScreen(display)),                               BlackPixel(display,
237                               WhitePixel(display, DefaultScreen(display)));                                          DefaultScreen(display)),
238                                 WhitePixel(display,
239                                            DefaultScreen(display)));
240    iconwin=XCreateSimpleWindow(display, window,    iconwin=XCreateSimpleWindow(display, window,
241                                mysizehints.x, mysizehints.y, mysizehints.width,                                mysizehints.x, mysizehints.y,
242                                  mysizehints.width,
243                                mysizehints.height, 0,                                mysizehints.height, 0,
244                                BlackPixel(display, DefaultScreen(display)),                                BlackPixel(display,
245                                WhitePixel(display, DefaultScreen(display)));                                           DefaultScreen(display)),
246                                  WhitePixel(display,
247                                             DefaultScreen(display)));
248    XSetWMNormalHints(display, window, &mysizehints);    XSetWMNormalHints(display, window, &mysizehints);
249    classHint.res_name=wname;    classHint.res_name=wname;
250    classHint.res_class=wname;    classHint.res_class=wname;
# Line 237  main(int argc, char **argv) Line 253  main(int argc, char **argv)
253    XStoreName(display, window, "wmar");    XStoreName(display, window, "wmar");
254    XSelectInput(display, window, ButtonPressMask | ExposureMask    XSelectInput(display, window, ButtonPressMask | ExposureMask
255                 | ButtonReleaseMask                 | ButtonReleaseMask
256                 | PointerMotionMask | StructureNotifyMask | EnterWindowMask                 | PointerMotionMask | StructureNotifyMask
257                   | EnterWindowMask
258                 | LeaveWindowMask                 | LeaveWindowMask
259                 | KeyPressMask | KeyReleaseMask);                 | KeyPressMask | KeyReleaseMask);
260    XSelectInput(display, iconwin, ButtonPressMask | ExposureMask    XSelectInput(display, iconwin, ButtonPressMask | ExposureMask
261                 | ButtonReleaseMask                 | ButtonReleaseMask
262                 | PointerMotionMask | StructureNotifyMask | EnterWindowMask                 | PointerMotionMask | StructureNotifyMask
263                   | EnterWindowMask
264                 | LeaveWindowMask                 | LeaveWindowMask
265                 | KeyPressMask | KeyReleaseMask);                 | KeyPressMask | KeyReleaseMask);
266    gcm = GCForeground | GCBackground | GCGraphicsExposures;    gcm = GCForeground | GCBackground | GCGraphicsExposures;

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26