mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
main: present invalid locale errors as a user-notification
Foot does not support running under non-UTF8 locales. If we detect a non-UTF8 locale, we log this and exit with an error. However, it appears a fairly common situation is this: user (knowingly or unknowingly) only configures his/hers locale in e.g. the shell RC files. These aren’t sourced when the compositor is started via a display manager. Thus, compositor key binds will fail to launch, and the user typically has no way of seeing foot’s output. So, the user proceeds to start another terminal, and from that one tries launching foot. And it works... (because the shell in the other terminal sourced the locale configuration). User is left confused and often don’t know how to debug. This patch is somewhat hackish; in addition to logging the locale error, it also pushes a user notification. For this to be visible, we need to actually start a terminal window. So, we ignore the configured shell, and we ignore any custom command line, and instead spawns “/bin/sh -c ‘’”. This allows us to get something running (that hopefully doesn’t produce too much output we can’t decode due to the non-UTF8 locale). But, it will exit immediately. So we also set the --hold flag. This works, and may be a good enough “solution”. However, it only works for standalone foot instances, not footclients.
This commit is contained in:
parent
7bb8d48b75
commit
9873d2732f
1 changed files with 19 additions and 3 deletions
22
main.c
22
main.c
|
|
@ -424,10 +424,18 @@ main(int argc, char *const *argv)
|
|||
LOG_ERR("setlocale() failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
LOG_INFO("locale: %s", locale);
|
||||
if (!locale_is_utf8()) {
|
||||
LOG_ERR("locale is not UTF-8");
|
||||
return ret;
|
||||
|
||||
bool bad_locale = !locale_is_utf8();
|
||||
if (bad_locale) {
|
||||
LOG_ERR("locale '%s' is not UTF-8", locale);
|
||||
|
||||
if (check_config)
|
||||
return ret;
|
||||
|
||||
user_notification_add_fmt(&user_notifications, USER_NOTIFICATION_ERROR,
|
||||
"locale '%s' is not UTF-8", locale);
|
||||
}
|
||||
|
||||
struct config conf = {NULL};
|
||||
|
|
@ -502,6 +510,14 @@ main(int argc, char *const *argv)
|
|||
conf.fonts[0].arr[0].pattern, &conf.notifications);
|
||||
}
|
||||
|
||||
|
||||
if (bad_locale) {
|
||||
static char *const bad_locale_fake_argv[] = {"/bin/sh", "-c", "", NULL};
|
||||
argc = 1;
|
||||
argv = bad_locale_fake_argv;
|
||||
conf.hold_at_exit = true;
|
||||
}
|
||||
|
||||
struct fdm *fdm = NULL;
|
||||
struct reaper *reaper = NULL;
|
||||
struct wayland *wayl = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue