Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix "Launch at login" #39

Merged
merged 1 commit into from

2 participants

@kainjow

See issue #38.

@ashchan
Owner

This is wonderful!

@ashchan ashchan merged commit b0275d0 into ashchan:master
@ashchan
Owner

@kainjow it doesn't seem to be working properly on one of my machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 20, 2012
  1. @kainjow
This page is out of date. Refresh to see the latest.
View
3  .gitmodules
@@ -1,3 +1,6 @@
[submodule "Libs/macruby-keychain-wrapper"]
path = Libs/macruby-keychain-wrapper
url = git://github.com/ashchan/macruby-keychain-wrapper.git
+[submodule "Libs/NSAppLoginItems"]
+ path = Libs/NSAppLoginItems
+ url = https://github.com/kainjow/NSAppLoginItems.git
View
53 Classes/GNStartItems.rb
@@ -9,63 +9,20 @@
class GNStartItems
def isSet
- cf = CFPreferencesCopyValue(
- "AutoLaunchedApplicationDictionary",
- "loginwindow",
- KCFPreferencesCurrentUser,
- KCFPreferencesAnyHost
- )
-
- return false unless cf
-
- cf.any? { |app| path == app["Path"] }
+ # isInLoginItems returns BOOL but apparently Ruby doesn't cast
+ # that to an internal boolean, so do it manually.
+ return NSApp.isInLoginItems == 1 ? true : false
end
def set(autoLaunch)
if autoLaunch != isSet
- cf = CFPreferencesCopyValue(
- "AutoLaunchedApplicationDictionary",
- "loginwindow",
- KCFPreferencesCurrentUser,
- KCFPreferencesAnyHost
- )
-
- if cf
- cf = cf.mutableCopy
- else
- cf = NSMutableArray.alloc.init
- end
-
if autoLaunch
#add
- #cf << { "Path" => path }
- cf.addObject(NSDictionary.dictionaryWithObject(path, forKey:"Path"))
+ NSApp.addToLoginItems
else
#remove
- to_remove = nil
- cf.each do |app|
- to_remove = app and break if app.valueForKey("Path") == path
- end
- cf.removeObject(to_remove) if to_remove
+ NSApp.removeFromLoginItems
end
-
- CFPreferencesSetValue(
- "AutoLaunchedApplicationDictionary",
- cf,
- "loginwindow",
- KCFPreferencesCurrentUser,
- KCFPreferencesAnyHost
- )
-
- CFPreferencesSynchronize(
- "loginwindow",
- KCFPreferencesCurrentUser,
- KCFPreferencesAnyHost
- )
end
end
-
- def path
- @path ||= NSBundle.mainBundle.bundlePath
- end
end
View
14 Gmail Notifr.xcodeproj/project.pbxproj
@@ -50,6 +50,7 @@
4DE3BE140D8651D900ECA448 /* MacRuby.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DE3BE130D8651D900ECA448 /* MacRuby.framework */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
+ A56634131633432300E4C57F /* NSApplication+LoginItems.m in Sources */ = {isa = PBXBuildFile; fileRef = A56634121633432300E4C57F /* NSApplication+LoginItems.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -145,6 +146,8 @@
4DE3BE130D8651D900ECA448 /* MacRuby.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MacRuby.framework; path = /Library/Frameworks/MacRuby.framework; sourceTree = "<absolute>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* Gmail Notifr.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Gmail Notifr.app"; sourceTree = BUILT_PRODUCTS_DIR; };
+ A56634111633432300E4C57F /* NSApplication+LoginItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSApplication+LoginItems.h"; path = "Libs/NSAppLoginItems/NSApplication+LoginItems.h"; sourceTree = "<group>"; };
+ A56634121633432300E4C57F /* NSApplication+LoginItems.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSApplication+LoginItems.m"; path = "Libs/NSAppLoginItems/NSApplication+LoginItems.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -214,6 +217,7 @@
1A7A949712D2091200F4D5F3 /* lib */ = {
isa = PBXGroup;
children = (
+ A56634141633433300E4C57F /* NSAppLoginItems */,
1A7A94F212D2097000F4D5F3 /* macruby-keychain-wrapper */,
);
name = lib;
@@ -322,6 +326,15 @@
name = Frameworks;
sourceTree = "<group>";
};
+ A56634141633433300E4C57F /* NSAppLoginItems */ = {
+ isa = PBXGroup;
+ children = (
+ A56634111633432300E4C57F /* NSApplication+LoginItems.h */,
+ A56634121633432300E4C57F /* NSApplication+LoginItems.m */,
+ );
+ name = NSAppLoginItems;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXLegacyTarget section */
@@ -448,6 +461,7 @@
buildActionMask = 2147483647;
files = (
8D11072D0486CEB800E47090 /* main.m in Sources */,
+ A56634131633432300E4C57F /* NSApplication+LoginItems.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1  Libs/NSAppLoginItems
@@ -0,0 +1 @@
+Subproject commit 2b3954e1da3addeb732aa72f6e310a760fa90d12
Something went wrong with that request. Please try again.