[Pkg-wmaker-commits] [wmfsm] 27/83: wmfsm: Add -a command line option to select appearance at runtime.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sun Aug 23 14:05:44 UTC 2015


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

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

commit d9f655cc21726649164f69b93fe9059ee5687ebc
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Thu Jan 22 00:22:13 2015 -0600

    wmfsm: Add -a command line option to select appearance at runtime.
    
    Also update Makefile to install appearance XPMs during "make install".
---
 wmfsm/Makefile.am |  4 +++-
 wmfsm/wmfsm.1     |  3 +++
 wmfsm/wmfsm.c     | 24 ++++++++++++++++++++++--
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/wmfsm/Makefile.am b/wmfsm/Makefile.am
index cf8d271..f315429 100644
--- a/wmfsm/Makefile.am
+++ b/wmfsm/Makefile.am
@@ -6,6 +6,8 @@ wmfsm_SOURCES = wmfsm.c getopt.c getopt1.c getopt.h
 endif
 wmfsm_LDADD = ../wmgeneral/libwmgeneral.a @LIBS@ @X11LIBS@ @X_LIBS@ @X_EXTRA_LIBS@
 man_MANS = wmfsm.1
-EXTRA_DIST = $(man_MANS) wmfsm_master_highcolor.xpm wmfsm_master_cyan.xpm wmfsm_master_lowcolor.xpm wmfsm_mask.xbm wmfsmrc.sample
+dist_pkgdata_DATA = wmfsm_master_highcolor.xpm wmfsm_master_cyan.xpm \
+	wmfsm_master_lowcolor.xpm
+EXTRA_DIST = $(man_MANS) wmfsm_mask.xbm wmfsmrc.sample
 CLEANFILES = wmfsm_master.xpm
 
diff --git a/wmfsm/wmfsm.1 b/wmfsm/wmfsm.1
index 93b0910..de691ff 100644
--- a/wmfsm/wmfsm.1
+++ b/wmfsm/wmfsm.1
@@ -34,6 +34,9 @@ Draw on the specified display.
 .IP "\fB\-d\fP, \fB\-\-delay\fP 	" 10
 Wait the specified number of milliseconds to redraw
 the window.
+.IP "\fB\-a\fP, \fB\-\-appearance\fP    " 10
+Select an appearance file.  Note that these files may be found in the wmfsm
+data directory, likely /usr/local/share/wmfsm or /usr/share/wmfsm.
 .SH "FILES"
 .PP
 You may exclude filesystems from being show by wmfsm
diff --git a/wmfsm/wmfsm.c b/wmfsm/wmfsm.c
index 01bf326..9f57aae 100644
--- a/wmfsm/wmfsm.c
+++ b/wmfsm/wmfsm.c
@@ -125,6 +125,7 @@ int blinkper = 95;
 char dummy[4096];
 char *myName;
 int delay = DELAY_10;
+char appearance[256] = "";
 
 int xpos[] = { 66, 71, 76, 81, 86, 91,	/* A B C D E F */
 	66, 71, 76, 81, 86, 91,	/* G H I J K L */
@@ -162,8 +163,10 @@ main(int argc, char *argv[])
 	int dx, dy;
 	char hostname[100];
 	int i, j, k;
+	int xpm_free = 0;
 	int c, on[9] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
 	struct statfs buffer;
+	char **pixmap;
 
 	/*
 	 *  Parse any command line arguments.
@@ -171,9 +174,21 @@ main(int argc, char *argv[])
 	myName = strdup(argv[0]);
 	ParseCMDLine(argc, argv);
 
+	if (appearance[0] == 0) {
+		pixmap = wmfsm_master_xpm;
+	} else {
+		if (XpmReadFileToData(appearance, &pixmap) != XpmSuccess) {
+			fprintf(stderr, "warning: could not read appearance file; using default.\n");
+			pixmap = wmfsm_master_xpm;
+		} else {
+			xpm_free = 1;
+		}
+	}
 
-	openXwindow(argc, argv, wmfsm_master_xpm, wmfsm_mask_bits, wmfsm_mask_width, wmfsm_mask_height);
+	openXwindow(argc, argv, pixmap, wmfsm_mask_bits, wmfsm_mask_width, wmfsm_mask_height);
 
+	if (xpm_free)
+		XpmFree(pixmap);
 
 #ifndef SVR4
 	if (gethostname(hostname, 100) != 0) {
@@ -401,16 +416,20 @@ ParseCMDLine(int argc, char *argv[])
 		{"blink", no_argument, &blink, 1},
 		{"noblink", no_argument, &blink, 0},
 		{"delay", required_argument, 0, 'd'},
+		{"appearance", required_argument, 0, 'a'},
 		{"help", no_argument, 0, 'h'},
 		{0, 0, 0, 0}
 	};
 	while (1) {
-		c = getopt_long(argc, argv, "bd:fhn", long_options, &option_index);
+		c = getopt_long(argc, argv, "a:bd:fhn", long_options, &option_index);
 		if (c == -1)
 			break;
 		switch (c) {
 		case 0:	/* If blink or noblink was toggled */
 			break;
+		case 'a':
+			strcpy(appearance, optarg);
+			break;
 		case 'b':
 			blink = 1;
 			break;
@@ -447,6 +466,7 @@ print_usage()
 	printf("\t--[no]blink\t\tBlinks if a filesystem is 95 percent full.\n");
 	printf("\t-display <Display>\tUse alternate X display.\n");
 	printf("\t--delay <number>, -d\tUse a delay that is not the default.\n");
+	printf("\t--appearance <file>, -a\tSelect an appearance file.\n");
 	printf("\t-h\t\t\tDisplay help screen.\n");
 }
 

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



More information about the Pkg-wmaker-commits mailing list