Skip to content

Commit 3ed6524

Browse files
Caellianbrndnmtthws
authored andcommitted
Hide U flag altogether if not on Linux
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
1 parent e6465e8 commit 3ed6524

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

doc/man.md.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ file.
162162

163163
**-U \| \--unique**
164164

165-
: Conky won't start if another Conky process is already running.
165+
: Conky won't start if another Conky process is already running. Implemented
166+
only for Linux.
166167

167168
**-v \| -V \| \--version**
168169

src/conky.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,10 @@ void set_current_config() {
21062106

21072107
/* : means that character before that takes an argument */
21082108
const char *getopt_string =
2109-
"vVqdDSs:t:u:i:hc:p:U"
2109+
"vVqdDSs:t:u:i:hc:p:"
2110+
#if defined(__linux__)
2111+
"U"
2112+
#endif
21102113
#ifdef BUILD_X11
21112114
"x:y:w:a:X:m:f:"
21122115
#ifdef OWN_WINDOW
@@ -2136,8 +2139,12 @@ const struct option longopts[] = {
21362139
{"double-buffer", 0, nullptr, 'b'}, {"window-id", 1, nullptr, 'w'},
21372140
#endif /* BUILD_X11 */
21382141
{"text", 1, nullptr, 't'}, {"interval", 1, nullptr, 'u'},
2139-
{"pause", 1, nullptr, 'p'}, {"unique", 0, nullptr, 'U'},
2140-
{nullptr, 0, nullptr, 0}};
2142+
{"pause", 1, nullptr, 'p'},
2143+
#if defined(__linux__)
2144+
{"unique", 0, nullptr, 'U'},
2145+
#endif /* Linux */
2146+
{nullptr, 0, nullptr, 0}
2147+
};
21412148

21422149
void setup_inotify() {
21432150
#ifdef HAVE_SYS_INOTIFY_H

src/main.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ static void print_help(const char *prog_name) {
275275
prog_name);
276276
}
277277

278+
#if defined(__linux__)
278279
// NOTE: Only works on systems where there is a /proc/[pid]/stat file.
279280
static bool is_conky_already_running() {
280281
DIR *dir;
@@ -312,6 +313,7 @@ static bool is_conky_already_running() {
312313
closedir(dir);
313314
return instances > 1;
314315
}
316+
#endif /* Linux */
315317

316318
inline void reset_optind() {
317319
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
@@ -392,19 +394,22 @@ int main(int argc, char **argv) {
392394
window.window = strtol(optarg, nullptr, 0);
393395
break;
394396
#endif /* BUILD_X11 */
397+
#if defined(__linux__)
395398
case 'U':
396399
unique_process = true;
397400
break;
398-
401+
#endif /* Linux */
399402
case '?':
400403
return EXIT_FAILURE;
401404
}
402405
}
403406

407+
#if defined(__linux__)
404408
if (unique_process && is_conky_already_running()) {
405409
NORM_ERR("already running");
406410
return 0;
407411
}
412+
#endif /* Linux */
408413

409414
try {
410415
set_current_config();

0 commit comments

Comments
 (0)