Skip to content

Commit c715316

Browse files
ciiiiidehesa
authored andcommitted
Improve relaunch Finder in toggle-desktop-icons
1 parent 139df49 commit c715316

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

commands/system/toggle-desktop-icons.applescript

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,20 @@ end if
2626

2727
do shell script "defaults write com.apple.finder CreateDesktop -bool " & NewSet
2828

29-
tell application "Finder"
30-
quit
29+
tell application "Finder" to quit
30+
31+
set inTime to current date
32+
repeat
33+
-- check Finder process not exist
34+
tell application "System Events"
35+
if "Finder" is not in (get name of processes) then exit repeat
36+
end tell
37+
-- if repeat run for 10s, exit repeat
38+
if (current date) - inTime is greater than 10 then exit repeat
39+
delay 0.2
40+
end repeat
41+
42+
tell application "Finder"
3143
try
3244
activate
3345
end try

0 commit comments

Comments
 (0)