2

When I create apps with Automator, they run with the little cog that appears in the top right.

When I click the cog it says "0% completed (Run Shell Script)".

This feature is documented sparsely by Apple and I can’t locate a third party example of this and wondered if I can incorporate progress in the menu bar for my scripts.

For example, I run a rsync daemon to backup data every week.

I have an automator app to run this zsh script.

#!/bin/zsh

echo "Starting. $(date)" >> /Users/admin/Scripts/Automation/rsync/rsync.log
open /Users/admin/Scripts/Automation/rsync/notify_starting.app

rsync -r --delete --exclude 'Data 1' --exclude 'Data 2' /Users/admin/Documents /Volumes/TOSHIBA/Backups/rsync
rsync -r --delete /Users/admin/2022 /Volumes/TOSHIBA/Backups/rsync
rsync -r --max-size=100m --delete /Users/admin/Desktop /Volumes/TOSHIBA/Backups/rsync
rsync -r --delete /Users/admin/out_data /Volumes/TOSHIBA/Backups/rsync
rsync -r --delete /Users/admin/WESTERFIELD /Volumes/TOSHIBA/Backups/rsync
rsync -r --delete /Users/admin/images/2022 /Volumes/TOSHIBA/Backups/rsync
rsync -r --delete /Users/admin/Scripts /Volumes/TOSHIBA/Backups/rsync
rsync -r --max-size=100m --delete /Users/admin /Volumes/TOSHIBA/Backups/rsync

echo "Completed. $(date)" >> /Users/admin/Scripts/Automation/rsync/rsync.log
echo "\n\n" >>  /Users/admin/Scripts/Automation/rsync/rsync.log
open /Users/admin/Scripts/Automation/rsync/notify_completed.app

It takes a while to run, and slows the computer down a little. It would be really nice to see how far it's progressed. I get it might not be possible to know exactly, but if I could even know which line of the rsync commands it's reached that would be a start.

Is it possible to change my script to allow for the progess of the programs to change the percentage other than running and done?

4
  • 1
    All that really shows is the progress of actions that have completed.
    – red_menace
    Commented Aug 16, 2022 at 15:42
  • 2
    If you wanted to share a possible script you want to add progress we might be able to suggest an improvement. Same with research, document exactly what you searched or found and we can suggest better resources like the edit I made
    – bmike
    Commented Aug 16, 2022 at 15:43
  • @bmike Thanks. I added an edit with my example script. Commented Aug 16, 2022 at 16:46
  • Woo! Now that’s great. I know how to parallelize the rsync, but not yet how to trigger back to AppleScript. A worthy question +1
    – bmike
    Commented Aug 16, 2022 at 16:56

1 Answer 1

0

See if this helps, in the "Mac Automation Scripting Guide" under the section "Interacting with Users" lists Displaying Progress:

    - Reset the progress information
    set progress total steps to 0
    set progress completed steps to 0
    set progress description to ""
    set progress additional description to ""

So, as you progress through the script, it appears changing these parameters help show the progress in the menu bar. I haven't completed my testing on this. But, this is what I'll be doing.

--

Since I wrote the above answer, I tried it myself. If you have access to running Apple Script, I think still it is valid (therefore I will be testing it further myself).

However, found a quick win too:

percentage="10%"
counter=2
    
osascript -e "display notification \"script completed: ${percentage}\" with title \"Script ${counter} progress\""

Here I have used two variables. Feel free to adjust to your needs. Variables are optional. But I thought it'd be useful.

Secret sauce is the osascript command. You can pass the script command with the -e switch. And get that to run your display notification, which is not the most elegant. But without having to peak at the logs, you can see something around in the GUI now, while you work on other important tasks.

Again, to simplify, the bare-bone command would look something like:

osascript -e "display notification MyMessage with title MyMessageTitle"

A bit more complete version would look like:

osascript -e 'display notification "All graphics have been converted." with title "My Graphic Processing Script" subtitle "Processing is complete." sound name "Frog"'

Hope this helps a bit.

Reference: https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/DisplayNotifications.html

1
  • ScriptMonitor.app (which is what implements the menu item) can also be used with osascript (see stackoverflow.com/q/34081057/10853463), but entries are separate and work differently for scripts and Automator applications (which the OP is/was using).
    – red_menace
    Commented Sep 3, 2023 at 13:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .