-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathapp_auto_launcher_impl_linux.dart
More file actions
49 lines (43 loc) · 1.03 KB
/
app_auto_launcher_impl_linux.dart
File metadata and controls
49 lines (43 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import 'dart:io';
import 'package:launch_at_startup/src/app_auto_launcher.dart';
class AppAutoLauncherImplLinux extends AppAutoLauncher {
AppAutoLauncherImplLinux({
required super.appName,
required super.appPath,
super.args,
});
File get _desktopFile {
return File(
'${Platform.environment['HOME']}/.config/autostart/$appName.desktop',
);
}
@override
Future<bool> isEnabled() async {
return _desktopFile.existsSync();
}
@override
Future<bool> enable() async {
String contents = '''
[Desktop Entry]
Type=Application
Name=$appName
Icon=$appName
Comment=$appName startup script
Exec=${args.isEmpty ? appPath : '$appPath ${args.join(' ')}'}
StartupNotify=false
Terminal=false
''';
if (!_desktopFile.parent.existsSync()) {
_desktopFile.parent.createSync(recursive: true);
}
_desktopFile.writeAsStringSync(contents);
return true;
}
@override
Future<bool> disable() async {
if (_desktopFile.existsSync()) {
_desktopFile.deleteSync();
}
return true;
}
}