Skip to content

Commit

Permalink
Use tray_icon config to macOS menu icon
Browse files Browse the repository at this point in the history
  • Loading branch information
thevindu-w committed Nov 10, 2024
1 parent 0f023a9 commit 7f9ecf8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static inline void _apply_default_conf(void) {
if (configuration.web_port <= 0) configuration.web_port = WEB_PORT;
if (configuration.web_mode_enabled < 0) configuration.web_mode_enabled = 0;
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(__APPLE__)
if (configuration.tray_icon < 0) configuration.tray_icon = 1;
#endif
}
Expand Down Expand Up @@ -564,12 +564,14 @@ int main(int argc, char **argv) {
}

#ifdef __APPLE__
fflush(stdout);
fflush(stderr);
pid_t p_menu = fork();
if (p_menu == 0) {
show_menu_icon();
exit(EXIT_SUCCESS);
if (configuration.tray_icon) {
fflush(stdout);
fflush(stderr);
pid_t p_menu = fork();
if (p_menu == 0) {
show_menu_icon();
exit(EXIT_SUCCESS);
}
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions utils/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ static void parse_line(char *line, config *cfg) {
set_is_true(value, &(cfg->method_enabled.get_screenshot));
} else if (!strcmp("method_info_enabled", key)) {
set_is_true(value, &(cfg->method_enabled.info));
#ifdef _WIN32
#if defined(_WIN32) || defined(__APPLE__)
} else if (!strcmp("tray_icon", key)) {
set_is_true(value, &(cfg->tray_icon));
#endif
Expand Down Expand Up @@ -366,7 +366,7 @@ void parse_conf(config *cfg, const char *file_name) {
cfg->method_enabled.get_copied_image = -1;
cfg->method_enabled.get_screenshot = -1;
cfg->method_enabled.info = -1;
#ifdef _WIN32
#if defined(_WIN32) || defined(__APPLE__)
cfg->tray_icon = -1;
#endif
if (ipv4_aton(NULL, &(cfg->bind_addr)) != EXIT_SUCCESS) error_exit("Error initializing bind address");
Expand Down
2 changes: 1 addition & 1 deletion utils/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef struct _config {
int8_t info;
} method_enabled;

#ifdef _WIN32
#if defined(_WIN32) || defined(__APPLE__)
int8_t tray_icon;
#endif
} config;
Expand Down

0 comments on commit 7f9ecf8

Please sign in to comment.