[Pkg-wmaker-commits] [wmifs] 85/118: wmifs: Add -c command line option allowing users to set color.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Thu Aug 27 02:37:54 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmifs.

commit 0b5c53eee5be8c87d2cc2c66a7fccc51499eb206
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Wed May 27 17:33:19 2015 -0500

    wmifs: Add -c command line option allowing users to set color.
---
 wmifs.1 |  3 +++
 wmifs.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/wmifs.1 b/wmifs.1
index d22b954..42f4b1b 100644
--- a/wmifs.1
+++ b/wmifs.1
@@ -54,6 +54,9 @@ Scrolling interval, in seconds (default: 5)
 .TP
 .B \-w
 Use the waveform graph instead of the classic one.
+.TP
+.B \-c <color>
+Set color.
 
 .SH FILES
 .TP
diff --git a/wmifs.c b/wmifs.c
index 5a080da..1344405 100644
--- a/wmifs.c
+++ b/wmifs.c
@@ -255,6 +255,8 @@ int		WaveForm = 0;
 int		LockMode = 0;
 int		SampleInt = DEFAULT_SAMPLE_INTERVAL;
 int		ScrollSpeed = CHECK_INTERFACE_INTERVAL;
+XpmIcon wmgen;
+char color[256];
 
   /*****************/
  /* PPP variables */
@@ -296,6 +298,7 @@ int main(int argc, char *argv[])
 
 	int		i;
 
+	color[0] = 0;
 
 	/* Parse Command Line */
 
@@ -304,6 +307,12 @@ int main(int argc, char *argv[])
 
 		if (*arg == '-') {
 			switch (arg[1]) {
+			case 'c' :
+				if (argc > i+1) {
+					strcpy(color, argv[i+1]);
+					i++;
+				}
+				break;
 			case 'd':
 				if (strcmp(arg+1, "display")) {
 					usage();
@@ -344,6 +353,21 @@ int main(int argc, char *argv[])
 	return 0;
 }
 
+Pixel scale_pixel(Pixel pixel, float scale)
+{
+       int red, green, blue;
+
+       red = pixel / ( 1 << 16 );
+       green = pixel % (1 << 16) / (1 << 8);
+       blue = pixel % (1 << 8);
+
+       red *= scale;
+       green *= scale;
+       blue *= scale;
+
+       return red * (1 << 16) + green * (1 << 8) + blue;
+}
+
 /*******************************************************************************\
 |* wmifs_routine															   *|
 \*******************************************************************************/
@@ -443,6 +467,54 @@ void wmifs_routine(int argc, char **argv)
 
 	parse_rcfile("/etc/wmifsrc.fixed", wmifs_keys);
 
+       /* set user-defined colors */
+       if (color[0] != 0) {
+               Window  Root;
+               XColor col;
+               XWindowAttributes attributes;
+               int screen;
+               Pixel pixel;
+#define NUMSYMBOLS 4
+               XpmColorSymbol user_color[NUMSYMBOLS] = {
+                       {NULL, "#2081B2CAAEBA", 0}, /* + */
+                       {NULL, "#28A23CF338E3", 0}, /* O */
+                       {NULL, "#000049244103", 0}, /* @ */
+                       {NULL, "#18618A288617", 0}, /* # */
+                        };
+
+
+               /* code based on GetColor() from wmgeneral.c */
+               /* we need a temporary display to parse the color */
+               display = XOpenDisplay(NULL);
+               screen = DefaultScreen(display);
+               Root = RootWindow(display, screen);
+               XGetWindowAttributes(display, Root, &attributes);
+
+               col.pixel = 0;
+               if (!XParseColor(display, attributes.colormap, color, &col)) {
+                       fprintf(stderr, "wmtime: can't parse %s.\n", color);
+                       goto draw_window;
+               } else if (!XAllocColor(display, attributes.colormap, &col)) {
+                       fprintf(stderr, "wmtime: can't allocate %s.\n", color);
+                       goto draw_window;
+               }
+
+               pixel = col.pixel;
+
+               /* replace colors from wmtime-master.xpm */
+               user_color[0].pixel = pixel;
+               user_color[1].pixel = scale_pixel(pixel, .3);
+               user_color[2].pixel = scale_pixel(pixel, .4);
+               user_color[3].pixel = scale_pixel(pixel, .8);
+
+               wmgen.attributes.valuemask |= XpmColorSymbols;
+               wmgen.attributes.numsymbols = NUMSYMBOLS;
+               wmgen.attributes.colorsymbols = user_color;
+
+               XCloseDisplay(display);
+       }
+
+draw_window:
 	openXwindow(argc, argv, wmifs_master_xpm, (char*)wmifs_mask_bits, wmifs_mask_width, wmifs_mask_height);
 
 	/* > Button */
@@ -937,6 +1009,7 @@ void usage(void)
 	fprintf(stderr, "\t-s <interval>\tscrolling interval, in seconds (default: 5)\n");
 	fprintf(stderr, "\t-v\tprint the version number\n");
 	fprintf(stderr, "\t-w\twaveform load\n");
+	fprintf(stderr, "\t-c <color>\tset color\n");
 	fprintf(stderr, "\n");
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmifs.git



More information about the Pkg-wmaker-commits mailing list