aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTudor Roman2017-02-15 21:00:10 +0200
committerTudor Roman2017-02-15 21:00:10 +0200
commit58bca360f6b30f4f064465603c34cd3ad6b426ee (patch)
tree9c3ee5f1e9ff65e1453bad44e4db799dee5e5ac2
parenta4ad7ef8725beee6e645f5a67f424910c46bd999 (diff)
downloadruler-58bca360f6b30f4f064465603c34cd3ad6b426ee.tar.gz
ruler-58bca360f6b30f4f064465603c34cd3ad6b426ee.zip
added -v flag: print version information
-rw-r--r--Makefile5
-rw-r--r--VERSION1
-rw-r--r--man/ruler.16
-rw-r--r--man/ruler.1.html3
-rw-r--r--man/ruler.1.md5
-rw-r--r--ruler.c12
-rw-r--r--ruler.h9
-rw-r--r--rulerrc (renamed from test)4
8 files changed, 38 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 352fc79..d1d5a0d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,14 @@
include config.mk
+VERCMD ?= git describe 2> /dev/null
+
NAME = ruler
+VERSION = $(shell $(VERCMD) || cat VERSION)
all: $(NAME)
$(NAME): ruler.c lex.yy.c y.tab.c
- clang $^ $(CFLAGS) $(LDFLAGS) -o ruler
+ clang $^ $(CFLAGS) $(LDFLAGS) -DNAME=\"$(NAME)\" -DVERSION=\"$(VERSION)\" -o ruler
%.tab.c %.tab.h: parser.y
yacc $<
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..49d5957
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.1
diff --git a/man/ruler.1 b/man/ruler.1
index 20c0f5b..a3adf7b 100644
--- a/man/ruler.1
+++ b/man/ruler.1
@@ -38,6 +38,10 @@ Apply rules when windows change their properties\.
\fB\-s\fR \fIshell\fR
Execute rule commands with \fIshell\fR\.
.
+.TP
+\fB\-v\fR
+Print version information\.
+.
.SH "BEHAVIOR"
\fBruler\fR is a program that listens to X window events and applies a set of rules on windows that match them\. A rule is made from two parts: a list of descriptors and a command, that is piped to an interpreter (\fB$SHELL\fR by default)\.
.
@@ -103,7 +107,7 @@ CRITERION_i := class | instance | type | name | role
If \fBCOMMAND\fR is preceded by a \fB;\fR, the command will be run synchronously, otherwise it will be run asynchronously\.
.
.P
-\fBCOMMAND\fR will be executed by the shell set in the \fBSHELL\fR environment variable\. The window id will be set in the \fBRULER_ID\fR environment variable\.
+\fBCOMMAND\fR will be executed by the shell set in the \fBSHELL\fR environment variable\. The window id will be set in the \fBRULER_WID\fR environment variable\.
.
.P
\fBCRITERION\fR can be:
diff --git a/man/ruler.1.html b/man/ruler.1.html
index fbcad9a..3076bbd 100644
--- a/man/ruler.1.html
+++ b/man/ruler.1.html
@@ -93,6 +93,7 @@ specific windows, called <em>rules</em>.</p>
<dt class="flush"><code>-o</code></dt><dd><p> Apply rules on windows with <em>override_redirect</em> set, like panels and docks.</p></dd>
<dt class="flush"><code>-p</code></dt><dd><p> Apply rules when windows change their properties.</p></dd>
<dt><code>-s</code> <var>shell</var></dt><dd><p> Execute rule commands with <var>shell</var>.</p></dd>
+<dt class="flush"><code>-v</code></dt><dd><p> Print version information.</p></dd>
</dl>
@@ -152,7 +153,7 @@ can have multi-line commands this way.</p>
otherwise it will be run asynchronously.</p>
<p><code>COMMAND</code> will be executed by the shell set in the <code>SHELL</code> environment
-variable. The window id will be set in the <code>RULER_ID</code> environment variable.</p>
+variable. The window id will be set in the <code>RULER_WID</code> environment variable.</p>
<p><code>CRITERION</code> can be:</p>
diff --git a/man/ruler.1.md b/man/ruler.1.md
index a81c99d..10e14f7 100644
--- a/man/ruler.1.md
+++ b/man/ruler.1.md
@@ -30,6 +30,9 @@ specific windows, called *rules*.
* `-s` <shell>:
Execute rule commands with <shell>.
+* `-v`:
+ Print version information.
+
## BEHAVIOR
`ruler` is a program that listens to X window events and applies a set of rules
@@ -86,7 +89,7 @@ If `COMMAND` is preceded by a `;`, the command will be run synchronously,
otherwise it will be run asynchronously.
`COMMAND` will be executed by the shell set in the `SHELL` environment
-variable. The window id will be set in the `RULER_ID` environment variable.
+variable. The window id will be set in the `RULER_WID` environment variable.
`CRITERION` can be:
diff --git a/ruler.c b/ruler.c
index ca142ac..aee29d1 100644
--- a/ruler.c
+++ b/ruler.c
@@ -49,6 +49,14 @@ print_usage(const char *program_name, int exit_value)
exit(exit_value);
}
+void print_version(void)
+{
+ fprintf(stderr, "%s %s\n", NAME, VERSION);
+ fprintf(stderr, "Copyright (c) 2017 Tudor Ioan Roman\n");
+ fprintf(stderr, "Released under the ISC License\n");
+ exit(0);
+}
+
char *
strip_quotes(char *str)
{
@@ -924,7 +932,9 @@ main(int argc, char **argv)
case 'm':
conf.exec_on_map = 1; break;
case 'h':
- print_usage(argv0, 0);
+ print_usage(argv0, 0); break;
+ case 'v':
+ print_version(); break;
} ARGEND
/* the remaining arguments should be files */
diff --git a/ruler.h b/ruler.h
index 8eb65f6..51be82e 100644
--- a/ruler.h
+++ b/ruler.h
@@ -9,6 +9,14 @@
#define ENV_VARIABLE "RULER_WID"
#define DEBUG 0
+#ifndef NAME
+#define NAME "ruler"
+#endif
+
+#ifndef VERSION
+#define VERSION "-1"
+#endif
+
enum {
ATOM_WM_NAME,
ATOM_WM_CLASS,
@@ -77,6 +85,7 @@ int yyparse(void);
void yyrestart(FILE *);
void print_usage(const char *, int);
+void print_version(void);
char * strip_quotes(char *);
struct descriptor * new_descriptor(char *, char *);
diff --git a/test b/rulerrc
index 8c87696..c026f1f 100644
--- a/test
+++ b/rulerrc
@@ -1,7 +1,7 @@
# with
-# comment #wew
+# comment #test
role="browser"
- wtf "$WID" && waitron group_add_window 2
+ wtf "$RULER_WID" && waitron group_add_window 2
# match all
name=".*"