-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockactions.scpt
58 lines (48 loc) · 1.58 KB
/
dockactions.scpt
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
50
51
52
53
54
55
56
57
58
-- Empties the trash bin without warning the user
-- Quits TIDAL app
-- To be used with an option three-finger click on macOS Dock items
-- Adapted from https://community.folivora.ai/t/enhanced-dock-for-macos/22364
tell application "System Events"
-- Store current app's ID so we can turn the focus back to it after we empty the bin
set frontAppID to bundle identifier of first process whose frontmost is true
end tell
tell application "System Events" to tell process "Dock" to try
set frontmost to true
delay 0.2
set l to list 1
try
set s to item 1 of (first UI element whose selected is true) of l
set {AppNm, AppSr} to {name of s, subrole of s}
on error
set AppNm to name of value of attribute "AXFocusedUIElement"
set AppSr to subrole of item 1 of UI element AppNm of l
end try
try
set AppSt to value of attribute "AXIsApplicationRunning" of UI element AppNm of l
end try
on error
beep
return
end try
-- if AppSr is "AXTrashDockItem" then
if AppNm is "Bin" then
tell application "Finder"
if (warns before emptying of trash) then
set warns before emptying of trash to false
try
empty trash
end try
set warns before emptying of trash to true
else
empty trash
end if
end tell
-- Return focus to the actual app in use
activate application id frontAppID
else
tell application AppNm
quit
end tell
-- Return focus to the actual app in use
activate application id frontAppID
end if