mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-23 03:43:02 +00:00
add config file argument
This commit is contained in:
parent
5bb9d781be
commit
c406cfab4d
1 changed files with 119 additions and 105 deletions
|
@ -15,9 +15,12 @@
|
|||
#define VERSION_OPT_LONG "--version"
|
||||
#define VERSION_OPT_SHRT "-v"
|
||||
|
||||
#define CONFIG_OPT_LONG "--config"
|
||||
#define CONFIG_OPT_SHRT "-c"
|
||||
|
||||
#define MAJOR 2
|
||||
#define MINOR 14
|
||||
#define PATCH 0
|
||||
#define PATCH 2
|
||||
|
||||
extern int SLSMainConnectionID(void);
|
||||
extern int RunApplicationEventLoop(void);
|
||||
|
@ -96,7 +99,7 @@ static void acquire_lockfile(void) {
|
|||
};
|
||||
|
||||
if (fcntl(handle, F_SETLK, &lockfd) == -1) {
|
||||
error("sketchybar: could not acquire lock-file! abort..\n");
|
||||
error("sketchybar: could not acquire lock-file... already running?\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +121,8 @@ static bool get_config_file(char *restrict filename, char *restrict buffer, int
|
|||
}
|
||||
|
||||
static void exec_config_file(void) {
|
||||
if (!get_config_file("sketchybarrc", g_config_file, sizeof(g_config_file))) {
|
||||
if (!*g_config_file
|
||||
&& !get_config_file("sketchybarrc", g_config_file, sizeof(g_config_file))) {
|
||||
printf("could not locate config file..");
|
||||
return;
|
||||
}
|
||||
|
@ -165,13 +169,23 @@ static inline void init_misc_settings(void) {
|
|||
#pragma clang diagnostic pop
|
||||
|
||||
static void parse_arguments(int argc, char **argv) {
|
||||
if ((string_equals(argv[1], VERSION_OPT_LONG)) || (string_equals(argv[1], VERSION_OPT_SHRT))) {
|
||||
if ((string_equals(argv[1], VERSION_OPT_LONG))
|
||||
|| (string_equals(argv[1], VERSION_OPT_SHRT))) {
|
||||
fprintf(stdout, "sketchybar-v%d.%d.%d\n", MAJOR, MINOR, PATCH);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if ((string_equals(argv[1], CLIENT_OPT_LONG)) || (string_equals(argv[1], CLIENT_OPT_SHRT)))
|
||||
} else if ((string_equals(argv[1], CLIENT_OPT_LONG))
|
||||
|| (string_equals(argv[1], CLIENT_OPT_SHRT))) {
|
||||
exit(client_send_message(argc-1, argv+1));
|
||||
} else if ((string_equals(argv[1], CONFIG_OPT_LONG))
|
||||
|| (string_equals(argv[1], CONFIG_OPT_SHRT))) {
|
||||
if (argc < 3) {
|
||||
printf("[!] Error: Too few arguments for argument 'config'.\n");
|
||||
} else {
|
||||
snprintf(g_config_file, sizeof(g_config_file), "%s", argv[2]);
|
||||
return;
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
exit(client_send_message(argc, argv));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue