2

Previously,

% launchctl submit -l label -- command args

was the way to go.

This does not work in 10.11.2, I'm fairly sure it was working in 10.10.x, but cannot be certain.

The likely-looking plist does not welcome manual editing:

% defaults read ~/Library/Preferences/com.apple.loginitems.plist
{
    SessionItems = {
        Controller = CustomListItems;
        CustomListItems = (
            ...,
            {
                Alias = <00000000 00ec0003 00010000 d29c9a2e 0000482b 00000000 00083b9f 00083ba5 0000d217 ce980000 00000920 fffe0000 00000000 0000ffff ffff0001 00140008 3b9f0008 3b9e0007 91170007 91160007 9115000e 001c000d 00530070 00650063 00740061 0063006c 0065002e 00610070 0070000f 00300017 00410050 0050004c 00450020 00530053 00440020 00530044 00300031 00320038 00460020 004d0065 00640069 00610012 00386f70 742f686f 6d656272 65772d63 61736b2f 4361736b 726f6f6d 2f737065 63746163 6c652f31 2e302e31 2f537065 63746163 6c652e61 70700013 00012f00 ffff0000>;
                CustomItemProperties = {
                    "com.apple.LSSharedFileList.Binding" = <646e6962 00000000 02000000 00000000 00000000 00000000 00000000 41000000 00000000 66696c65 3a2f2f2f 6f70742f 686f6d65 62726577 2d636173 6b2f4361 736b726f 6f6d2f73 70656374 61636c65 2f312e30 2e312f53 70656374 61636c65 2e617070 2f1d0000 00000000 00636f6d 2e646976 69736962 6c656279 7a65726f 2e537065 63746163 6c650000 000000f4 07008e40 10100200 00009855 a21b>;
                };
                Name = "Spectacle.app";
            },
            ...
        );
    };
}
%

There's surely a better way?

5

Well, it seems there's no cleaner way than Applescript - at least my searches have turned up nothing.

So I've written a simple script to add/remove/list login items:

% loginitems -a Caffeine -p "/Applications/Caffeine.app"
% loginitems -l
Caffeine
% loginitems -d Caffeine
% loginitems -l
%
  • Shouldn't the Homebrew formula that you created for this be in a separate tap instead of a fork of the legacy Homebrew repository, which was deprecated by what the project's maintainers and contributors called the 'core/formula split,' which was documented in this GitHub issue? Fixing this would clear a lot of cruft out of your repository, don't you agree? – RandomDSdevel Dec 21 '16 at 19:35
  • @RandomDSdevel cf. github.com/ojford/homebrew-formulae (brew tap OJFord/formulae && brew install loginitems, or I think just brew install OJFord/formulae/loginitems also works) – OJFord Dec 21 '16 at 20:59
  • Great! Thanks for acting so quickly on my suggestion! – RandomDSdevel Dec 21 '16 at 21:14
  • @RandomDSdevel I didn't ;) (see history.) – OJFord Dec 21 '16 at 21:22
  • Ah, so you just forgot to add a deprecation notice and redirect to the old fork (or simply haven't gotten around to it yet.) – RandomDSdevel Dec 21 '16 at 21:31

You must log in to answer this question.

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