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.
pull/176/head
Érico Nogueira Rolim 4 years ago committed by GitHub
parent a36f70ecb2
commit b2c1ef5c50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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");

@ -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;

@ -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);

Loading…
Cancel
Save