diff --git a/lib/main.dart b/lib/main.dart index f4d087a2..2ce831bd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,55 +1,9 @@ -import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:umbrix/bootstrap.dart'; import 'package:umbrix/core/model/environment.dart'; void main() async { - // Single instance check - BEFORE Flutter initialization - if (Platform.isLinux || Platform.isWindows) { - final lockFile = File('/tmp/umbrix.lock'); - - if (await lockFile.exists()) { - try { - final pidString = await lockFile.readAsString(); - final pid = int.tryParse(pidString.trim()); - - if (pid != null) { - // Check if process is still alive - final result = await Process.run('ps', ['-p', pid.toString()]); - - if (result.exitCode == 0) { - // Process alive - restore and focus existing window - try { - // Find window and restore from minimized state, then activate - final searchResult = await Process.run('xdotool', ['search', '--name', 'Umbrix']); - if (searchResult.exitCode == 0 && searchResult.stdout.toString().trim().isNotEmpty) { - final windowId = searchResult.stdout.toString().trim().split('\n').first; - // Restore from minimized/iconified state - await Process.run('xdotool', ['windowmap', windowId]); - await Process.run('xdotool', ['windowactivate', windowId]); - } - } catch (_) { - // xdotool not available, just exit - } - exit(0); - } else { - // Stale lock - remove it - await lockFile.delete(); - } - } - } catch (e) { - try { await lockFile.delete(); } catch (_) {} - } - } - - // Create lock file with current PID - try { - await lockFile.create(); - await lockFile.writeAsString(pid.toString()); - } catch (_) {} - } - final widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); diff --git a/linux/my_application.cc b/linux/my_application.cc index ac3afe83..50977fad 100644 --- a/linux/my_application.cc +++ b/linux/my_application.cc @@ -137,6 +137,6 @@ MyApplication *my_application_new() { return MY_APPLICATION(g_object_new(my_application_get_type(), "application-id", APPLICATION_ID, - "flags", G_APPLICATION_NON_UNIQUE, + "flags", G_APPLICATION_DEFAULT_FLAGS, nullptr)); }