aboutsummaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-11-23 06:31:33 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-11-23 06:31:33 +0000
commita5f3aa1278972e76571e6cc6d0e76b43f1e957cd (patch)
tree74dbfbd9b78dfa2254bf8144aad4ff94bb430b1f /client.c
parentMerge branch 'pgo' (diff)
parentclient: add new "--window-size-*" options to docs and CHANGELOG.md (diff)
Merge branch 'footclient-w'
Closes #189.
Diffstat (limited to 'client.c')
-rw-r--r--client.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/client.c b/client.c
index a9d823c7..9887c514 100644
--- a/client.c
+++ b/client.c
@@ -37,6 +37,8 @@ print_usage(const char *prog_name)
printf(" -t,--term=TERM value to set the environment variable TERM to (foot)\n"
" --title=TITLE initial window title (foot)\n"
" -a,--app-id=ID window application ID (foot)\n"
+ " -w,--window-size-pixels=WIDTHxHEIGHT initial width and height, in pixels\n"
+ " -W,--window-size-chars=WIDTHxHEIGHT initial width and height, in characters\n"
" --maximized start in maximized mode\n"
" --fullscreen start in fullscreen mode\n"
" --login-shell start shell as a login shell\n"
@@ -54,23 +56,28 @@ main(int argc, char *const *argv)
const char *const prog_name = argv[0];
static const struct option longopts[] = {
- {"term", required_argument, NULL, 't'},
- {"title", required_argument, NULL, 'T'},
- {"app-id", required_argument, NULL, 'a'},
- {"maximized", no_argument, NULL, 'm'},
- {"fullscreen", no_argument, NULL, 'F'},
- {"login-shell", no_argument, NULL, 'L'},
- {"server-socket", required_argument, NULL, 's'},
- {"hold", no_argument, NULL, 'H'},
- {"log-colorize", optional_argument, NULL, 'l'},
- {"version", no_argument, NULL, 'v'},
- {"help", no_argument, NULL, 'h'},
- {NULL, no_argument, NULL, 0},
+ {"term", required_argument, NULL, 't'},
+ {"title", required_argument, NULL, 'T'},
+ {"app-id", required_argument, NULL, 'a'},
+ {"window-size-pixels", required_argument, NULL, 'w'},
+ {"window-size-chars", required_argument, NULL, 'W'},
+ {"maximized", no_argument, NULL, 'm'},
+ {"fullscreen", no_argument, NULL, 'F'},
+ {"login-shell", no_argument, NULL, 'L'},
+ {"server-socket", required_argument, NULL, 's'},
+ {"hold", no_argument, NULL, 'H'},
+ {"log-colorize", optional_argument, NULL, 'l'},
+ {"version", no_argument, NULL, 'v'},
+ {"help", no_argument, NULL, 'h'},
+ {NULL, no_argument, NULL, 0},
};
const char *term = "";
const char *title = "";
const char *app_id = "";
+ unsigned size_type = 0; // enum conf_size_type (without pulling in tllist/fcft via config.h)
+ unsigned width = 0;
+ unsigned height = 0;
const char *server_socket_path = NULL;
enum log_colorize log_colorize = LOG_COLORIZE_AUTO;
bool login_shell = false;
@@ -79,7 +86,7 @@ main(int argc, char *const *argv)
bool hold = false;
while (true) {
- int c = getopt_long(argc, argv, "+t:T:a:mFLs:Hl::vh", longopts, NULL);
+ int c = getopt_long(argc, argv, "+t:T:a:w:W:mFLs:Hl::vh", longopts, NULL);
if (c == -1)
break;
@@ -100,6 +107,22 @@ main(int argc, char *const *argv)
login_shell = true;
break;
+ case 'w':
+ if (sscanf(optarg, "%ux%u", &width, &height) != 2 || width == 0 || height == 0) {
+ fprintf(stderr, "error: invalid window-size-pixels: %s\n", optarg);
+ return EXIT_FAILURE;
+ }
+ size_type = 0; // CONF_SIZE_PX
+ break;
+
+ case 'W':
+ if (sscanf(optarg, "%ux%u", &width, &height) != 2 || width == 0 || height == 0) {
+ fprintf(stderr, "error: invalid window-size-chars: %s\n", optarg);
+ return EXIT_FAILURE;
+ }
+ size_type = 1; // CONF_SIZE_CELLS
+ break;
+
case 'm':
maximized = true;
fullscreen = false;
@@ -215,6 +238,9 @@ main(int argc, char *const *argv)
const size_t app_id_len = strlen(app_id) + 1;
const struct client_data data = {
+ .width = width,
+ .height = height,
+ .size_type = size_type,
.maximized = maximized,
.fullscreen = fullscreen,
.hold = hold,