mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-11 05:33:55 -04:00
commit
689a4cc741
13 changed files with 108 additions and 16 deletions
|
|
@ -43,6 +43,8 @@
|
||||||
(https://codeberg.org/dnkl/foot/issues/14).
|
(https://codeberg.org/dnkl/foot/issues/14).
|
||||||
* `-d,--log-level={info|warning|error}` to both `foot` and
|
* `-d,--log-level={info|warning|error}` to both `foot` and
|
||||||
`footclient` (https://codeberg.org/dnkl/foot/issues/337).
|
`footclient` (https://codeberg.org/dnkl/foot/issues/337).
|
||||||
|
* `-D,--working-directory=DIR` to both `foot` and `footclient`
|
||||||
|
(https://codeberg.org/dnkl/foot/issues/347)
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
28
client.c
28
client.c
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define LOG_MODULE "foot-client"
|
#define LOG_MODULE "foot-client"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
|
|
@ -54,6 +55,7 @@ print_usage(const char *prog_name)
|
||||||
" -m,--maximized start in maximized mode\n"
|
" -m,--maximized start in maximized mode\n"
|
||||||
" -F,--fullscreen start in fullscreen mode\n"
|
" -F,--fullscreen start in fullscreen mode\n"
|
||||||
" -L,--login-shell start shell as a login shell\n"
|
" -L,--login-shell start shell as a login shell\n"
|
||||||
|
" -D,--working-directory=DIR directory to start in (CWD)\n"
|
||||||
" -s,--server-socket=PATH path to the server UNIX domain socket (default=$XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock)\n"
|
" -s,--server-socket=PATH path to the server UNIX domain socket (default=$XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock)\n"
|
||||||
" -H,--hold remain open after child process exits\n"
|
" -H,--hold remain open after child process exits\n"
|
||||||
" -d,---log-level={info|warning|error} log level (info)\n"
|
" -d,---log-level={info|warning|error} log level (info)\n"
|
||||||
|
|
@ -77,6 +79,7 @@ main(int argc, char *const *argv)
|
||||||
{"maximized", no_argument, NULL, 'm'},
|
{"maximized", no_argument, NULL, 'm'},
|
||||||
{"fullscreen", no_argument, NULL, 'F'},
|
{"fullscreen", no_argument, NULL, 'F'},
|
||||||
{"login-shell", no_argument, NULL, 'L'},
|
{"login-shell", no_argument, NULL, 'L'},
|
||||||
|
{"working-directory", required_argument, NULL, 'D'},
|
||||||
{"server-socket", required_argument, NULL, 's'},
|
{"server-socket", required_argument, NULL, 's'},
|
||||||
{"hold", no_argument, NULL, 'H'},
|
{"hold", no_argument, NULL, 'H'},
|
||||||
{"log-level", required_argument, NULL, 'd'},
|
{"log-level", required_argument, NULL, 'd'},
|
||||||
|
|
@ -89,6 +92,7 @@ main(int argc, char *const *argv)
|
||||||
const char *term = "";
|
const char *term = "";
|
||||||
const char *title = "";
|
const char *title = "";
|
||||||
const char *app_id = "";
|
const char *app_id = "";
|
||||||
|
const char *custom_cwd = NULL;
|
||||||
unsigned size_type = 0; // enum conf_size_type (without pulling in tllist/fcft via config.h)
|
unsigned size_type = 0; // enum conf_size_type (without pulling in tllist/fcft via config.h)
|
||||||
unsigned width = 0;
|
unsigned width = 0;
|
||||||
unsigned height = 0;
|
unsigned height = 0;
|
||||||
|
|
@ -101,7 +105,7 @@ main(int argc, char *const *argv)
|
||||||
bool hold = false;
|
bool hold = false;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int c = getopt_long(argc, argv, "+t:T:a:w:W:mFLs:Hd:l::vh", longopts, NULL);
|
int c = getopt_long(argc, argv, "+t:T:a:w:W:mFLD:s:Hd:l::vh", longopts, NULL);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -122,6 +126,16 @@ main(int argc, char *const *argv)
|
||||||
login_shell = true;
|
login_shell = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'D': {
|
||||||
|
struct stat st;
|
||||||
|
if (stat(optarg, &st) < 0 || !(st.st_mode & S_IFDIR)) {
|
||||||
|
fprintf(stderr, "error: %s: not a directory\n", optarg);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
custom_cwd = optarg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
if (sscanf(optarg, "%ux%u", &width, &height) != 2 || width == 0 || height == 0) {
|
if (sscanf(optarg, "%ux%u", &width, &height) != 2 || width == 0 || height == 0) {
|
||||||
fprintf(stderr, "error: invalid window-size-pixels: %s\n", optarg);
|
fprintf(stderr, "error: invalid window-size-pixels: %s\n", optarg);
|
||||||
|
|
@ -202,7 +216,7 @@ main(int argc, char *const *argv)
|
||||||
log_init(log_colorize, false, LOG_FACILITY_USER, log_level);
|
log_init(log_colorize, false, LOG_FACILITY_USER, log_level);
|
||||||
|
|
||||||
/* malloc:ed and needs to be in scope of all goto's */
|
/* malloc:ed and needs to be in scope of all goto's */
|
||||||
char *cwd = NULL;
|
char *_cwd = NULL;
|
||||||
struct client_argv *cargv = NULL;
|
struct client_argv *cargv = NULL;
|
||||||
|
|
||||||
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
|
@ -247,17 +261,19 @@ main(int argc, char *const *argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
const char *cwd = custom_cwd;
|
||||||
|
if (cwd == NULL) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
size_t buf_len = 1024;
|
size_t buf_len = 1024;
|
||||||
do {
|
do {
|
||||||
cwd = xrealloc(cwd, buf_len);
|
_cwd = xrealloc(_cwd, buf_len);
|
||||||
if (getcwd(cwd, buf_len) == NULL && errno != ERANGE) {
|
if (getcwd(_cwd, buf_len) == NULL && errno != ERANGE) {
|
||||||
LOG_ERRNO("failed to get current working directory");
|
LOG_ERRNO("failed to get current working directory");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
buf_len *= 2;
|
buf_len *= 2;
|
||||||
} while (errno == ERANGE);
|
} while (errno == ERANGE);
|
||||||
|
cwd = _cwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* String lengths, including NULL terminator */
|
/* String lengths, including NULL terminator */
|
||||||
|
|
@ -356,7 +372,7 @@ main(int argc, char *const *argv)
|
||||||
|
|
||||||
err:
|
err:
|
||||||
free(cargv);
|
free(cargv);
|
||||||
free(cwd);
|
free(_cwd);
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
close(fd);
|
close(fd);
|
||||||
log_deinit();
|
log_deinit();
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ complete -c foot -x -s a -l app-id
|
||||||
complete -c foot -s m -l maximized -d "start in maximized mode"
|
complete -c foot -s m -l maximized -d "start in maximized mode"
|
||||||
complete -c foot -s F -l fullscreen -d "start in fullscreen mode"
|
complete -c foot -s F -l fullscreen -d "start in fullscreen mode"
|
||||||
complete -c foot -s L -l login-shell -d "start shell as a login shell"
|
complete -c foot -s L -l login-shell -d "start shell as a login shell"
|
||||||
|
complete -c foot -F -s D -l working-directory -d "initial working directory for the client application (CWD)"
|
||||||
complete -c foot -x -s w -l window-size-pixels -d "window WIDTHxHEIGHT, in pixels (700x500)"
|
complete -c foot -x -s w -l window-size-pixels -d "window WIDTHxHEIGHT, in pixels (700x500)"
|
||||||
complete -c foot -x -s W -l window-size-chars -d "window WIDTHxHEIGHT, in characters (not set)"
|
complete -c foot -x -s W -l window-size-chars -d "window WIDTHxHEIGHT, in characters (not set)"
|
||||||
complete -c foot -F -s s -l server -d "run as server; open terminals by running footclient"
|
complete -c foot -F -s s -l server -d "run as server; open terminals by running footclient"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ complete -c footclient -x -s a -l app-id
|
||||||
complete -c footclient -s m -l maximized -d "start in maximized mode"
|
complete -c footclient -s m -l maximized -d "start in maximized mode"
|
||||||
complete -c footclient -s F -l fullscreen -d "start in fullscreen mode"
|
complete -c footclient -s F -l fullscreen -d "start in fullscreen mode"
|
||||||
complete -c footclient -s L -l login-shell -d "start shell as a login shell"
|
complete -c footclient -s L -l login-shell -d "start shell as a login shell"
|
||||||
|
complete -c footclient -F -s D -l working-directory -d "initial working directory for the client application (CWD)"
|
||||||
complete -c footclient -x -s w -l window-size-pixels -d "window WIDTHxHEIGHT, in pixels (700x500)"
|
complete -c footclient -x -s w -l window-size-pixels -d "window WIDTHxHEIGHT, in pixels (700x500)"
|
||||||
complete -c footclient -x -s W -l window-size-chars -d "window WIDTHxHEIGHT, in characters (not set)"
|
complete -c footclient -x -s W -l window-size-chars -d "window WIDTHxHEIGHT, in characters (not set)"
|
||||||
complete -c footclient -F -s s -l server-socket -d "override the default path to the foot server socket ($XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock)"
|
complete -c footclient -F -s s -l server-socket -d "override the default path to the foot server socket ($XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock)"
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ _arguments \
|
||||||
'(-m --maximized)'{-m,--maximized}'[start in maximized mode]' \
|
'(-m --maximized)'{-m,--maximized}'[start in maximized mode]' \
|
||||||
'(-F --fullscreen)'{-F,--fullscreen}'[start in fullscreen mode]' \
|
'(-F --fullscreen)'{-F,--fullscreen}'[start in fullscreen mode]' \
|
||||||
'(-L --login-shell)'{-L,--login-shell}'[start shell as a login shell]' \
|
'(-L --login-shell)'{-L,--login-shell}'[start shell as a login shell]' \
|
||||||
|
'(-D --working-directory)'{-D,--working-directory}'[initial working directory for the client application (CWD)]:working_directory:_files' \
|
||||||
'(-w --window-size-pixels)'{-w,--window-size-pixels}'[window WIDTHxHEIGHT, in pixels (700x500)]:size_pixels:()' \
|
'(-w --window-size-pixels)'{-w,--window-size-pixels}'[window WIDTHxHEIGHT, in pixels (700x500)]:size_pixels:()' \
|
||||||
'(-W --window-size-chars)'{-W,--window-size-chars}'[window WIDTHxHEIGHT, in characters (not set)]:size_chars:()' \
|
'(-W --window-size-chars)'{-W,--window-size-chars}'[window WIDTHxHEIGHT, in characters (not set)]:size_chars:()' \
|
||||||
'(-s --server)'{-s,--server}'[run as server; open terminals by running footclient]:server:_files' \
|
'(-s --server)'{-s,--server}'[run as server; open terminals by running footclient]:server:_files' \
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ _arguments \
|
||||||
'(-m --maximized)'{-m,--maximized}'[start in maximized mode]' \
|
'(-m --maximized)'{-m,--maximized}'[start in maximized mode]' \
|
||||||
'(-F --fullscreen)'{-F,--fullscreen}'[start in fullscreen mode]' \
|
'(-F --fullscreen)'{-F,--fullscreen}'[start in fullscreen mode]' \
|
||||||
'(-L --login-shell)'{-L,--login-shell}'[start shell as a login shell]' \
|
'(-L --login-shell)'{-L,--login-shell}'[start shell as a login shell]' \
|
||||||
|
'(-D --working-directory)'{-D,--working-directory}'[initial working directory for the client application (CWD)]:working_directory:_files' \
|
||||||
'(-w --window-size-pixels)'{-w,--window-size-pixels}'[window WIDTHxHEIGHT, in pixels (700x500)]:size_pixels:()' \
|
'(-w --window-size-pixels)'{-w,--window-size-pixels}'[window WIDTHxHEIGHT, in pixels (700x500)]:size_pixels:()' \
|
||||||
'(-W --window-size-chars)'{-W,--window-size-chars}'[window WIDTHxHEIGHT, in characters (not set)]:size_chars:()' \
|
'(-W --window-size-chars)'{-W,--window-size-chars}'[window WIDTHxHEIGHT, in characters (not set)]:size_chars:()' \
|
||||||
'(-s --server-socket)'{-s,--server-socket}'[override the default path to the foot server socket ($XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock)]:server:_files' \
|
'(-s --server-socket)'{-s,--server-socket}'[override the default path to the foot server socket ($XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock)]:server:_files' \
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,13 @@ the foot command line
|
||||||
Start in fullscreen mode. If both *--maximized* and *--fullscreen*
|
Start in fullscreen mode. If both *--maximized* and *--fullscreen*
|
||||||
are specified, the _last_ one takes precedence.
|
are specified, the _last_ one takes precedence.
|
||||||
|
|
||||||
*--login-shell*
|
*-L*,*--login-shell*
|
||||||
Start a login shell, by prepending a '-' to argv[0].
|
Start a login shell, by prepending a '-' to argv[0].
|
||||||
|
|
||||||
|
*-D*,*--working-directory*=_DIR_
|
||||||
|
Initial working directory for the client application. Default:
|
||||||
|
_CWD of foot_.
|
||||||
|
|
||||||
*-s*,*--server*[=_PATH_]
|
*-s*,*--server*[=_PATH_]
|
||||||
Run as a server. In this mode, a single foot instance hosts
|
Run as a server. In this mode, a single foot instance hosts
|
||||||
multiple terminals (windows). Use *footclient*(1) to launch new
|
multiple terminals (windows). Use *footclient*(1) to launch new
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,10 @@ terminal has terminated).
|
||||||
*-L*,*--login-shell*
|
*-L*,*--login-shell*
|
||||||
Start a login shell, by prepending a '-' to argv[0].
|
Start a login shell, by prepending a '-' to argv[0].
|
||||||
|
|
||||||
|
*-D*,*--working-directory*=_DIR_
|
||||||
|
Initial working directory for the client application. Default:
|
||||||
|
_CWD of footclient_.
|
||||||
|
|
||||||
*-s*,*--server-socket*=_PATH_
|
*-s*,*--server-socket*=_PATH_
|
||||||
Connect to _PATH_ instead of
|
Connect to _PATH_ instead of
|
||||||
*$XDG\_RUNTIME\_DIR/foot-$WAYLAND\_DISPLAY.sock*.
|
*$XDG\_RUNTIME\_DIR/foot-$WAYLAND\_DISPLAY.sock*.
|
||||||
|
|
|
||||||
32
main.c
32
main.c
|
|
@ -67,6 +67,7 @@ print_usage(const char *prog_name)
|
||||||
" -m,--maximized start in maximized mode\n"
|
" -m,--maximized start in maximized mode\n"
|
||||||
" -F,--fullscreen start in fullscreen mode\n"
|
" -F,--fullscreen start in fullscreen mode\n"
|
||||||
" -L,--login-shell start shell as a login shell\n"
|
" -L,--login-shell start shell as a login shell\n"
|
||||||
|
" -D,--working-directory=DIR directory to start in (CWD)\n"
|
||||||
" -w,--window-size-pixels=WIDTHxHEIGHT initial width and height, in pixels\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"
|
" -W,--window-size-chars=WIDTHxHEIGHT initial width and height, in characters\n"
|
||||||
" -s,--server[=PATH] run as a server (use 'footclient' to start terminals).\n"
|
" -s,--server[=PATH] run as a server (use 'footclient' to start terminals).\n"
|
||||||
|
|
@ -163,6 +164,7 @@ main(int argc, char *const *argv)
|
||||||
{"title", required_argument, NULL, 'T'},
|
{"title", required_argument, NULL, 'T'},
|
||||||
{"app-id", required_argument, NULL, 'a'},
|
{"app-id", required_argument, NULL, 'a'},
|
||||||
{"login-shell", no_argument, NULL, 'L'},
|
{"login-shell", no_argument, NULL, 'L'},
|
||||||
|
{"working-directory", required_argument, NULL, 'D'},
|
||||||
{"font", required_argument, NULL, 'f'},
|
{"font", required_argument, NULL, 'f'},
|
||||||
{"window-size-pixels", required_argument, NULL, 'w'},
|
{"window-size-pixels", required_argument, NULL, 'w'},
|
||||||
{"window-size-chars", required_argument, NULL, 'W'},
|
{"window-size-chars", required_argument, NULL, 'W'},
|
||||||
|
|
@ -185,6 +187,7 @@ main(int argc, char *const *argv)
|
||||||
const char *conf_term = NULL;
|
const char *conf_term = NULL;
|
||||||
const char *conf_title = NULL;
|
const char *conf_title = NULL;
|
||||||
const char *conf_app_id = NULL;
|
const char *conf_app_id = NULL;
|
||||||
|
const char *custom_cwd = NULL;
|
||||||
bool login_shell = false;
|
bool login_shell = false;
|
||||||
tll(char *) conf_fonts = tll_init();
|
tll(char *) conf_fonts = tll_init();
|
||||||
enum conf_size_type conf_size_type = CONF_SIZE_PX;
|
enum conf_size_type conf_size_type = CONF_SIZE_PX;
|
||||||
|
|
@ -204,7 +207,7 @@ main(int argc, char *const *argv)
|
||||||
user_notifications_t user_notifications = tll_init();
|
user_notifications_t user_notifications = tll_init();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int c = getopt_long(argc, argv, "+c:Ct:T:a:Lf:w:W:s::HmFPp:d:l::Svh", longopts, NULL);
|
int c = getopt_long(argc, argv, "+c:Ct:T:a:LD:f:w:W:s::HmFPp:d:l::Svh", longopts, NULL);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -233,6 +236,16 @@ main(int argc, char *const *argv)
|
||||||
conf_app_id = optarg;
|
conf_app_id = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'D': {
|
||||||
|
struct stat st;
|
||||||
|
if (stat(optarg, &st) < 0 || !(st.st_mode & S_IFDIR)) {
|
||||||
|
fprintf(stderr, "error: %s: not a directory\n", optarg);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
custom_cwd = optarg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
tll_free_and_free(conf_fonts, free);
|
tll_free_and_free(conf_fonts, free);
|
||||||
for (char *font = strtok(optarg, ","); font != NULL; font = strtok(NULL, ",")) {
|
for (char *font = strtok(optarg, ","); font != NULL; font = strtok(NULL, ",")) {
|
||||||
|
|
@ -443,18 +456,21 @@ main(int argc, char *const *argv)
|
||||||
struct server *server = NULL;
|
struct server *server = NULL;
|
||||||
struct shutdown_context shutdown_ctx = {.term = &term, .exit_code = EXIT_FAILURE};
|
struct shutdown_context shutdown_ctx = {.term = &term, .exit_code = EXIT_FAILURE};
|
||||||
|
|
||||||
char *cwd = NULL;
|
const char *cwd = custom_cwd;
|
||||||
{
|
char *_cwd = NULL;
|
||||||
|
|
||||||
|
if (cwd == NULL) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
size_t buf_len = 1024;
|
size_t buf_len = 1024;
|
||||||
do {
|
do {
|
||||||
cwd = xrealloc(cwd, buf_len);
|
_cwd = xrealloc(_cwd, buf_len);
|
||||||
if (getcwd(cwd, buf_len) == NULL && errno != ERANGE) {
|
if (getcwd(_cwd, buf_len) == NULL && errno != ERANGE) {
|
||||||
LOG_ERRNO("failed to get current working directory");
|
LOG_ERRNO("failed to get current working directory");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
buf_len *= 2;
|
buf_len *= 2;
|
||||||
} while (errno == ERANGE);
|
} while (errno == ERANGE);
|
||||||
|
cwd = _cwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
shm_set_max_pool_size(conf.tweak.max_shm_pool_size);
|
shm_set_max_pool_size(conf.tweak.max_shm_pool_size);
|
||||||
|
|
@ -476,8 +492,8 @@ main(int argc, char *const *argv)
|
||||||
&term_shutdown_cb, &shutdown_ctx)) == NULL) {
|
&term_shutdown_cb, &shutdown_ctx)) == NULL) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
free(cwd);
|
free(_cwd);
|
||||||
cwd = NULL;
|
_cwd = NULL;
|
||||||
|
|
||||||
if (as_server && (server = server_init(&conf, fdm, reaper, wayl)) == NULL)
|
if (as_server && (server = server_init(&conf, fdm, reaper, wayl)) == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -510,7 +526,7 @@ main(int argc, char *const *argv)
|
||||||
ret = aborted || tll_length(wayl->terms) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
ret = aborted || tll_length(wayl->terms) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(cwd);
|
free(_cwd);
|
||||||
server_destroy(server);
|
server_destroy(server);
|
||||||
term_destroy(term);
|
term_destroy(term);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ executable(
|
||||||
'spawn.c', 'spawn.h',
|
'spawn.c', 'spawn.h',
|
||||||
'tokenize.c', 'tokenize.h',
|
'tokenize.c', 'tokenize.h',
|
||||||
'url-mode.c', 'url-mode.h',
|
'url-mode.c', 'url-mode.h',
|
||||||
'user-notification.h',
|
'user-notification.c', 'user-notification.h',
|
||||||
'wayland.c', 'wayland.h',
|
'wayland.c', 'wayland.h',
|
||||||
wl_proto_src + wl_proto_headers, version,
|
wl_proto_src + wl_proto_headers, version,
|
||||||
dependencies: [math, threads, libepoll, pixman, wayland_client, wayland_cursor, xkb, fontconfig,
|
dependencies: [math, threads, libepoll, pixman, wayland_client, wayland_cursor, xkb, fontconfig,
|
||||||
|
|
|
||||||
1
server.c
1
server.c
|
|
@ -275,6 +275,7 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
|
||||||
|
|
||||||
if (client->term == NULL) {
|
if (client->term == NULL) {
|
||||||
LOG_ERR("failed to instantiate new terminal");
|
LOG_ERR("failed to instantiate new terminal");
|
||||||
|
client_send_exit_code(client, -1);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
38
user-notification.c
Normal file
38
user-notification.c
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include "user-notification.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
static bool
|
||||||
|
user_notification_add_va(user_notifications_t *notifications,
|
||||||
|
enum user_notification_kind kind, const char *fmt,
|
||||||
|
va_list ap)
|
||||||
|
{
|
||||||
|
va_list ap2;
|
||||||
|
va_copy(ap2, ap);
|
||||||
|
int cnt = vsnprintf(NULL, 0, fmt, ap2);
|
||||||
|
va_end(ap2);
|
||||||
|
|
||||||
|
if (cnt < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char *text = malloc(cnt + 1);
|
||||||
|
vsnprintf(text, cnt + 1, fmt, ap);
|
||||||
|
|
||||||
|
struct user_notification not = {
|
||||||
|
.kind = kind,
|
||||||
|
.text = text,
|
||||||
|
};
|
||||||
|
tll_push_back(*notifications, not);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
user_notification_add(user_notifications_t *notifications,
|
||||||
|
enum user_notification_kind kind, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
bool ret = user_notification_add_va(notifications, kind, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <tllist.h>
|
#include <tllist.h>
|
||||||
|
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
enum user_notification_kind {
|
enum user_notification_kind {
|
||||||
USER_NOTIFICATION_DEPRECATED,
|
USER_NOTIFICATION_DEPRECATED,
|
||||||
USER_NOTIFICATION_WARNING,
|
USER_NOTIFICATION_WARNING,
|
||||||
|
|
@ -22,3 +25,7 @@ user_notifications_free(user_notifications_t *notifications)
|
||||||
free(it->item.text);
|
free(it->item.text);
|
||||||
tll_free(*notifications);
|
tll_free(*notifications);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool user_notification_add(user_notifications_t *notifications,
|
||||||
|
enum user_notification_kind kind,
|
||||||
|
const char *fmt, ...) PRINTF(3);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue