Its taking some kicking around, but here is the fruit of my labour… using core foundation over the RC bridge.
require 'osx/cocoa'
loginItems = OSX::CFPreferencesCopyValue(
"AutoLaunchedApplicationDictionary",
"loginwindow",
OSX::KCFPreferencesCurrentUser,
OSX::KCFPreferencesAnyHost)
application_path = File.expand_path("~/path/to/your.app")
application_hidden = false
loginItems << OSX::NSDictionary.dictionaryWithObjects_forKeys(
[ application_path, application_hidden ],
[ <img src='http://blog.getintheloop.eu/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ath, :Hide ])
# puts loginItems
OSX::CFPreferencesSetValue(
"AutoLaunchedApplicationDictionary",
loginItems,
"loginwindow",
OSX::KCFPreferencesCurrentUser,
OSX::KCFPreferencesAnyHost)
OSX::CFPreferencesSynchronize("loginwindow",
OSX::KCFPreferencesCurrentUser,
OSX::KCFPreferencesAnyHost)
With any luck this might help someone
Tags: Mac OSX

