another thorny permissions issue

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9356
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: another thorny permissions issue

Post by richmond62 » Tue Jul 05, 2022 1:23 pm

Anyway, I shall be stealing your solution, including the spaces trick
Glad to know, and glad to make someone happy for once. 8)

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: another thorny permissions issue

Post by marksmithhfx » Tue Jul 05, 2022 1:24 pm

richmond62 wrote:
Tue Jul 05, 2022 1:01 pm
Just checked WITH & WITHOUT Safari running.
Ah, now you can never say NEVER 😊
Last edited by marksmithhfx on Thu May 25, 2023 10:37 pm, edited 1 time in total.
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9356
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: another thorny permissions issue

Post by richmond62 » Tue Jul 05, 2022 1:26 pm

Ah, now you can't save NEVER
Indeed.

Though I use Brave for 99% of my needs on Mac OS 12.5,
Opera on Mac OS 10.6.8 and a 'kinky' version of Firefox on Mac OS 10.7.5.

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: another thorny permissions issue

Post by marksmithhfx » Tue Jul 05, 2022 9:02 pm

Just to top off this discussion, this is what I ended up with in the open card handler (1st thing) so the user generally has to quit Safari to use my app. Even though I've been hammering away at my Safari bookmarks on two laptops, about 10 times a day, for over a month with no obvious corruption or other negative consequence, it's still good practice not to have two different apps dealing with the same output file (when there are no obvious multi-user controls in place). Accidents will happen.

Code: Select all

   -- check if Safari is open 
   repeat while (shell("top -o rsize -ncols 2 -l 1")) contains "safari "
      -- put up dialog
      answer warning "Please quit Safari before continuing with this program." with "Cancel" or "Ok"
      if it is "Cancel" then quit
   end repeat
Thanks to everyone for your help on this. It was an important milestone to achieve.

Mark
Last edited by marksmithhfx on Wed Jul 06, 2022 10:55 am, edited 2 times in total.
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: another thorny permissions issue

Post by FourthWorld » Wed Jul 06, 2022 4:13 am

marksmithhfx wrote:
Mon Jul 04, 2022 10:00 pm
FourthWorld wrote:
Mon Jul 04, 2022 5:47 pm
shell("top") will return a list of running processes.
Thanks Richard. LC 9.6.8 rc2 using

Code: Select all

get shell("top")
assuming it goes into the it variable also hangs livecode. Is there an alternative I'm not thinking of?
It needs the -n option (number of iterations), with 1 for the value, e.g.: shell("top -n 1")

But that's not likely to do what you need either, because as wonderful as bash is some programs need the shell context set for a user to call them. I think there's a way to do that from LC (Mark Weider probably knows off the top of his head), but I don't do enough with LC these days to have time to figure that out.

Consolation prize: while this won't help your Mac needs, this is a fun read, a Linux Journal article by Dr Raney from '97 showing how to write a GUI alternative to top, by traversing the /proc directories directly:
https://www.linuxjournal.com/article/2110
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: another thorny permissions issue

Post by marksmithhfx » Wed Jul 06, 2022 11:06 am

FourthWorld wrote:
Wed Jul 06, 2022 4:13 am
Consolation prize: while this won't help your Mac needs, this is a fun read, a Linux Journal article by Dr Raney from '97 showing how to write a GUI alternative to top, by traversing the /proc directories directly:
https://www.linuxjournal.com/article/2110
Thanks Richard... looks like an interesting read. Will take a closer look at it when I get a few minutes later today.

Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: another thorny permissions issue

Post by FourthWorld » Wed Jul 06, 2022 5:35 pm

I found the shell problem tugging at me, so I found the solution:
1. Specify the terminal type in $SHELL (LC's shell runs outside a user context)
2. Specify batch mode ("-b") for non-console use

This works on Linux, and may likely work on macOS but I haven't tested it there:

Code: Select all

put "xterm" into $TERM; put shell("top -bn 1")
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: another thorny permissions issue

Post by marksmithhfx » Thu Jul 07, 2022 5:42 pm

FourthWorld wrote:
Wed Jul 06, 2022 4:13 am
Consolation prize: while this won't help your Mac needs, this is a fun read, a Linux Journal article by Dr Raney from '97 showing how to write a GUI alternative to top, by traversing the /proc directories directly:
https://www.linuxjournal.com/article/2110
Thanks Richard. Interesting read. I think I'll try and build a graphical UI to the "top" command using the example he provided. Might not get far, but will be interesting to try.

PS have not tried your latest suggestion but while fooling around earlier in bash I did get an error using -b as an unsupported parameter. Such a shame all the bashes have different language elements. Makes finding good examples harder since they don't always translate to the Mac.

Life eh?

Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: another thorny permissions issue

Post by FourthWorld » Thu Jul 07, 2022 6:01 pm

marksmithhfx wrote:
Thu Jul 07, 2022 5:42 pm
FourthWorld wrote:
Wed Jul 06, 2022 4:13 am
Consolation prize: while this won't help your Mac needs, this is a fun read, a Linux Journal article by Dr Raney from '97 showing how to write a GUI alternative to top, by traversing the /proc directories directly:
https://www.linuxjournal.com/article/2110
Thanks Richard. Interesting read. I think I'll try and build a graphical UI to the "top" command using the example he provided. Might not get far, but will be interesting to try.
I don't know how accessible macOS' equivalent to /proc is, but I'm keen to hear what you find.
PS have not tried your latest suggestion but while fooling around earlier in bash I did get an error using -b as an unsupported parameter. Such a shame all the bashes have different language elements. Makes finding good examples harder since they don't always translate to the Mac.
There are several open source packages that are out of date as shipped with even the latest versions of macOS. This is mostly due to license changes in a project.

For example, macOS ships with a version of rsync that's many years old, because several years ago rsync moved from GPV v2 to v3, and v3's patent pool clause was apparently a turnoff to a company that derives much of its value from patent encumbrance.

With rsync the downsides are non-trivial: there are many known vulnerabilities logged against the version Apple ships with. Seasoned command-line fans have become accustomed to use third-party packagers to keep up with tools like that.

I don't know if this sort of thing is why -b to trigger batch mode didn't work with top on macOS. I'll see if I can get some time to explore that next week, but if you learn anything in the meantime I'd been keen to hear what you discover.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: another thorny permissions issue

Post by marksmithhfx » Fri Aug 26, 2022 8:15 pm

paul@researchware.com wrote:
Sun Jul 03, 2022 2:29 pm
If you have a link or a button that executes:
launch url "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles//"

It will open the correct panel. The user still needs to scroll to the Full Disk Access, unlock the setting with their admin password, and manually add the app.
Thanks Paul, I have been using your example. I was discussing this the other day with Stam and he suggested some AppleScript he had tested that opened the Privacy panel and highlighted (and selected) the Full Disk Access sub-section.

Code: Select all

openURL:(current application's NSURL's URLWithString:"x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles")
This looked very similar to your example so I decided to try it without the trailing "//" and it worked. Selected "Full Disk Access" (although it did not scroll "Full Disk Access") it was at least highlighted and selected reducing the steps the user has to take to 2: unlock the privacy panel and put a check in the box next to the application you want to authorise."

Given the reduction in steps, I made a custom dialog to explain what needs to be done to the end user. I'm not saying this is a perfect solution, but it was the best I could come up with. Perhaps this may be of some use to yourself or others. Thanks again for posting your original message as it really got this ball rolling.

Image

PS the image resolution is actually better in the app than it is in this screenshot, or I need new glasses :)

Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: another thorny permissions issue

Post by marksmithhfx » Thu Sep 29, 2022 5:02 pm

While I am on about custom dialog boxes, and before I make a feature request, does anyone know if anything like the following dialog is supported in LC presently. I think this is what the "standard" dialogs in macOS look like these days, and based on past experience I think rolling your own is the only way to achieve this look. Correct?

Thanks
Mark


Screenshot 2022-09-29 at 4.54.29 pm.png
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: another thorny permissions issue

Post by stam » Thu Sep 29, 2022 5:48 pm

Just use 'sheet'
It creates a window-modal dialog out of a stack centred on the parent window, dims and inactivates the parent window.
Just create a substack (called, say, "alert") and model it as you see fit.

To show, just use:

Code: Select all

sheet stack "alert"
As this is window-modal you have to include a control to close it. If you get stuck in the IDE you can either close the stack or change it's style to "topLevel", eg with a command in the messageBox.

I'm using this right now and it works great...

S.

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: another thorny permissions issue

Post by marksmithhfx » Thu Sep 29, 2022 5:51 pm

stam wrote:
Thu Sep 29, 2022 5:48 pm
Just use 'sheet'

I'm using this right now and it works great...

S.
Thanks Stam. Will give it a go.
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: another thorny permissions issue

Post by stam » Thu Sep 29, 2022 5:56 pm

marksmithhfx wrote:
Thu Sep 29, 2022 5:51 pm
stam wrote:
Thu Sep 29, 2022 5:48 pm
Just use 'sheet'

I'm using this right now and it works great...

S.
Thanks Stam. Will give it a go.
I forgot to mention that "sheet" will only work this way with MacOS 12 or newer. Older versions of MacOS show the substack as an old-fashioned sheet (ie sliding out of the titlebar and remaining fixed to it, which is not what you're after).

As of MacOS 12 the HIG for 'sheet' has changed to be a centred window-modal as described above.
Read more about the HIG here: https://developer.apple.com/design/huma ... on/sheets/

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: another thorny permissions issue

Post by marksmithhfx » Thu Sep 29, 2022 6:27 pm

stam wrote:
Thu Sep 29, 2022 5:56 pm
I forgot to mention that "sheet" will only work this way with MacOS 12 or newer. Older versions of MacOS show the substack as an old-fashioned sheet (ie sliding out of the titlebar and remaining fixed to it, which is not what you're after).
I'm on 12 so that works. However, we'll see what kind of response we get in beta testing. I am actually hoping to put this app into the new macOS TestFlight program and distribute beta's from there. Anyone have any experience with that?

Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”