From b2c1ef5c50893ca78ba2872f5ba61b9d935d17be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira=20Rolim?= <34201958+ericonr@users.noreply.github.com> Date: Mon, 3 Feb 2020 03:20:47 -0300 Subject: [PATCH] add wayland specifier to session names (#162) Create a config option to force ly to add " (Wayland)" to session names, as long as those names don't already contain the string. --- res/config.ini | 3 +++ src/config.c | 2 ++ src/config.h | 1 + src/utils.c | 13 +++++++++++++ 4 files changed, 19 insertions(+) diff --git a/res/config.ini b/res/config.ini index 6863dcaf..8de8f0cd 100644 --- a/res/config.ini +++ b/res/config.ini @@ -83,6 +83,9 @@ # wayland setup command #wayland_cmd = /etc/ly/wsetup.sh +# add wayland specifier to session names +#wayland_specifier = false + # wayland desktop environments #waylandsessions = /usr/share/wayland-sessions diff --git a/src/config.c b/src/config.c index dbf47c47..6645438f 100644 --- a/src/config.c +++ b/src/config.c @@ -184,6 +184,7 @@ void config_load(const char *cfg_path) {"term_reset_cmd", &config.term_reset_cmd, config_handle_str}, {"tty", &config.tty, config_handle_u8}, {"wayland_cmd", &config.wayland_cmd, config_handle_str}, + {"wayland_specifier", &config.wayland_specifier, config_handle_bool}, {"waylandsessions", &config.waylandsessions, config_handle_str}, {"x_cmd", &config.x_cmd, config_handle_str}, {"x_cmd_setup", &config.x_cmd_setup, config_handle_str}, @@ -289,6 +290,7 @@ void config_defaults() config.term_reset_cmd = strdup("/usr/bin/tput reset"); config.tty = 2; config.wayland_cmd = strdup(DATADIR "/wsetup.sh"); + config.wayland_specifier = false; config.waylandsessions = strdup("/usr/share/wayland-sessions"); config.x_cmd = strdup("/usr/bin/X"); config.x_cmd_setup = strdup(DATADIR "/xsetup.sh"); diff --git a/src/config.h b/src/config.h index c88cdaba..fa0b67bf 100644 --- a/src/config.h +++ b/src/config.h @@ -89,6 +89,7 @@ struct config char* term_reset_cmd; u8 tty; char* wayland_cmd; + bool wayland_specifier; char* waylandsessions; char* x_cmd; char* x_cmd_setup; diff --git a/src/utils.c b/src/utils.c index fd26dae4..be98bdaf 100644 --- a/src/utils.c +++ b/src/utils.c @@ -95,6 +95,19 @@ void desktop_crawl( strncat(path, dir_info->d_name, (sizeof (path)) - 1); configator(&desktop_config, path); + // if these are wayland sessions, add " (Wayland)" to their names, + // as long as their names don't already contain that string + if (server == DS_WAYLAND && config.wayland_specifier) + { + const char wayland_specifier[] = " (Wayland)"; + if (strstr(name, wayland_specifier) == NULL) + { + name = realloc(name, (strlen(name) + sizeof(wayland_specifier) + 1)); + // using strcat is safe because the string is constant + strcat(name, wayland_specifier); + } + } + if ((name != NULL) && (exec != NULL)) { input_desktop_add(target, name, exec, server);