getFrontmostApp method
Implementation
@override
Future<FrontmostApp?> getFrontmostApp() async {
// Would call native input module
try {
final result = await Process.run('osascript', [
'-e',
'tell application "System Events" to get {bundle identifier, name} of first process whose frontmost is true',
]);
if (result.exitCode == 0) {
final parts = (result.stdout as String).trim().split(', ');
if (parts.length >= 2) {
return FrontmostApp(bundleId: parts[0], displayName: parts[1]);
}
}
} catch (_) {}
return null;
}