summaryrefslogtreecommitdiffstats
path: root/swaygrab/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaygrab/main.c')
-rw-r--r--swaygrab/main.c26
1 files changed, 19 insertions, 7 deletions
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
12void sway_terminate(void) { 12void sway_terminate(void) {
13 exit(1); 13 exit(EXIT_FAILURE);
14} 14}
15 15
16int numlen(int n) { 16int 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