An open-source cross-platform alternative to AirDrop
fix(linux): respect `XDG_CONFIG_HOME`, safely remove the desktop entry, and set its icon (#3356)
Victor Carrerasc95e25481396
diff --git a/app/lib/util/native/autostart_helper.dart b/app/lib/util/native/autostart_helper.dartindex ddbf47d7..d360a984 100644--- a/app/lib/util/native/autostart_helper.dart+++ b/app/lib/util/native/autostart_helper.dart@@ -21,6 +21,7 @@ Future<bool> enableAutoStart({required bool startHidden}) async {Type=ApplicationName=${packageInfo.appName}Comment=${packageInfo.appName} startup script+Icon=${packageInfo.packageName}Exec=${Platform.resolvedExecutable}${startHidden ? ' $startHiddenFlag' : ''}StartupNotify=falseTerminal=false@@ -57,7 +58,10 @@ Future<bool> disableAutoStart() async {final packageInfo = await PackageInfo.fromPlatform();switch (defaultTargetPlatform) {case TargetPlatform.linux:- File(_getLinuxFilePath(packageInfo.packageName)).deleteSync();+ final file = File(_getLinuxFilePath(packageInfo.packageName));+ if (file.existsSync()) {+ file.deleteSync();+ }break;case TargetPlatform.macOS:await setLaunchAtLogin(false);@@ -118,5 +122,9 @@ RegistryKey _getWindowsRegistryKey() {}String _getLinuxFilePath(String appName) {- return '${Platform.environment['HOME']}/.config/autostart/$appName.desktop';+ // XDG base directory paths must be absolute; unset, empty, or relative values fall back to $HOME/.config.+ // https://specifications.freedesktop.org/basedir/latest/#basics+ final configHome = Platform.environment['XDG_CONFIG_HOME'];+ final base = configHome == null || configHome.isEmpty || !Directory(configHome).isAbsolute ? '${Platform.environment['HOME']}/.config' : configHome;+ return '$base/autostart/$appName.desktop';}