Skip to content

Instantly share code, notes, and snippets.

@viatcheslavmogilevsky
Last active March 5, 2025 16:22
Show Gist options
  • Save viatcheslavmogilevsky/a34bc254438cae3cd7feb341cb3f4414 to your computer and use it in GitHub Desktop.
Save viatcheslavmogilevsky/a34bc254438cae3cd7feb341cb3f4414 to your computer and use it in GitHub Desktop.
End-of-the-day automation
on run {}
-- reset file
do shell script "/usr/bin/git -C ~/path/to/repo checkout -- path/to/file/in/repo.txt"
tell application "Finder"
close every window
set trashcount to count of items of the trash
if trashcount > 0 then
empty the trash
end if
end tell
try
tell application "Calendar" to if it is running then quit
end try
-- get list of open apps
tell application "System Events"
set allFrontApps to displayed name of (every process whose background only is false) as list
end tell
-- leave some apps open
set exclusions to {"Calendar", "Finder", "LaunchBar"}
-- leave even windows open of some apps
set exclusionsToHide to {"LaunchBar", "Finder", "System Information"}
-- quit each app or just hide
repeat with thisApp in allFrontApps
set thisApp to thisApp as text
if thisApp is not in exclusions then
tell application thisApp to quit
else
if thisApp is not in exclusionsToHide then
tell application "System Events"
set visible of application process thisApp to false
end tell
end if
end if
end repeat
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment