mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-23 05:33:57 -04:00
config: add ‘url-launch’ option, defaulting to “xdg-open ${url}”
This commit is contained in:
parent
0cbdf657a7
commit
4233c806c3
4 changed files with 63 additions and 22 deletions
66
config.c
66
config.c
|
|
@ -453,6 +453,33 @@ str_to_pt_or_px(const char *s, struct pt_or_px *res, struct config *conf,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
str_to_spawn_template(struct config *conf,
|
||||||
|
const char *s, struct config_spawn_template *template,
|
||||||
|
const char *path, int lineno, const char *section,
|
||||||
|
const char *key)
|
||||||
|
{
|
||||||
|
free(template->raw_cmd);
|
||||||
|
free(template->argv);
|
||||||
|
|
||||||
|
template->raw_cmd = NULL;
|
||||||
|
template->argv = NULL;
|
||||||
|
|
||||||
|
char *raw_cmd = xstrdup(s);
|
||||||
|
char **argv = NULL;
|
||||||
|
|
||||||
|
if (!tokenize_cmdline(raw_cmd, &argv)) {
|
||||||
|
LOG_AND_NOTIFY_ERR(
|
||||||
|
"%s:%d: [%s]: %s: syntax error in command line",
|
||||||
|
path, lineno, section, key);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template->raw_cmd = raw_cmd;
|
||||||
|
template->argv = argv;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_section_main(const char *key, const char *value, struct config *conf,
|
parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
const char *path, unsigned lineno)
|
const char *path, unsigned lineno)
|
||||||
|
|
@ -675,24 +702,19 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strcmp(key, "notify") == 0) {
|
else if (strcmp(key, "notify") == 0) {
|
||||||
free(conf->notify.raw_cmd);
|
if (!str_to_spawn_template(conf, value, &conf->notify, path, lineno,
|
||||||
free(conf->notify.argv);
|
"default", "notify"))
|
||||||
|
{
|
||||||
conf->notify.raw_cmd = NULL;
|
|
||||||
conf->notify.argv = NULL;
|
|
||||||
|
|
||||||
char *raw_cmd = xstrdup(value);
|
|
||||||
char **argv = NULL;
|
|
||||||
|
|
||||||
if (!tokenize_cmdline(raw_cmd, &argv)) {
|
|
||||||
LOG_AND_NOTIFY_ERR(
|
|
||||||
"%s:%d: [default]: notify: syntax error in command line",
|
|
||||||
path, lineno);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
conf->notify.raw_cmd = raw_cmd;
|
else if (strcmp(key, "url-launch") == 0) {
|
||||||
conf->notify.argv = argv;
|
if (!str_to_spawn_template(conf, value, &conf->url_launch, path, lineno,
|
||||||
|
"default", "url-launch"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strcmp(key, "selection-target") == 0) {
|
else if (strcmp(key, "selection-target") == 0) {
|
||||||
|
|
@ -2308,6 +2330,9 @@ config_load(struct config *conf, const char *conf_path,
|
||||||
"notify-send -a foot -i foot ${title} ${body}");
|
"notify-send -a foot -i foot ${title} ${body}");
|
||||||
tokenize_cmdline(conf->notify.raw_cmd, &conf->notify.argv);
|
tokenize_cmdline(conf->notify.raw_cmd, &conf->notify.argv);
|
||||||
|
|
||||||
|
conf->url_launch.raw_cmd = xstrdup("xdg-open ${url}");
|
||||||
|
tokenize_cmdline(conf->url_launch.raw_cmd, &conf->url_launch.argv);
|
||||||
|
|
||||||
tll_foreach(*initial_user_notifications, it)
|
tll_foreach(*initial_user_notifications, it)
|
||||||
tll_push_back(conf->notifications, it->item);
|
tll_push_back(conf->notifications, it->item);
|
||||||
tll_free(*initial_user_notifications);
|
tll_free(*initial_user_notifications);
|
||||||
|
|
@ -2372,6 +2397,13 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_spawn_template(struct config_spawn_template *template)
|
||||||
|
{
|
||||||
|
free(template->raw_cmd);
|
||||||
|
free(template->argv);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
config_free(struct config conf)
|
config_free(struct config conf)
|
||||||
{
|
{
|
||||||
|
|
@ -2381,8 +2413,8 @@ config_free(struct config conf)
|
||||||
free(conf.app_id);
|
free(conf.app_id);
|
||||||
free(conf.word_delimiters);
|
free(conf.word_delimiters);
|
||||||
free(conf.scrollback.indicator.text);
|
free(conf.scrollback.indicator.text);
|
||||||
free(conf.notify.raw_cmd);
|
free_spawn_template(&conf.notify);
|
||||||
free(conf.notify.argv);
|
free_spawn_template(&conf.url_launch);
|
||||||
for (size_t i = 0; i < ALEN(conf.fonts); i++) {
|
for (size_t i = 0; i < ALEN(conf.fonts); i++) {
|
||||||
tll_foreach(conf.fonts[i], it)
|
tll_foreach(conf.fonts[i], it)
|
||||||
config_font_destroy(&it->item);
|
config_font_destroy(&it->item);
|
||||||
|
|
|
||||||
11
config.h
11
config.h
|
|
@ -66,6 +66,11 @@ struct pt_or_px {
|
||||||
float pt;
|
float pt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct config_spawn_template {
|
||||||
|
char *raw_cmd;
|
||||||
|
char **argv;
|
||||||
|
};
|
||||||
|
|
||||||
struct config {
|
struct config {
|
||||||
char *term;
|
char *term;
|
||||||
char *shell;
|
char *shell;
|
||||||
|
|
@ -198,10 +203,8 @@ struct config {
|
||||||
SELECTION_TARGET_BOTH
|
SELECTION_TARGET_BOTH
|
||||||
} selection_target;
|
} selection_target;
|
||||||
|
|
||||||
struct {
|
struct config_spawn_template notify;
|
||||||
char *raw_cmd;
|
struct config_spawn_template url_launch;
|
||||||
char **argv;
|
|
||||||
} notify;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
enum fcft_scaling_filter fcft_filter;
|
enum fcft_scaling_filter fcft_filter;
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,10 @@ in this order:
|
||||||
|
|
||||||
Default: _notify-send -a foot -i foot ${title} ${body}_.
|
Default: _notify-send -a foot -i foot ${title} ${body}_.
|
||||||
|
|
||||||
|
*url-launch*
|
||||||
|
Command to execute when opening URLs. _${url}_ will be replaced
|
||||||
|
with the actual URL. Default: _xdg-open ${url}_.
|
||||||
|
|
||||||
*selection-target*
|
*selection-target*
|
||||||
Clipboard target to automatically copy selected text to. One of
|
Clipboard target to automatically copy selected text to. One of
|
||||||
*none*, *primary*, *clipboard* or *both*. Default: _primary_.
|
*none*, *primary*, *clipboard* or *both*. Default: _primary_.
|
||||||
|
|
|
||||||
4
foot.ini
4
foot.ini
|
|
@ -20,10 +20,12 @@
|
||||||
# pad=2x2 # optionally append 'center'
|
# pad=2x2 # optionally append 'center'
|
||||||
# resize-delay-ms=100
|
# resize-delay-ms=100
|
||||||
|
|
||||||
|
# notify=notify-send -a foot -i foot ${title} ${body}
|
||||||
|
# url-launch=xdg-open ${url}
|
||||||
|
|
||||||
# bold-text-in-bright=no
|
# bold-text-in-bright=no
|
||||||
# bell=none
|
# bell=none
|
||||||
# word-delimiters=,│`|:"'()[]{}<>
|
# word-delimiters=,│`|:"'()[]{}<>
|
||||||
# notify=notify-send -a foot -i foot ${title} ${body}
|
|
||||||
# selection-target=primary
|
# selection-target=primary
|
||||||
# workers=<number of logical CPUs>
|
# workers=<number of logical CPUs>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue