Any way to use a different prefs file?

About BasiliskII, a 68k Mac emulator for Windows, MacOSX, and Linux that can run System 7.x through MacOS 8.1.

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
bribri
Tinkerer
Posts: 41
Joined: Tue Apr 04, 2023 4:20 am

Any way to use a different prefs file?

Post by bribri »

I want to create a self-contained Basilisk II that uses a different preferences file than ~/.basilisk_ii_prefs, so I can configure it for a specific task without affecting my current Basilisk II settings. Ideally it'd use a prefs file in the same folder as the app itself. The host system is running macOS.

Is there any way to do that?
User avatar
Cat_7
Expert User
Posts: 6451
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Any way to use a different prefs file?

Post by Cat_7 »

This should work:

You create a command file that starts BasiliskII with the argument --config prefs_file_name.
So first set the desired settings with the GUI. Then make a textfile (I use 81.txt as example below to start MacOS 8.1) and copy the content of your current .basilisk_ii_prefs file into it.
Save the file as 81.txt

Then make a new text file.
Content should be something like this:

Code: Select all

#!/bin/bash
cd "$(dirname "$0")"

/Applications/BasiliskII/BasiliskII.app/Contents/MacOS/BasiliskII --config /Applications/BasiliskII/81.txt
Save the file with .command extension and make the file executable and you're done. When you double-click the command file Basilisk will use the prefs in the 81.txt file.
A terminal window opens in which you see Basilisk start. I don't know whether this can be prevented.

You can create multiple command files each pointing to a different text file with different prefs.

You can then no longer use the GUI to change settings, unless you repeat the step to copy your desired prefs into one of the multiple text files.
But you can edit the new prefs files with textedit.


Best,
Cat_7
emendelson
Forum All-Star
Posts: 1875
Joined: Tue Oct 14, 2008 12:12 am

Re: Any way to use a different prefs file?

Post by emendelson »

You might look at the self-contained apps I posted here:

https://mendelson.org/selfcontained.html

The MacOS folder contains a script, not an executable, and you can edit the script to suit your needs. The "bii.prefs" file can also be rewritten or replaced with any other prefs file you want, and that prefs file can be called by the script.

And credit where credit is due: Some of the details in the script were first sugested by adespoton in this forum.
bribri
Tinkerer
Posts: 41
Joined: Tue Apr 04, 2023 4:20 am

Re: Any way to use a different prefs file?

Post by bribri »

Cat_7 wrote: Tue Apr 08, 2025 5:03 am You create a command file that starts BasiliskII with the argument --config prefs_file_name.
Thanks, I was thinking I might try something like that. I take it there's no way to also specify which prefs file the GUI will edit?
bribri
Tinkerer
Posts: 41
Joined: Tue Apr 04, 2023 4:20 am

Re: Any way to use a different prefs file?

Post by bribri »

Another follow up question: is there a way to use a different xpram file too? (Is that even all that important?)
User avatar
adespoton
Forum All-Star
Posts: 4620
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com

Re: Any way to use a different prefs file?

Post by adespoton »

bribri wrote: Tue Apr 08, 2025 3:20 pm Another follow up question: is there a way to use a different xpram file too? (Is that even all that important?)
That can be important if you're flipping between different OSes while using the same XPRAM file.

Since you seem to be using macOS as your host system, you could try fiddling with https://github.com/adespoton/macosemushells -- these are severely outdated compared to the ones I use today, but they show a solution for custom config and xpram files (I *think* the 7.0.1P through 7.1.2P setups are all using BII in this revision of my shells).
emendelson
Forum All-Star
Posts: 1875
Joined: Tue Oct 14, 2008 12:12 am

Re: Any way to use a different prefs file?

Post by emendelson »

I finally figured out (it should have been obvious) how to modify the code to save the xpram file inside the app, and will post instructions sometime in the next few days. Stay tuned.
bribri
Tinkerer
Posts: 41
Joined: Tue Apr 04, 2023 4:20 am

Re: Any way to use a different prefs file?

Post by bribri »

I figured out how to compile BasiliskII myself, so I can also just modify the source code now to have it look for these files in different places.

However, there's still the GUI. That's not open source, correct? I don't suppose there's any way to convince it to use a different preferences file, is there?
emendelson
Forum All-Star
Posts: 1875
Joined: Tue Oct 14, 2008 12:12 am

Re: Any way to use a different prefs file?

Post by emendelson »

