Skip to content

Commit 716a1b1

Browse files
committed
WSLGd: load user weston.ini
Allow user to customize weston settings (e.g to load xkb keymaps that don't have a Windows counterpart). Load ".weston.ini" from User Profile dir if it exists.
1 parent 4ad2bbf commit 716a1b1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

WSLGd/main.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define WESTON_NOTIFY_SOCKET SHARE_PATH "/weston-notify.sock"
1313
#define DEFAULT_ICON_PATH "/usr/share/icons"
1414
#define USER_DISTRO_ICON_PATH USER_DISTRO_MOUNT_PATH DEFAULT_ICON_PATH
15+
#define USER_WESTON_CONFIG_FILE ".weston.ini"
1516

1617
constexpr auto c_serviceIdTemplate = "%08X-FACB-11E6-BD58-64006A7986D3";
1718
constexpr auto c_userName = "wslg";
@@ -444,6 +445,21 @@ try {
444445
westonArgs += " ";
445446
westonArgs += westonLoggerOption;
446447

448+
// Check whether a user weston.ini exists and add it to weston options
449+
std::string westonConfigOption("--config=");
450+
std::string westonConfigFilePath;
451+
auto userProfile = getenv(c_userProfileEnv);
452+
if (userProfile) {
453+
westonConfigFilePath = TranslateWindowsPath(userProfile);
454+
westonConfigFilePath += "/" USER_WESTON_CONFIG_FILE;
455+
}
456+
457+
if (std::filesystem::is_regular_file(westonConfigFilePath)) {
458+
westonConfigOption += westonConfigFilePath;
459+
westonArgs += " ";
460+
westonArgs += westonConfigOption;
461+
}
462+
447463
// Launch weston.
448464
// N.B. Additional capabilities are needed to setns to the mount namespace of the user distro.
449465
monitor.LaunchProcess(std::vector<std::string>{

0 commit comments

Comments
 (0)