foot: add --maximized and --fullscreen command line options

This commit is contained in:
Daniel Eklöf 2020-03-26 19:47:00 +01:00
parent e197368c0f
commit 728e23863c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 30 additions and 0 deletions

View file

@ -5,6 +5,8 @@ _arguments \
'(-c --config)'{-c,--config}'[path to configuration file (XDG_CONFIG_HOME/footrc)]:config:_files' \
'(-f --font)'{-f,--font}'[font name and style in fontconfig format (monospace)]:font:->fonts' \
'(-t --term)'{-t,--term}'[value to set the environment variable TERM to (foot)]:term:->terms' \
'--maximized[start in maximized mode]' \
'--fullscreen[start in fullscreen mode]' \
'--login-shell[start shell as a login shell]' \
'(-g --geometry)'{-g,--geometry}'[window WIDTHxHEIGHT, in pixels (700x50)]:geometry:()' \
'(-s --server)'{-s,--server}'[run as server; open terminals by running footclient]:server:_files' \

View file

@ -36,6 +36,14 @@ execute (instead of the shell).
*-t*,*--term*=_TERM_
Value to set the environment variable *TERM* to. Default: *foot*.
*--maximized*
Start in maximized mode. If both *--maximized* and *--fullscreen*
are specified, the _last_ one takes precedence.
*--fullscreen*
Start in fullscreen mode. If both *--maximized* and *--fullscreen*
are specified, the _last_ one takes precedence.
*--login-shell*
Start a login shell, by prepending a '-' to argv[0].

20
main.c
View file

@ -46,6 +46,8 @@ print_usage(const char *prog_name)
" -c,--config=PATH load configuration from PATH (XDG_CONFIG_HOME/footrc)\n"
" -f,--font=FONT comma separated list of fonts in fontconfig format (monospace)\n"
" -t,--term=TERM value to set the environment variable TERM to (foot)\n"
" --maximized start in maximized mode\n"
" --fullscreen start in fullscreen mode\n"
" --login-shell start shell as a login shell\n"
" -g,--geometry=WIDTHxHEIGHT set initial width and height\n"
" -s,--server[=PATH] run as a server (use 'footclient' to start terminals).\n"
@ -142,6 +144,8 @@ main(int argc, char *const *argv)
{"geometry", required_argument, NULL, 'g'},
{"server", optional_argument, NULL, 's'},
{"hold", no_argument, NULL, 'H'},
{"maximized", no_argument, NULL, 'm'},
{"fullscreen", no_argument, NULL, 'F'},
{"presentation-timings", no_argument, NULL, 'P'}, /* Undocumented */
{"print-pid", required_argument, NULL, 'p'},
{"log-colorize", optional_argument, NULL, 'l'},
@ -161,6 +165,8 @@ main(int argc, char *const *argv)
const char *conf_server_socket_path = NULL;
bool presentation_timings = false;
bool hold = false;
bool maximized = false;
bool fullscreen = false;
bool unlink_pid_file = false;
const char *pid_file = NULL;
enum log_colorize log_colorize = LOG_COLORIZE_AUTO;
@ -232,6 +238,16 @@ main(int argc, char *const *argv)
hold = true;
break;
case 'm':
maximized = true;
fullscreen = false;
break;
case 'F':
fullscreen = true;
maximized = false;
break;
case 'p':
pid_file = optarg;
break;
@ -306,6 +322,10 @@ main(int argc, char *const *argv)
free(conf.server_socket_path);
conf.server_socket_path = strdup(conf_server_socket_path);
}
if (maximized)
conf.startup_mode = STARTUP_MAXIMIZED;
else if (fullscreen)
conf.startup_mode = STARTUP_FULLSCREEN;
conf.presentation_timings = presentation_timings;
conf.hold_at_exit = hold;