diff options
author | Tudor Roman | 2017-02-15 21:00:10 +0200 |
---|---|---|
committer | Tudor Roman | 2017-02-15 21:00:10 +0200 |
commit | 58bca360f6b30f4f064465603c34cd3ad6b426ee (patch) | |
tree | 9c3ee5f1e9ff65e1453bad44e4db799dee5e5ac2 | |
parent | a4ad7ef8725beee6e645f5a67f424910c46bd999 (diff) | |
download | ruler-58bca360f6b30f4f064465603c34cd3ad6b426ee.tar.gz ruler-58bca360f6b30f4f064465603c34cd3ad6b426ee.zip |
added -v flag: print version information
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | VERSION | 1 | ||||
-rw-r--r-- | man/ruler.1 | 6 | ||||
-rw-r--r-- | man/ruler.1.html | 3 | ||||
-rw-r--r-- | man/ruler.1.md | 5 | ||||
-rw-r--r-- | ruler.c | 12 | ||||
-rw-r--r-- | ruler.h | 9 | ||||
-rw-r--r-- | rulerrc (renamed from test) | 4 |
8 files changed, 38 insertions, 7 deletions
@@ -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 $< @@ -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: @@ -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 */ @@ -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 *); @@ -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=".*" |