From 0c9d36aa5bb64029c254a6fcd645b892b37d5661 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Wed, 17 Jun 2020 11:28:44 +0530 Subject: Adds cli arguments --- config.h | 5 +++++ daemonic.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/config.h b/config.h index a6d3c45..9caba28 100644 --- a/config.h +++ b/config.h @@ -30,3 +30,8 @@ static Key keys[] = { { MOD|ShiftMask, XK_x, mode(Bright, True) }, }; +static ModeProperties mode_properties[MODE_SIZE] = { + [Music] = { "Music player" }, + [Bright] = { "Brightness" }, +}; + diff --git a/daemonic.c b/daemonic.c index 881034f..f429134 100644 --- a/daemonic.c +++ b/daemonic.c @@ -4,6 +4,8 @@ #include #include +#define VERSION "0.0.1" + typedef struct Command { char* command; unsigned int mode; @@ -16,6 +18,10 @@ typedef struct Key { Command command; } Key; +typedef struct ModeProperties { + char* label; +} ModeProperties; + #define cmd(c) (Command) { c, -1, False } #define mode(m, p) (Command) { NULL, m, p } @@ -124,7 +130,29 @@ void keypress(Display *dpy, Window win, XKeyEvent *ev) { } } -int main() { +char* get_mode_label() { + if (current_mode == -1) return ""; + ModeProperties props = mode_properties[current_mode]; + return props.label; +} + +void help_menu(char* x) { + printf("Usage: %s [-vh]\n", x); +} + +int main(int argc, char *argv[]) { + int opt; + while ((opt = getopt(argc, argv, "vh")) != -1) { + switch (opt) { + case 'v': printf("%s\n", VERSION); return 0; + /*case 'm': printf("%s\n", get_mode_label()); return 0;*/ + case 'h': + default: + help_menu(argv[0]); + return opt != 'h'; + } + } + XSetErrorHandler(error_handler); int running = 1, i = 0; -- cgit v1.3.1