svkbd

simple virtual keyboard
git clone git://git.suckless.org/svkbd
Log | Files | Refs | LICENSE

commit 9ff7c9fea2f062994c4b91c1a297580719dcde8b
parent 4ab83f9dfce2db53293f65f22590260217fbbbd5
Author: Christoph Lohmann <20h@r-36.net>
Date:   Thu, 24 Mar 2011 19:41:58 +0100

Adding commandline options.
Diffstat:
svkbd.c | 42++++++++++++++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 4 deletions(-)

diff --git a/svkbd.c b/svkbd.c @@ -425,12 +425,46 @@ updatekeys() { } } +void +usage(char *argv0) { + fprintf(stderr, "usage: %s [-hv] [-wh height] [-ww width] " + "[-wx x position] [-wy y position]\n", argv0); + exit(1); +} + int main(int argc, char *argv[]) { - if(argc == 2 && !strcmp("-v", argv[1])) - die("svkbd-"VERSION", © 2006-2010 svkbd engineers, see LICENSE for details\n"); - else if(argc != 1) - die("usage: svkbd [-v]\n"); + int i; + + for (i = 1; argv[i]; i++) { + if(!strcmp(argv[i], "-v")) { + die("svkbd-"VERSION", © 2006-2010 svkbd engineers," + " see LICENSE for details\n"); + } + if(!strcmp(argv[i], "-wh")) { + wh = atoi(argv[i+1]); + i++; + continue; + } + if(!strcmp(argv[i], "-ww")) { + ww = atoi(argv[i+1]); + i++; + continue; + } + if(!strcmp(argv[i], "-wx")) { + wx = atoi(argv[i+1]); + i++; + continue; + } + if(!strcmp(argv[i], "-wy")) { + wy = atoi(argv[i+1]); + i++; + continue; + } + if(!strcmp(argv[i], "-h")) + usage(argv[0]); + } + if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fprintf(stderr, "warning: no locale support\n"); if(!(dpy = XOpenDisplay(0)))