Skip to content

Commit

Permalink
Merge pull request #218 from google/fix/148
Browse files Browse the repository at this point in the history
macOS desktop tracer record correct app title
  • Loading branch information
BobEvans authored Sep 26, 2023
2 parents 9fa3f01 + 8889513 commit 2e09772
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
9 changes: 9 additions & 0 deletions pal_event_server/lib/src/allowlist_default_rules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ List<AllowListRule> createRules() {
var rules = <AllowListRule>[];
rules.add(AllowListRule.ofAppUsed(r'Google-chrome'));
rules.add(AllowListRule.ofAppUsed(r'Google Chrome'));
rules.add(AllowListRule.ofAppUsed(r'Google Chat'));
rules.add(AllowListRule.ofAppUsed(r'Taqo'));
rules.add(AllowListRule.ofAppUsed(r'Gnome terminal'));
rules.add(AllowListRule.ofAppUsed(r'Terminal'));
Expand All @@ -41,15 +42,19 @@ List<AllowListRule> createRules() {
rules.add(AllowListRule.ofAppUsed(r'XTerm'));
rules.add(AllowListRule.ofAppUsed(r'UXTerm'));
rules.add(AllowListRule.ofAppUsed(r'URxvt'));
rules.add(AllowListRule.ofAppUsed(r'iTerm2'));
rules.add(AllowListRule.ofAppUsed(r'Emacs'));
rules.add(AllowListRule.ofAppUsed(r'Code'));
rules.add(AllowListRule.ofAppUsed(r'Gvim'));
rules.add(AllowListRule.ofAppUsed(r'neovim'));
rules.add(AllowListRule.ofAppUsed(r'TextEdit'));
rules.add(AllowListRule.ofAppUsed(r'jetbrains-idea-ce'));
rules.add(AllowListRule.ofAppUsed(r'jetbrains-idea-ue'));
rules.add(AllowListRule.ofAppUsed(r'jetbrains-clion'));
rules.add(AllowListRule.ofAppUsed(r'jetbrains-studio'));
rules.add(AllowListRule.ofAppUsed(r'IntelliJ IDEA'));
rules.add(AllowListRule.ofAppUsed(r'Thunar'));
rules.add(AllowListRule.ofAppUsed(r'Finder'));
rules.add(AllowListRule.ofAppUsed(r'Calculator'));
rules.add(AllowListRule.ofAppUsed(r'org.gnome.Nautilus'));
rules.add(AllowListRule.ofAppUsed(r'Firefox'));
Expand All @@ -71,15 +76,19 @@ List<AllowListRule> createRules() {
rules.add(AllowListRule.ofAppContent(r'XTerm', r'.*'));
rules.add(AllowListRule.ofAppContent(r'UXTerm', r'.*'));
rules.add(AllowListRule.ofAppContent(r'URxvt', r'.*'));
rules.add(AllowListRule.ofAppContent(r'iTerm2', r'.*'));
rules.add(AllowListRule.ofAppContent(r'Emacs', r'.*'));
rules.add(AllowListRule.ofAppContent(r'Code', r'.*'));
rules.add(AllowListRule.ofAppContent(r'Gvim', r'.*'));
rules.add(AllowListRule.ofAppContent(r'neovim', r'.*'));
rules.add(AllowListRule.ofAppContent(r'TextEdit', r'.*'));
rules.add(AllowListRule.ofAppContent(r'jetbrains-idea-ce', r'.*'));
rules.add(AllowListRule.ofAppContent(r'jetbrains-idea-ue', r'.*'));
rules.add(AllowListRule.ofAppContent(r'jetbrains-clion', r'.*'));
rules.add(AllowListRule.ofAppContent(r'jetbrains-studio', r'.*'));
rules.add(AllowListRule.ofAppContent(r'IntelliJ IDEA', r'.*'));
rules.add(AllowListRule.ofAppContent(r'Thunar', r'.*'));
rules.add(AllowListRule.ofAppContent(r'Finder', r'.*'));
rules.add(AllowListRule.ofAppContent(r'org.gnome.Nautilus', r'.*'));
rules.add(AllowListRule.ofAppContent(r'.*', r'\bfuchsia\b'));
rules.add(AllowListRule.ofAppContent(r'.*', r'\bunix\b'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ Map<String, dynamic> buildResultMap(dynamic result) {
}

const scriptArgs = [
"-e", r'global frontApp, frontAppName, windowTitle', //
"-e", r'set windowTitle to ""',
"-e", r'global frontAppName, windowTitle, urlText', //
"-e", r'set windowTitle to "__"',
"-e", r'set urlText to ""',
"-e", r'tell application "System Events"',
"-e", r'set frontApp to first application process whose frontmost is true',
"-e", r'set frontAppName to name of frontApp',
"-e", r'tell first application process whose frontmost is true',
"-e", r'set frontAppName to displayed name',
"-e", r'try',
"-e",
r'set axwindows to (every UI element of frontApp whose role is "AXWindow" or subrole is "AXStandardWindow")',
"-e", r'if axwindows is not {} then',
"-e", r'set windowTitle to name of (item 1 of axwindows)',
r'set windowTitle to (name of first UI element whose role is "AXWindow" or subrole is "AXStandardWindow")',
"-e", r'if frontAppName is "Google Chrome" then',
"-e", r'tell application "Google Chrome"',
"-e", r'set urlText to URL of active tab of front window',
Expand All @@ -53,13 +53,17 @@ const scriptArgs = [
"-e", r'tell application "Safari"',
"-e", r'set urlText to URL of front document',
"-e", r'end tell',
"-e", r'else',
"-e", r'set urlText to ""',
"-e", r'end if',
"-e", r'else',
"-e", r'set windowTitle to "__"',
"-e", r'set urlText to ""',
"-e", r'else if frontAppName is "Google Chat" then',
"-e", r'tell application "Google Chat" of me',
"-e", r'set windowTitle to name of front window',
"-e", r'end tell',
"-e", r'else if frontAppName is "Chrome Remote Desktop" then',
"-e", r'tell application "Chrome Remote Desktop" of me',
"-e", r'set windowTitle to name of front window',
"-e", r'end tell',
"-e", r'end if',
"-e", r'end try',
"-e", r'end tell',
"-e", r'end tell',
"-e",
r'set result to frontAppName & "❣" & windowTitle & "❣" & urlText & return',
Expand Down

0 comments on commit 2e09772

Please sign in to comment.