diff options
-rw-r--r-- | sway.1.txt | 3 | ||||
-rw-r--r-- | sway/main.c | 35 | ||||
-rw-r--r-- | swaybg/main.c | 2 | ||||
-rw-r--r-- | swaygrab.1.txt | 3 | ||||
-rw-r--r-- | swaygrab/main.c | 26 | ||||
-rw-r--r-- | swaymsg.1.txt | 3 | ||||
-rw-r--r-- | swaymsg/main.c | 24 |
7 files changed, 75 insertions, 21 deletions
@@ -17,6 +17,9 @@ Synopsis | |||
17 | Options | 17 | Options |
18 | ------- | 18 | ------- |
19 | 19 | ||
20 | *-h, --help*:: | ||
21 | Show help message and quit. | ||
22 | |||
20 | *-c, \--config* <config>:: | 23 | *-c, \--config* <config>:: |
21 | Specifies a config file. | 24 | Specifies a config file. |
22 | 25 | ||
diff --git a/sway/main.c b/sway/main.c index dd609214..1261a7ce 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -55,25 +55,41 @@ int main(int argc, char **argv) { | |||
55 | static int verbose = 0, debug = 0, validate = 0; | 55 | static int verbose = 0, debug = 0, validate = 0; |
56 | 56 | ||
57 | static struct option long_options[] = { | 57 | static struct option long_options[] = { |
58 | {"help", no_argument, NULL, 'h'}, | ||
58 | {"config", required_argument, NULL, 'c'}, | 59 | {"config", required_argument, NULL, 'c'}, |
59 | {"validate", no_argument, &validate, 1}, | 60 | {"validate", no_argument, NULL, 'C'}, |
60 | {"debug", no_argument, &debug, 1}, | 61 | {"debug", no_argument, NULL, 'd'}, |
61 | {"version", no_argument, NULL, 'v'}, | 62 | {"version", no_argument, NULL, 'v'}, |
62 | {"verbose", no_argument, &verbose, 1}, | 63 | {"verbose", no_argument, NULL, 'V'}, |
63 | {"get-socketpath", no_argument, NULL, 'p'}, | 64 | {"get-socketpath", no_argument, NULL, 'p'}, |
64 | {0, 0, 0, 0} | 65 | {0, 0, 0, 0} |
65 | }; | 66 | }; |
66 | 67 | ||
67 | char *config_path = NULL; | 68 | char *config_path = NULL; |
69 | |||
70 | const char* usage = | ||
71 | "Usage: sway [options] [command]\n" | ||
72 | "\n" | ||
73 | " -h, --help Show help message and quit.\n" | ||
74 | " -c, --config <config> Specify a config file.\n" | ||
75 | " -C, --validate Check the validity of the config file, then exit.\n" | ||
76 | " -d, --debug Enables full logging, including debug information.\n" | ||
77 | " -v, --version Show the version number and quit.\n" | ||
78 | " -V, --verbose Enables more verbose logging.\n" | ||
79 | " --get-socketpath Gets the IPC socket path and prints it, then exits.\n" | ||
80 | "\n"; | ||
81 | |||
68 | int c; | 82 | int c; |
69 | while (1) { | 83 | while (1) { |
70 | int option_index = 0; | 84 | int option_index = 0; |
71 | c = getopt_long(argc, argv, "CdvVpc:", long_options, &option_index); | 85 | c = getopt_long(argc, argv, "hCdvVpc:", long_options, &option_index); |
72 | if (c == -1) { | 86 | if (c == -1) { |
73 | break; | 87 | break; |
74 | } | 88 | } |
75 | switch (c) { | 89 | switch (c) { |
76 | case 0: // Flag | 90 | case 'h': // help |
91 | fprintf(stdout, "%s", usage); | ||
92 | exit(EXIT_SUCCESS); | ||
77 | break; | 93 | break; |
78 | case 'c': // config | 94 | case 'c': // config |
79 | config_path = strdup(optarg); | 95 | config_path = strdup(optarg); |
@@ -90,7 +106,7 @@ int main(int argc, char **argv) { | |||
90 | #else | 106 | #else |
91 | fprintf(stdout, "version not detected\n"); | 107 | fprintf(stdout, "version not detected\n"); |
92 | #endif | 108 | #endif |
93 | exit(0); | 109 | exit(EXIT_SUCCESS); |
94 | break; | 110 | break; |
95 | case 'V': // verbose | 111 | case 'V': // verbose |
96 | verbose = 1; | 112 | verbose = 1; |
@@ -98,12 +114,15 @@ int main(int argc, char **argv) { | |||
98 | case 'p': ; // --get-socketpath | 114 | case 'p': ; // --get-socketpath |
99 | if (getenv("SWAYSOCK")) { | 115 | if (getenv("SWAYSOCK")) { |
100 | fprintf(stdout, "%s\n", getenv("SWAYSOCK")); | 116 | fprintf(stdout, "%s\n", getenv("SWAYSOCK")); |
101 | exit(0); | 117 | exit(EXIT_SUCCESS); |
102 | } else { | 118 | } else { |
103 | fprintf(stderr, "sway socket not detected.\n"); | 119 | fprintf(stderr, "sway socket not detected.\n"); |
104 | exit(1); | 120 | exit(EXIT_FAILURE); |
105 | } | 121 | } |
106 | break; | 122 | break; |
123 | default: | ||
124 | fprintf(stderr, "%s", usage); | ||
125 | exit(EXIT_FAILURE); | ||
107 | } | 126 | } |
108 | } | 127 | } |
109 | 128 | ||
diff --git a/swaybg/main.c b/swaybg/main.c index ec64ddb7..69d718c5 100644 --- a/swaybg/main.c +++ b/swaybg/main.c | |||
@@ -29,7 +29,7 @@ void sway_terminate(void) { | |||
29 | } | 29 | } |
30 | list_free(surfaces); | 30 | list_free(surfaces); |
31 | registry_teardown(registry); | 31 | registry_teardown(registry); |
32 | exit(1); | 32 | exit(EXIT_FAILURE); |
33 | } | 33 | } |
34 | 34 | ||
35 | int main(int argc, const char **argv) { | 35 | int main(int argc, const char **argv) { |
diff --git a/swaygrab.1.txt b/swaygrab.1.txt index 009fbe7e..cd4b8bd2 100644 --- a/swaygrab.1.txt +++ b/swaygrab.1.txt | |||
@@ -20,6 +20,9 @@ ImageMagick convert for processing. | |||
20 | Options | 20 | Options |
21 | ------- | 21 | ------- |
22 | 22 | ||
23 | *-h, --help*:: | ||
24 | Show help message and quit. | ||
25 | |||
23 | *-c, \--capture*:: | 26 | *-c, \--capture*:: |
24 | Captures multiple frames as video and passes them into ffmpeg. Continues until | 27 | Captures multiple frames as video and passes them into ffmpeg. Continues until |
25 | you send SIGTERM (ctrl+c) to swaygrab. | 28 | you send SIGTERM (ctrl+c) to swaygrab. |
diff --git a/swaygrab/main.c b/swaygrab/main.c index 63cf223f..681a6da4 100644 --- a/swaygrab/main.c +++ b/swaygrab/main.c | |||
@@ -10,7 +10,7 @@ | |||
10 | #include "ipc-client.h" | 10 | #include "ipc-client.h" |
11 | 11 | ||
12 | void sway_terminate(void) { | 12 | void sway_terminate(void) { |
13 | exit(1); | 13 | exit(EXIT_FAILURE); |
14 | } | 14 | } |
15 | 15 | ||
16 | int numlen(int n) { | 16 | int numlen(int n) { |
@@ -127,24 +127,33 @@ int main(int argc, char **argv) { | |||
127 | init_log(L_INFO); | 127 | init_log(L_INFO); |
128 | 128 | ||
129 | static struct option long_options[] = { | 129 | static struct option long_options[] = { |
130 | {"capture", no_argument, &capture, 'c'}, | 130 | {"help", no_argument, NULL, 'h'}, |
131 | {"capture", no_argument, NULL, 'c'}, | ||
131 | {"version", no_argument, NULL, 'v'}, | 132 | {"version", no_argument, NULL, 'v'}, |
132 | {"socket", required_argument, NULL, 's'}, | 133 | {"socket", required_argument, NULL, 's'}, |
133 | {"raw", no_argument, &raw, 'r'}, | 134 | {"raw", no_argument, NULL, 'r'}, |
134 | {"rate", required_argument, NULL, 'R'}, | 135 | {"rate", required_argument, NULL, 'R'}, |
135 | {0, 0, 0, 0} | 136 | {0, 0, 0, 0} |
136 | }; | 137 | }; |
137 | 138 | ||
139 | const char *usage = | ||
140 | "Usage: swaygrab [options] <output> [file]\n" | ||
141 | "\n" | ||
142 | " -h, --help Show help message and quit.\n" | ||
143 | " -c, --capture Capture video.\n" | ||
144 | " -v, --version Show the version number and quit.\n" | ||
145 | " -s, --socket <socket> Use the specified socket.\n" | ||
146 | " -R, --rate <rate> Specify framerate (default: 30)\n" | ||
147 | " -r, --raw Write raw rgba data to stdout.\n"; | ||
148 | |||
138 | int c; | 149 | int c; |
139 | while (1) { | 150 | while (1) { |
140 | int option_index = 0; | 151 | int option_index = 0; |
141 | c = getopt_long(argc, argv, "cvs:r", long_options, &option_index); | 152 | c = getopt_long(argc, argv, "hcvs:r", long_options, &option_index); |
142 | if (c == -1) { | 153 | if (c == -1) { |
143 | break; | 154 | break; |
144 | } | 155 | } |
145 | switch (c) { | 156 | switch (c) { |
146 | case 0: // Flag | ||
147 | break; | ||
148 | case 's': // Socket | 157 | case 's': // Socket |
149 | socket_path = strdup(optarg); | 158 | socket_path = strdup(optarg); |
150 | break; | 159 | break; |
@@ -163,8 +172,11 @@ int main(int argc, char **argv) { | |||
163 | #else | 172 | #else |
164 | fprintf(stdout, "version not detected\n"); | 173 | fprintf(stdout, "version not detected\n"); |
165 | #endif | 174 | #endif |
166 | exit(0); | 175 | exit(EXIT_SUCCESS); |
167 | break; | 176 | break; |
177 | default: | ||
178 | fprintf(stderr, "%s", usage); | ||
179 | exit(EXIT_FAILURE); | ||
168 | } | 180 | } |
169 | } | 181 | } |
170 | 182 | ||
diff --git a/swaymsg.1.txt b/swaymsg.1.txt index d832dd17..984780fa 100644 --- a/swaymsg.1.txt +++ b/swaymsg.1.txt | |||
@@ -17,6 +17,9 @@ Synopsis | |||
17 | Options | 17 | Options |
18 | ------- | 18 | ------- |
19 | 19 | ||
20 | *-h, --help*:: | ||
21 | Show help message and quit. | ||
22 | |||
20 | *-q, \--quiet*:: | 23 | *-q, \--quiet*:: |
21 | Sends the IPC message but does not print the response from sway. | 24 | Sends the IPC message but does not print the response from sway. |
22 | 25 | ||
diff --git a/swaymsg/main.c b/swaymsg/main.c index 3a2e1ee7..f8c9e14c 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include "log.h" | 12 | #include "log.h" |
13 | 13 | ||
14 | void sway_terminate(void) { | 14 | void sway_terminate(void) { |
15 | exit(1); | 15 | exit(EXIT_FAILURE); |
16 | } | 16 | } |
17 | 17 | ||
18 | int main(int argc, char **argv) { | 18 | int main(int argc, char **argv) { |
@@ -23,22 +23,33 @@ int main(int argc, char **argv) { | |||
23 | init_log(L_INFO); | 23 | init_log(L_INFO); |
24 | 24 | ||
25 | static struct option long_options[] = { | 25 | static struct option long_options[] = { |
26 | {"quiet", no_argument, &quiet, 'q'}, | 26 | {"help", no_argument, NULL, 'h'}, |
27 | {"quiet", no_argument, NULL, 'q'}, | ||
27 | {"version", no_argument, NULL, 'v'}, | 28 | {"version", no_argument, NULL, 'v'}, |
28 | {"socket", required_argument, NULL, 's'}, | 29 | {"socket", required_argument, NULL, 's'}, |
29 | {"type", required_argument, NULL, 't'}, | 30 | {"type", required_argument, NULL, 't'}, |
30 | {0, 0, 0, 0} | 31 | {0, 0, 0, 0} |
31 | }; | 32 | }; |
32 | 33 | ||
34 | const char *usage = | ||
35 | "Usage: swaymsg [options] [message]\n" | ||
36 | "\n" | ||
37 | " -h, --help Show help message and quit.\n" | ||
38 | " -q, --quiet Be quiet.\n" | ||
39 | " -v, --version Show the version number and quit.\n" | ||
40 | " -s, --socket <socket> Use the specified socket.\n" | ||
41 | " -t, --type <type> Specify the message type.\n"; | ||
42 | |||
33 | int c; | 43 | int c; |
34 | while (1) { | 44 | while (1) { |
35 | int option_index = 0; | 45 | int option_index = 0; |
36 | c = getopt_long(argc, argv, "qvs:t:", long_options, &option_index); | 46 | c = getopt_long(argc, argv, "hqvs:t:", long_options, &option_index); |
37 | if (c == -1) { | 47 | if (c == -1) { |
38 | break; | 48 | break; |
39 | } | 49 | } |
40 | switch (c) { | 50 | switch (c) { |
41 | case 0: // Flag | 51 | case 'q': // Quiet |
52 | quiet = 1; | ||
42 | break; | 53 | break; |
43 | case 's': // Socket | 54 | case 's': // Socket |
44 | socket_path = strdup(optarg); | 55 | socket_path = strdup(optarg); |
@@ -52,8 +63,11 @@ int main(int argc, char **argv) { | |||
52 | #else | 63 | #else |
53 | fprintf(stdout, "version not detected\n"); | 64 | fprintf(stdout, "version not detected\n"); |
54 | #endif | 65 | #endif |
55 | exit(0); | 66 | exit(EXIT_SUCCESS); |
56 | break; | 67 | break; |
68 | default: | ||
69 | fprintf(stderr, "%s", usage); | ||
70 | exit(EXIT_FAILURE); | ||
57 | } | 71 | } |
58 | } | 72 | } |
59 | 73 | ||