Skip to content

Commit

Permalink
add wayland specifier to session names (#162)
Browse files Browse the repository at this point in the history
Create a config option to force ly to add " (Wayland)" to session
names, as long as those names don't already contain the string.
  • Loading branch information
ericonr authored Feb 3, 2020
1 parent a36f70e commit b2c1ef5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions res/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b2c1ef5

Please sign in to comment.