aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-06-17 11:28:44 +0530
committerAkshay Nair <phenax5@gmail.com>2020-06-17 11:28:44 +0530
commit0c9d36aa5bb64029c254a6fcd645b892b37d5661 (patch)
treed8cd3af6bfd8aeceaec921e491e6dc75e626561b
parent4b5384bcb6dd36d51aacc1e40ed8b020444f9882 (diff)
downloadshotkey-0c9d36aa5bb64029c254a6fcd645b892b37d5661.tar.gz
shotkey-0c9d36aa5bb64029c254a6fcd645b892b37d5661.zip
Adds cli arguments
-rw-r--r--config.h5
-rw-r--r--daemonic.c30
2 files changed, 34 insertions, 1 deletions
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 <X11/Xutil.h>
#include <unistd.h>
+#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;