在 El Capitan (10.11) 中使用 LaunchAgents

Using LaunchAgents in El Capitan (10.11)

我有一系列脚本 运行 在一个标准用户、一个管理员用户和默认用户模板的负载下。对于这个特定的示例,他们配置了背景和屏幕保护程序(因为这些是无法有效内置到图像中的 ByHost 首选项。)

但是,由于 10.11 中 /sbin/ 不再可访问,我的脚本都失败了。当将它们从我的 Admin Files 文件夹更改为 运行 时,它们仍然什么也没做。

这是通常放在 /sbin/

中的命令
#!/bin/sh

## Admin Platform Services User Customization Script - Default User Desktop - (Version 7.0 - Twilight Sparkle) B
## 7.1 (Late 2015) 10.10 Version - Updated with new directory structure and script 
## Single-Run Script to Change the Default User's Background

## Force background for Default User
/Admin-Files/Cosmetic\ Scripts/Background\ Engine/ChangeDesktop.py --path /Admin-Files/Admin\ Backgrounds/7.0\ Default\ User\ Backgrounds/OSX10\ -\ Geblin\ Mekkatorque\ -\ Default\ Large.png 

## Removes the .plist LaunchAgent from inside the User Launch Agent Folder. 
rm -f ~/Library/LaunchAgents/set-user-bg-osx10.plist

PLIST 在这里:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>set-user-bg-osx10</string>
   <key>Program</key>
   <string>/Admin-Files/Scripts/Scripts/OSX10/set-user-bg-osx10</string>
   <key>RunAtLoad</key>
   <true/>
</dict>
</plist>

现在什么都没有发生。这在之前的 OSX11 测试版中确实有效,但在 GM 中不再有效。

哦还有一件事:权限:

chmod 444 /Blizzard-Files/Scripts/Scripts/OSX10/set-user-bg-osx10.plist 
chmod +X /Blizzard-Files/Scripts/Scripts/OSX10/set-user-bg-osx10

如果有人遇到这样的问题,解决方法非常简单。

将 /sbin/ 更改为 private/etc/

然后它就像一个魅力。