<?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.pmset</string>
<key>ProgramArguments</key>
<array>
<string>pmset</string>
<string>womp</string>
<string>0</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
The best way to do it is with launchd, it's not quite as simple as a login or startup item, but by creating it in /Library/LaunchDaemons it can run as root.
The file you'd want to create would look something like:
Code:<?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.pmset</string> <key>ProgramArguments</key> <array> <string>pmset</string> <string>womp</string> <string>0</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
Just create the file in that format under something like:
/Library/LaunchDaemons/com.pmset.plist
This should cause it to run invisibly, and you can use the label of com.pmset to check that it's running in the Console.
While it's a bit more of a learning curve, I think that launchd is the best way to run anything at start-up, on a specific date (daily, weekly etc.), or for watching out for volume changes (mount) or folder updates. I use it now for all sorts of things, including setting the noatime flag on some volumes, checking if Macports needs updating and so-on.
sudo chown root:wheel /Library/LaunchDaemons/com.pmset.plist
sudo chmod 755 /Library/LaunchDaemons/com.pmset.plist
sudo launchctl list | grep 'com.pmset'
The most probable problem is that you don't have the permissions right on the file. It should be owned by root, and needs to be readable by root, and not writeable by anyone other than root. The following commands should take care of that:
Note that I am assuming the example path given above (which I would never normall use... it should not be "com.", but something like "personal.pmset.plist"). You can check if it has run with:Code:sudo chown root:wheel /Library/LaunchDaemons/com.pmset.plist sudo chmod 755 /Library/LaunchDaemons/com.pmset.plist
If it has sucessfully run there should be a '-' in the first column, and a '0' in the second. Otherwise you might want to look in the system log.Code:sudo launchctl list | grep 'com.pmset'