My attempt at integrating macOS 10+ with SheepShaver to try to make it act more like the Classic enviroment

About SheepShaver, a PPC Mac emulator for Windows, MacOS X, and Linux that can run System 7.5.3 to MacOS 9.0.4.

Moderators: Cat_7, Ronald P. Regensburg, ClockWise

Post Reply
triclon
Space Cadet
Posts: 4
Joined: Mon Dec 26, 2022 8:14 am

My attempt at integrating macOS 10+ with SheepShaver to try to make it act more like the Classic enviroment

Post by triclon »

Hi Everyone,

A few years ago I tried to integrate SheepShaver with Mac OS X (now macOS 13+). The idea was to have SheepShaver act more like the Classic environment where you could open up OS 9 applications from the macOS 10+ Finder. I recently dug up my old attempt at this from 6 years ago and updated it extensivly until I got something that roughly works, so I thought I would post how I got this to work in case anyone else was interested in it. This uses a combination of scripts in both macOS 10+ and OS 9 that talk to each other.

In macOS 10+, I set up a script created in Automator as a Quick Action that can be accessed via right clicking an application or file in the macOS 10+ Finder. This script saves a text file with the path to the application/file and then opens Sheepshaver where an Applescript with an alias placed in the OS 9 System folder Startup Items reads the file with the path and opens the application/file in OS 9.

Setup

First you need a working Sheepshaver virtual machine. I personally use SheepShaver Wrapper (http://www.columbia.edu/~em36/sheepshaverwrapper.html) with SheepShaver Version 2.5, 22 December 2022 in macOS Ventura 13.1. I have Mac OS 9.0.4 installed. I think most other SheepShaver setups will work, but don’t quote me on it. You will need to point your Unix root to your home directory.
In your home directory, the scripts will create and use a file called os9_app_path.txt. You can modify the name of this file or where it is located but you will need to update the scripts below to reflect these changes, and it is not recommended unless you know what you are doing.

Create the Quick Action in macOS 10+

In macOS 10+ open /Applications/Automator

File New -> Quick Action

Set “Workflow receives current” to “files or folders” in “Finder”

Select Actions and type “Run Shell Script” into the field next to it

Drag “Run Shell Script” from the left side of the screen to the right side where it says “Drag actions or files here to build your workflow” (or double click Run Shell Script)

Set shell to "/bin/bash"

Set Pass Input to "as arguments"

Copy the following into the script:

Code: Select all

for f in "$@"
do
	printf "Unix:${f#*/*/*/}" | sed -r 's/[/]+/:/g' > $HOME/os9_app_path.txt #Save path to classic file
	iconv -f UTF-8 -t MACINTOSH $HOME/os9_app_path.txt > $HOME/os9_app_path_tmp.txt #Convert to text encoding for classic mac OS
	mv $HOME/os9_app_path_tmp.txt $HOME/os9_app_path.txt
done
Next add the action (from the left side of the screen) “Launch Application” and select SheepShaver. You probably will need to select “other” to find SheepShaver.

Save the Quick Action. I named it “open_in_os9” but you can name it whatever you want.

You might need to give permission to the quick action
System Settings -> Privacy & Security -> Extensions -> Finder
Click the checkbox next to the Quick Action your just created


Set up script in SheepShaver

Open SheepShaver

Create the following script using Applescript
The script editor is found (at least for me) under:
/Macintosh HD/Applications/Apple Extras/AppleScript/Script Editor

Copy the following into the script editor:

Code: Select all

on idle
	set app_path_file to "Unix:os9_app_path.txt"
	set open_this_app to read file app_path_file
	if text 1 thru 10 in open_this_app is not "***DONE***" then --Check if already opened app
		tell application "Finder"
			open file open_this_app
		end tell
		write "***DONE***" to file app_path_file --App has now been open so write ***DONE*** into app_path_file
	end if
	return 1 --wait 1 seccond before checking again
end idle

Save the script as a “classic applet” anywhere easily accessible. Make sure "Stay Open" and "Never Show Startup Screen" are both checked.

Make an alias of the script and place the alias in
/Macintosh HD/System Folder/Startup Items

How to use it

In the macOS 10+ Finder, right click an application or file you want to open in SheepShaver.
Scroll down to Quick Actions
You should see your Quick Action. Select it to open the file in SheepShaver.

You can leave SheepShaver running in the background and this will still work. You can also open multiple applications in this manner.

Some caveats

Quitting the opened classic application still leaves SheepShaver running. I tried adding shut down to the script inside of SheepShaver but it only worked some of the time, and caused other issues with some applications opening and then SheepShaver immediately shutting down. I found it easier to just manually shut down SheepShaver when finished.

The applescript running in SheepShaver will keep running. This will let you keep opening classic mac applications from macOS 10+ while SheepShaver is running. I might want to try figuring out a way to hide the running script, but otherwise it is not much of a problem. It probably adds a small amount of CPU usage but I doubt much.

I couldn’t figure out a way to directly double click classic applications in macOS 10+ to open them in SheepShaver. With these scripts, you still have to right click the file you are trying to open go to Quick Actions.
triclon
Space Cadet
Posts: 4
Joined: Mon Dec 26, 2022 8:14 am

Re: My attempt at integrating macOS 10+ with SheepShaver to try to make it act more like the Classic enviroment

Post by triclon »

I have decided to call this the "SheepShaver Classic Integrator."

I have made some minor improvements and bundled the scripts into a .zip file you can download to make it easier to install.

You can download v1.0 here:
https://drive.google.com/file/d/19NMJWY ... sp=sharing

Follow the installation instructions in the readme.

I have only tested this on my own machine (MacBook Pro 13 in 2020 Intel, running macOS 13.1 with SheepShaver Wrapper and the latest version of SheepShaver), so if anyone wants to try this out, I would appreciate any feedback you might have.
Last edited by triclon on Thu Dec 29, 2022 8:05 am, edited 1 time in total.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: My attempt at integrating macOS 10+ with SheepShaver to try to make it act more like the Classic enviroment

Post by emendelson »

This is extremely impressive. Thank you!

A few quick notes:

Under Ventura, I had to use System Settings->Security & Privacy->Extensions (near the foot of the menu, under Others)->Finder-> where I could find the extension. (It was already checked when I looked for it). The readme seems to omit one of those destinations.

Probably you've already considered this, but it might be possible to create an AppleScript app in current macOS, so you could drop a classic app on it to open it in SheepShaver. That might also be useful for opening files from macOS in the relevant application in SheepShaver.

Have you looked at the background actions script in my Mac OS 9 for OSX/macOS? It uses some of the same techniques that you use in your script, but mine merely copies a file from macOS to the SheepShaver desktop.

This is very, very impressive work. Thank you again.
triclon
Space Cadet
Posts: 4
Joined: Mon Dec 26, 2022 8:14 am

Re: My attempt at integrating macOS 10+ with SheepShaver to try to make it act more like the Classic enviroment

Post by triclon »

Thank you for the feedback. I fixed the installation instructions in the readme.

Do you think scripts to transfer files would be a useful to these scripts on top of access to the "unix" drive?

I will take a look at your background script running in OS 9. Feel free to incorporate my code into your own scripts if you would like.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: My attempt at integrating macOS 10+ with SheepShaver to try to make it act more like the Classic enviroment

Post by emendelson »

I think you're the best person to decide what might be useful in your system. After trying it for a while, I decided that - for myself - what would be most useful would be an AppleScript app that I could run in macOS, with the same name as a Mac OS (classic) app in SheepShaver. I could click on the app in macOS and the app with the same name would open in SheepShaver. And if I were intelligent enough to figure out how to do it, I would make it work so that I could drop a file on the AppleScript app in macOS - and it would be copied to the SheepShaver desktop and opened there in the named app.

But that's a project for the future!
Post Reply