bribri wrote: Wed Apr 09, 2025 12:34 pm I figured out how to compile BasiliskII myself, so I can also just modify the source code now to have it look for these files in different places.

However, there's still the GUI. That's not open source, correct? I don't suppose there's any way to convince it to use a different preferences file, is there?
No way to edit the GUI. (For what it's worth, I never use the GUI - I always edit the prefs files by hand.)
emendelson
Forum All-Star
Posts: 1875
Joined: Tue Oct 14, 2008 12:12 am

Re: Any way to use a different prefs file?

Post by emendelson »

As a way to waste time, I modified the code so that the prefs file can optionally specify the folder path and/or filename of the BasiiskII xpram file.

Here is a notarized copy of the modified build:

https://www.dropbox.com/scl/fi/2pd2nqhv ... klpfo&dl=0

And here is a fork of the code with the modifications included. My code is incompetent, so I'm not sure I want to propose a pull to the main branch, but maybe kanjitalk755 will do a better job of it.

https://github.com/emendelson/macemu-xpram
emendelson
Forum All-Star
Posts: 1875
Joined: Tue Oct 14, 2008 12:12 am

Re: Any way to use a different prefs file?

Post by emendelson »

And kanjitalk755 has now implemented this feature properly, so it's part of the standard code for macOS. I've updated my System761 and System Seven apps to write the xpram file to custom locations in the user's Library/Application Support folder.
User avatar
Cat_7
Expert User
Posts: 6451
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Any way to use a different prefs file?

Post by Cat_7 »

kanjitalk755 has now implemented this feature properly, so it's part of the standard code for macOS.
Not for windows users?

Best,
Cat_7
emendelson
Forum All-Star
Posts: 1875
Joined: Tue Oct 14, 2008 12:12 am

Re: Any way to use a different prefs file?

Post by emendelson »

kanjitalk755 says it's only for macOS. Shall we both look at the Windows code and see if it's possible to do the same? I'll try to get to it today. But I'm a third-rate (make that fourth-rate) coder, so I doubt I'll succeed.

EDIT: I'm at a Mac now, so can't test, but the thing to do seems to be to edit Windows/xpram_windows, and find the section "static void build_xpram_path(void)". Then add the test for the path that kanjitalk755 added to the macOS version; if the xrpam pref is not present, use the existing setting. The trouble is that the code SEEMS to need double-backslashes, not single ones. Presumably we don't want the user to enter two backslashes, and presumably there's a way to replace single backslashes in a string with double backslashes, but I don't know what it is.

EDIT2: If it's necessary to replace backslashes with double backslashes, then maybe one of these methods will work:

https://stackoverflow.com/questions/610 ... -backslash

Of course you could simply ask kanjitalk755 to implement this - he probably could do it in two minutes or less.
User avatar
Ronald P. Regensburg
Expert User
Posts: 8051
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Any way to use a different prefs file?

Post by Ronald P. Regensburg »

Didn't we always strive with these emulators for platform parity feature wise? Better ask kanjitalk755 to implement this feature for all platforms.
emendelson
Forum All-Star
Posts: 1875
Joined: Tue Oct 14, 2008 12:12 am

Re: Any way to use a different prefs file?

Post by emendelson »

I prefer to try to do something by myself before asking kanjitalk755 to do it, and I figured out how to specify an xpram filename and location for BII under Windows. It required adding three lines of code. It's very incompetent code, but it seems to work. I'll post it on GitHub tomorrow and will ask kanjitalk755 to provide a more competent version.

Meanwhile, here's a codesigned BII exe for Windows that lets you specify the xpram file location in the prefs file like this:

Code: Select all

xpram c:\path\to\xpramfilename
The download is here:

https://www.dropbox.com/scl/fi/tils31j3 ... tg83p&dl=0
emendelson
Forum All-Star
Posts: 1875
Joined: Tue Oct 14, 2008 12:12 am

Re: Any way to use a different prefs file?

Post by emendelson »

And I've updated my Windows code so that it's only moderately incompetent, not very incompetent, and I've posted a pull request for kanjitalk755. With luck, kanjitalk755 will improve it as needed and will put an improved version into the standard code.
emendelson
Forum All-Star
Posts: 1875
Joined: Tue Oct 14, 2008 12:12 am

Re: Any way to use a different prefs file?

Post by emendelson »

And kanjitalk755 accepted my code and merged it. I think I must have got it right purely by luck.
Post Reply