[meta] macOS Shortcut to tell you if Shapr3D quit yet

This post describes the difficulty of restarting Shapr3D on macOS to get around bugs, and a Shortcut (shortcuts app) to easily help you monitor it until it quits.

Problem:
Shapr3D still has a bunch of bugs on macOS and many of them are solved by simply quitting and restarting it.

Unfortunately, Shapr3D Takes a reeeealy long time to actually quit behind the scenes. To the user it looks like it quits instantly, but it’s actually still running just with no user facing stuff. On my machine it’s ~37 seconds before it finally quits.

If you restart it before it’s fully shut down it just redraws the window instead of actually “restarting” because it never actually quit.

So, if you need to actually restart it to get past a bug you need to wait until it fully quits, so you need to know when it fully quits.

Solution:
Create a new Shortcut with the Shortcuts app that opens Activity Monitor and searches for Shapr so that you know when it’s actually quit and can be restarted.

Here’s what it looks like:

It’s a simple 2 step Shortcut.

  • “Open App” action with “Activity Monitor” as the name of the app to open.
  • “Run Applescript” action with the following text in it.
on run {input, parameters}
	(* Your script goes here *)
	tell application "Activity Monitor" to activate
	tell application "System Events"
		keystroke "f" using {command down, option down}
		keystroke "Shapr"
	end tell
	return input
end run

You’ll Also need to go grant the Shortcuts app the permission to type things.

System Settings > Privacy & Security > Accessibility - toggle the switch next to Shortcuts.

Full disclosure this does mean that if you run shortcuts you didn’t create they could do anything you can do with a keyboard, which is a potential security risk.

When you run this script it opens Activity Monitor, and types the keycombo to select the search box. Then it types in “Shapr”. After a short pause for the net poll of Activity Monitor you should see this.

just wait for the row with the Shapr3D icon to go away. That’s when it’s finished quitting.

BONUS:
Did you know you can invoke shortcuts from the Elgato Stream Deck? Now I’ve got a physical button on my desk that I can press to invoke this. Yes, I have to do it that often.

2 Likes

Isn’t that easier to do using ps instead of activity monitor?

BTW: on my Mac it stops after 2-3 sec totally.

If you need it I can write bash script which will kill current process, wait till it stops completely and rerun the app.

Here is the code. Just put it in the .sh file and give it executable permissions.

#!/usr/bin/env bash
APP="/Applications/Shapr3D.app/Contents/MacOS/Shapr3D"

PID=`ps axw | grep -v "grep" | grep $APP | awk ' { print $1 }'`


while kill $PID 2> /dev/null; do
    echo "Still running..."
    sleep 1
done

exec $APP 2> /dev/null  &

To force it run by mouse double-clicking change the extension to .command

1 Like

Just an example how it can be used

1 Like

Great shell script! Most of my career was spent as a Unix Sysadmin, and my first instinct is still to look for a command line solution. Although, to be fair to masukomi, the AppleScript shortcut is a pretty clever solution for all these young kids who only feel comfortable in a GUI environment :grin:

Also, excellent choice in wallpaper.

I’m still on this way :slight_smile:

It is but… you need to close the app, then run this shortcut and after you see app is closed rerun the app.

Mine solution is all in one, you just need to run it and it will done the job. Also no necesity of strange permissions for shortcuts app.

Oh, I absolutely agree that your shell script is a much better solution. I guess I’m just a grumpy old fart who couldn’t resist being a little snarky towards the younger generation who rarely bother to learn or understand everything that this amazing hardware and software can do for them.

1 Like

That’s why I like MacOS so much because it is almost that old good linux undercover :slight_smile:

Agree wholeheartedly!!! And anything not included can easily be found with Homebrew or Github.

1 Like

Made app-like variant. Just unpack and run it then you need it.

Restart.zip (842.1 KB)

1 Like

Thanks, I wasn’t really asking for a copy — just recognizing your good taste :slightly_smiling_face:

That wasn’t for you but you free to use it :laughing: