{"id":1523,"date":"2013-01-22T14:10:02","date_gmt":"2013-01-22T14:10:02","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=1523"},"modified":"2013-01-22T14:11:50","modified_gmt":"2013-01-22T14:11:50","slug":"adding-and-removing-individual-login-items-from-terminal","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=1523","title":{"rendered":"Adding and removing individual login items from Terminal"},"content":{"rendered":"<div>There is a way to use the\u00a0<tt>defaults<\/tt>\u00a0command-line tool to add items to the\u00a0<em>Login Items<\/em>\u00a0list of the\u00a0<em>Accounts<\/em>\u00a0or\u00a0<em>Users &amp; Groups<\/em>\u00a0System Preference panel:<\/div>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">defaults write loginwindow AutoLaunchedApplicationDictionary -array-add '{ &quot;Path&quot; = &quot;\/path\/to\/itemname&quot;; &quot;Hide&quot; = 0; }'<\/div><\/div>\n<p>Unfortunately, Apple provides no easy way to use\u00a0<tt>defaults<\/tt>\u00a0to remove a given login item from the list. While you can remove all login items by deleting<em>AutoLaunchedApplicationDictionary<\/em>, that&#8217;s usually not what you want to do.<\/p>\n<p>Luckily, there&#8217;s another way to do it that does allow removal of individual items as well as other things.<\/p>\n<p>A nice work-around solution is to instead use the\u00a0<tt>osascript<\/tt>\u00a0command-line tool to do it with simple AppleScript commands:<\/p>\n<p><b>Add an item<\/b>:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">osascript -e 'tell application &quot;System Events&quot; to make login item at end with properties {path:&quot;\/path\/to\/itemname&quot;, hidden:false}'<\/div><\/div>\n<p><b>Remove an item<\/b>:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">osascript -e 'tell application &quot;System Events&quot; to delete login item &quot;itemname&quot;'<\/div><\/div>\n<p><b>List all items<\/b>:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">osascript -e 'tell application &quot;System Events&quot; to get the name of every login item'<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>There is a way to use the\u00a0defaults\u00a0command-line tool to add items to the\u00a0Login Items\u00a0list of the\u00a0Accounts\u00a0or\u00a0Users &amp; Groups\u00a0System Preference panel: defaults write [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1523","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1523"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1523\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}