Skip to main content
Solved

create environment variable over plist file


Forum|alt.badge.img+3

Hi all!

recently arrived to Apple management and I've got a task pending to fix: to setup two environment variables necessary for one GUI application.

I can setup them over a plist file stored in /Library/LaunchAgents, but same plist file doesn't work loading it as a Configuration Profile from Jamf Pro.

If I look for loaded profiles, it appears from Jamf as well as from terminal typing 'profiles list -all', but it doesn't work. Other plist files launched from Jamf are working properly but no for setting environment variables.

Could someone to assist on this?

Thanks a lot in advance

Best answer by BGhilardi

1. Create a LaunchAgent script
Create a com.resolve.env.plist file in /Library/LaunchAgents/ to set the environment for each user launch:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.resolve.env</string>

<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>BMD_RESOLVE_SUPPORT_DIR</string>
<string>/chemin/personnalise/pour/resolve</string>
</array>

<key>RunAtLoad</key>
<true/>

<key>StandardOutPath</key>
<string>/tmp/resolve_env.log</string>

<key>StandardErrorPath</key>
<string>/tmp/resolve_env.err</string>
</dict>
</plist>

Replace the path "/path/custom/for/resolve" with the actual path you want to use.

2. Deploy via Jamf
Zip the .plist file (or create it via script in a Files and Processes policy).

Place it in /Library/LaunchAgents/ on the target machines via a package or Jamf policy.

You can also use a deployment script in Jamf to automatically copy it:

#!/bin/bash

cat <<EOF > /Library/LaunchAgents/com.resolve.env.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.resolve.env</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>BMD_RESOLVE_SUPPORT_DIR</string>
<string>/chemin/personnalise/pour/resolve</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF

chmod 644 /Library/LaunchAgents/com.resolve.env.plist
chown root:wheel /Library/LaunchAgents/com.resolve.env.plist

 

3. Restart the user session
Once the .plist is installed, the variable will be set upon user login. If Resolve is subsequently launched, it will be available.

View original
Did this topic help you find an answer to your question?

11 replies

sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3536 replies
  • April 8, 2025

@javipcn Can you post more info on what app and what exactly you're trying to set? While Configuration Profiles are commonly used to manage preferences for an application they can't be used to deploy something to /Library/LaunchAgents, and that is not normally where app configurations are set.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • April 8, 2025

Hi!!

yes, the application is Davinci Resolve and it requires to set a variable called BMD_RESOLVE_CONFIG_DIR to the proper path: '$HOME/Library/Preferences/Blackmagic Design/DaVinci Resolve/' or to other custom path.

Maybe, the best way could be to create a script to execute the setenv command?

Thanks for your quick reply!


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3536 replies
  • April 8, 2025
javipcn wrote:

Hi!!

yes, the application is Davinci Resolve and it requires to set a variable called BMD_RESOLVE_CONFIG_DIR to the proper path: '$HOME/Library/Preferences/Blackmagic Design/DaVinci Resolve/' or to other custom path.

Maybe, the best way could be to create a script to execute the setenv command?

Thanks for your quick reply!


Do you have a reference to the docs with instructions to set that path? I am not familiar with that app, but that location should be the default location for an app to store user specific settings.


BGhilardi
Forum|alt.badge.img+7
  • Jamf Heroes
  • 28 replies
  • Answer
  • April 8, 2025

1. Create a LaunchAgent script
Create a com.resolve.env.plist file in /Library/LaunchAgents/ to set the environment for each user launch:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.resolve.env</string>

<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>BMD_RESOLVE_SUPPORT_DIR</string>
<string>/chemin/personnalise/pour/resolve</string>
</array>

<key>RunAtLoad</key>
<true/>

<key>StandardOutPath</key>
<string>/tmp/resolve_env.log</string>

<key>StandardErrorPath</key>
<string>/tmp/resolve_env.err</string>
</dict>
</plist>

Replace the path "/path/custom/for/resolve" with the actual path you want to use.

2. Deploy via Jamf
Zip the .plist file (or create it via script in a Files and Processes policy).

Place it in /Library/LaunchAgents/ on the target machines via a package or Jamf policy.

You can also use a deployment script in Jamf to automatically copy it:

#!/bin/bash

cat <<EOF > /Library/LaunchAgents/com.resolve.env.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.resolve.env</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>BMD_RESOLVE_SUPPORT_DIR</string>
<string>/chemin/personnalise/pour/resolve</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF

chmod 644 /Library/LaunchAgents/com.resolve.env.plist
chown root:wheel /Library/LaunchAgents/com.resolve.env.plist

 

3. Restart the user session
Once the .plist is installed, the variable will be set upon user login. If Resolve is subsequently launched, it will be available.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • April 8, 2025
sdagley wrote:

Do you have a reference to the docs with instructions to set that path? I am not familiar with that app, but that location should be the default location for an app to store user specific settings.


It's described in the file "User Configuration folders and customization.txt" copied once the app is installed. In that file you can read as follow for custom locations as it's our case:

 
Overriding paths:
=================
For custom installations, the following environment variables can be used to override the new locations. 
Note that these environment variables need to be set after installation, but before starting Resolve for the first time.
 
BMD_RESOLVE_SUPPORT_DIR: 
The Application support location. If not set, the value defaults to the new Application Support location for each platform.
 
BMD_RESOLVE_CONFIG_DIR: 
The configuration location. If not set, the value defaults to the new Configuration location for each platform.
 
BMD_RESOLVE_LOGS_DIR: 
The location of DaVinci Resolve logs. If not set, the value defaults to $BMD_RESOLVE_SUPPORT_DIR/logs as per the evaluation of BMD_RESOLVE_SUPPORT_DIR above.

...


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • April 8, 2025

Great BGhilardi, it looks nice. I'll test it as soon as I can do.

Thanks both!


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3536 replies
  • April 8, 2025
javipcn wrote:

It's described in the file "User Configuration folders and customization.txt" copied once the app is installed. In that file you can read as follow for custom locations as it's our case:

 
Overriding paths:
=================
For custom installations, the following environment variables can be used to override the new locations. 
Note that these environment variables need to be set after installation, but before starting Resolve for the first time.
 
BMD_RESOLVE_SUPPORT_DIR: 
The Application support location. If not set, the value defaults to the new Application Support location for each platform.
 
BMD_RESOLVE_CONFIG_DIR: 
The configuration location. If not set, the value defaults to the new Configuration location for each platform.
 
BMD_RESOLVE_LOGS_DIR: 
The location of DaVinci Resolve logs. If not set, the value defaults to $BMD_RESOLVE_SUPPORT_DIR/logs as per the evaluation of BMD_RESOLVE_SUPPORT_DIR above.

...


Do you need to override the default which would already be in "$HOME/Library/Preferences/Blackmagic Design/DaVinci Resolve/'?


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • April 8, 2025
sdagley wrote:

Do you need to override the default which would already be in "$HOME/Library/Preferences/Blackmagic Design/DaVinci Resolve/'?


Yes, that's the target, to set the path to another location as default


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3536 replies
  • April 8, 2025
javipcn wrote:

Yes, that's the target, to set the path to another location as default


Since you mentioned you've "recently arrived to Apple management" I'm going to ask what was the need to use another location? The $HOME/Library/Preferences directory is a standard Apple location and Blackmagic Design appears to have been following that standard.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • April 10, 2025
sdagley wrote:

Since you mentioned you've "recently arrived to Apple management" I'm going to ask what was the need to use another location? The $HOME/Library/Preferences directory is a standard Apple location and Blackmagic Design appears to have been following that standard.


Yes. We're working in a LAN where others resources are shared. The above examples are just some of the custom setup but there is others, required for us. The default preferenceces and other parameters to be used by Resolve are located in a shared folder.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • April 10, 2025

I've deployed the plist file as a package and it's properly copied to the destination folder, so it works!!

Just I need to check because it's installed to the first user loged in, but I need to do for any user so Macos are joined to a Windows domain. But I believe it's another question, maybe to copy the plist to the LaunchAgents from the home folder intead system folder.

Thanks BGhilardi for the tip!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings