3

I need to execute a command-line tool to force maximum display brightness before user logs in (so login screen is shown with maximum brightness)

My problem is, if I run it from LaunchDaemons, it doesn't work. I think it is because from LaunchDaemons you can't run anything that interacts with the Window Server.

If I run it from LaunchAgents, it works. But it runs after login, so it is not an option.

Is there any alternative to LaunchDaemons to run scripts or programs that allow WindowServer access?

1
  • Do you need to run a specific brightness tool – or will a general Mac display brightness tool work? See mac display brightness at GitHub. Commented Oct 19, 2019 at 8:31

1 Answer 1

6

PreLoginAgents

macOS supports the ability to run graphical applications pre-login:

Running Agents Before Login

Most software that displays a user interface does not run prior to the user logging in. However, in some rare cases, it may be necessary to create a graphical agent that does.

By default, OS X does not allow any application to draw content prior to login. If you need to do so, your agent must call the setCanBecomeVisibleWithoutLogin: method on its windows. For more information, see the documentation for that method and the PreLoginAgents sample code.

The trick is to add the following lines to your /Library/LaunchAgents launchd plist:

<key>LimitLoadToSessionType</key>
<string>LoginWindow</string>

The executable must be stored in /Library/PrivilegedHelperTools.

We used this ability to show a notification window pre-login for Power Manager pending events.

This functionality may not be supported in the latest macOS; we have not relied on it for a long while.

2
  • 1
    It works !!!! I followed the coding example in the link you provided and I was missing 2 things: 1) PLIST in LaunchAgents vs LaunchDaemons, and 2) executable in /Library/PrivilegedHelperTools .
    – rupps
    Commented Oct 19, 2019 at 20:47
  • 1
    Great to hear you have it working. I have updated the answer to mention the LaunchAgents and helper tools folders. Commented Oct 20, 2019 at 9:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .