aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--experimental/keyboard-leds-trayicons.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/experimental/keyboard-leds-trayicons.c b/experimental/keyboard-leds-trayicons.c
index 676849e..9e32822 100644
--- a/experimental/keyboard-leds-trayicons.c
+++ b/experimental/keyboard-leds-trayicons.c
@@ -654,7 +654,8 @@ typedef struct {
} configuration;
// this should be configurable with -c parameter (getopts?)
-char* conffile = "/home/bgstack15/keyboard-leds-trayicons.conf";
+char* conffile = "NONE";
+int debug = 0;
// slightly modified from example https://github.com/benhoyt/inih
static int handler(void* user, const char* section, const char* name, const char* value) {
@@ -704,8 +705,40 @@ void sig_usr(int signo) {
return;
}
+int fprint_usage(char **argv) {
+ printf("Usage: %s [-c CONFFILE] [-d] [-h]\n", *argv);
+ printf("Create a system tray icon as specified\n");
+ printf("\n");
+ printf(" -c CONFFILE\tUse the specified config file (required)\n");
+ printf(" -d \tTurn debug messages on\n");
+ printf(" -h \tDisplay this help message\n");
+ printf("\n");
+ return 0;
+}
+
+
int main(int argc, char **argv) {
+ conffile = "/home/bgstack15/keyboard-leds-trayicons.conf";
+
+ // Step 0: parse parameters
+ int c;
+ while ((c = getopt(argc, argv, "c:dh")) != -1)
+ switch (c) {
+ case 'c':
+ conffile = optarg;
+ break;
+ case 'd':
+ debug = 1;
+ break;
+ case 'h':
+ return fprint_usage(argv);
+ break;
+ case '?':
+ fprintf(stderr, "Unknown option: %c\n", optopt);
+ return 1;
+ };
+
// Step 1: load config
configuration config;
if (ini_parse(conffile, handler, &config) < 0) {
bgstack15