String.openOS

Hi,

I am using String.openOS with URL strings to help the user open specific web pages in the default browser. This works fine on Windows, but on Macs nothing happens. Presumably my MacOS or Mac browser needs to be told to permit this. Does anyone know where to look?

sternsc

hmmm “http://example.com”.openOS is working fine for me on Mac 15.6.1… What SC and system versions and which default browser do you use?

I’m on Sequoia, MacOS 15.7.2 and SuperCollider 3.14.1. Tried with both Safari and Firefox as default browser, same non-result.

  • If I invoke myURLstring.openOS in the Command window (Cmd-E), the string is posted as the return value (a String object) in the Post window.
  • If I invoke the same thing in my code, nothing happens.
  • If I invoke [“open”, “http://example.com”].unixCmd from the Command window, an integer (a process ID?) is posted in the Post window, but nothing else happens.
  • If I invoke open “http://example.com” in a terminal shell, it works. Which is essentially what .openOS should be doing, I thought…
    Any ideas?

sternsc

openOS is implemented as follows:

openOS {
    ["open", this].unixCmd;
}

So "http://example".openOS is really the same as [“open”, “http://example.com”].unixCmd.

I don’t know why it wouldn’t work…

Maybe there is no default browser set up?

I remember years ago, using some external tools like lilypond, runInTerminal worked while unixCmd did not. I don’t remember the reason right now

I could not reproduce the issue with SC 3.14.1 and Firefox set as the default browser on macOS 15.7.2 (M1 Max). Could you record your actions and the SC output using QuickTime’s “New Screen Recording”?

1 Like

Not sure if it would reveal the underlying reason. But I can say that I, at least once, saw something similar happening with me.

Found it! At the start of my program, I add Platform.resourceDir to the start of the PATH in the environment. But the path delimiter character is different on Windows ($;) and Mac ($:), so the usual bin directories were not parsed from the Mac PATH. So the open shell command was not found. Problem solved.

Embarrassing though, that I have forgotten why I am adding Platform.resourceDir to the PATH - maybe there is no good reason to do that.

sternsc

2 Likes