diff --git a/doc/man.md.j2 b/doc/man.md.j2 index cbb86afb..d564e89b 100644 --- a/doc/man.md.j2 +++ b/doc/man.md.j2 @@ -162,7 +162,8 @@ file. **-U \| \--unique** -: Conky won't start if another Conky process is already running. +: Conky won't start if another Conky process is already running. Implemented + only for Linux. **-v \| -V \| \--version** diff --git a/src/conky.cc b/src/conky.cc index a9a4abef..44399cc5 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -2106,7 +2106,10 @@ void set_current_config() { /* : means that character before that takes an argument */ const char *getopt_string = - "vVqdDSs:t:u:i:hc:p:U" + "vVqdDSs:t:u:i:hc:p:" +#if defined(__linux__) + "U" +#endif #ifdef BUILD_X11 "x:y:w:a:X:m:f:" #ifdef OWN_WINDOW @@ -2136,8 +2139,12 @@ const struct option longopts[] = { {"double-buffer", 0, nullptr, 'b'}, {"window-id", 1, nullptr, 'w'}, #endif /* BUILD_X11 */ {"text", 1, nullptr, 't'}, {"interval", 1, nullptr, 'u'}, - {"pause", 1, nullptr, 'p'}, {"unique", 0, nullptr, 'U'}, - {nullptr, 0, nullptr, 0}}; + {"pause", 1, nullptr, 'p'}, +#if defined(__linux__) + {"unique", 0, nullptr, 'U'}, +#endif /* Linux */ + {nullptr, 0, nullptr, 0} +}; void setup_inotify() { #ifdef HAVE_SYS_INOTIFY_H diff --git a/src/main.cc b/src/main.cc index 39a2f307..cdbc2443 100644 --- a/src/main.cc +++ b/src/main.cc @@ -275,6 +275,7 @@ static void print_help(const char *prog_name) { prog_name); } +#if defined(__linux__) // NOTE: Only works on systems where there is a /proc/[pid]/stat file. static bool is_conky_already_running() { DIR *dir; @@ -312,6 +313,7 @@ static bool is_conky_already_running() { closedir(dir); return instances > 1; } +#endif /* Linux */ inline void reset_optind() { #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ @@ -392,19 +394,22 @@ int main(int argc, char **argv) { window.window = strtol(optarg, nullptr, 0); break; #endif /* BUILD_X11 */ +#if defined(__linux__) case 'U': unique_process = true; break; - +#endif /* Linux */ case '?': return EXIT_FAILURE; } } +#if defined(__linux__) if (unique_process && is_conky_already_running()) { NORM_ERR("already running"); return 0; } +#endif /* Linux */ try { set_current_config();