@@ -251,6 +251,8 @@ func _launch(app: LibraryLaunchItem) -> RunningApp:
251251 var user_env = settings_manager .get_value (section , env_key , {})
252252 if user_env and user_env is Dictionary and not (user_env as Dictionary ).is_empty ():
253253 env = user_env
254+ var inherit_environment_key := "." .join (["inherit_parent_environment" , app ._provider_id ])
255+ var inherit_environment := settings_manager .get_value (section , inherit_environment_key , true ) as bool
254256 var sandboxing_key := "." .join (["use_sandboxing" , app ._provider_id ])
255257 var use_sandboxing := settings_manager .get_value (section , sandboxing_key , false ) as bool
256258
@@ -264,6 +266,15 @@ func _launch(app: LibraryLaunchItem) -> RunningApp:
264266 # Set the OGUI ID environment variable
265267 env ["OGUI_ID" ] = app .name
266268
269+ # Set certain environment variables when not inheriting the parent environment
270+ if not inherit_environment :
271+ if not "HOME" in env :
272+ env ["HOME" ] = OS .get_environment ("HOME" )
273+ if not "XDG_SESSION_TYPE" in env :
274+ env ["XDG_SESSION_TYPE" ] = "x11"
275+ if not "XDG_RUNTIME_DIR" in env :
276+ env ["XDG_RUNTIME_DIR" ] = OS .get_environment ("XDG_RUNTIME_DIR" )
277+
267278 # Build any environment variables to include in the command
268279 var env_vars := PackedStringArray ()
269280 for key in env .keys ():
@@ -277,6 +288,8 @@ func _launch(app: LibraryLaunchItem) -> RunningApp:
277288 # Build the launch command to run
278289 var exec := "env"
279290 var command := ["-C" , cwd ]
291+ if not inherit_environment :
292+ command .push_front ("-i" )
280293 command .append_array (env_vars )
281294 command .append_array (sandbox )
282295 command .append (cmd )
0 commit comments