Skip to content

Commit ac62394

Browse files
committed
Auto-reenable login item after upgrade
1 parent d73d6c6 commit ac62394

File tree

7 files changed

+43
-7
lines changed

7 files changed

+43
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ The active development builds are produced on macOS 15 (Sequoia) and officially
8585

8686
### Upgrading
8787

88-
Each DMG bundles an `Upgrade SlowQuitApps.app` helper. Double-click it to stop the running helper, copy the bundled build into `/Applications` (macOS may prompt for your password), and relaunch SlowQuitApps so you can re-enable auto-start. You can still upgrade manually by disabling SlowQuitAppsLauncher under System Settings → General → Login Items, quitting the app, dragging the new `.app` into `/Applications`, and turning the login item back on afterward.
88+
Each DMG bundles an `Upgrade SlowQuitApps.app` helper. Double-click it to stop the running helper, copy the bundled build into `/Applications` (macOS may prompt for your password), and relaunch SlowQuitApps with auto-start automatically re-enabled. You can still upgrade manually by disabling SlowQuitAppsLauncher under System Settings → General → Login Items, quitting the app, dragging the new `.app` into `/Applications`, and turning the login item back on afterward.
8989

9090
## Customization
9191

SlowQuitApps/SQAAppDelegate.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
4949
if ([SQAPreferences disableAutostart]) {
5050
[SQAAutostart disable];
5151
[dialogs informAutoStartDisabled];
52+
} else if ([SQAPreferences pendingAutoEnable]) {
53+
if (![SQAAutostart enable]) {
54+
[dialogs informLoginItemRegistrationFailure];
55+
}
5256
} else if (![SQAAutostart isEnabled]) {
5357
[dialogs askAboutAutoStart];
5458
}

SlowQuitApps/SQAAutostart.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import <Foundation/Foundation.h>
2+
#import "SQAPreferences.h"
23
@import ServiceManagement;
34
#import "SQAAutostart.h"
45

@@ -66,11 +67,20 @@ + (BOOL)shouldRegisterLoginItem:(BOOL)enabled {
6667

6768

6869
+ (BOOL)enable {
69-
return [self shouldRegisterLoginItem:YES];
70+
BOOL result = [self shouldRegisterLoginItem:YES];
71+
if (result) {
72+
[SQAPreferences setDisableAutostart:NO];
73+
[SQAPreferences setPendingAutoEnable:NO];
74+
}
75+
return result;
7076
}
7177

7278
+ (BOOL)disable {
73-
return [self shouldRegisterLoginItem:NO];
79+
BOOL result = [self shouldRegisterLoginItem:NO];
80+
if (result) {
81+
[SQAPreferences setDisableAutostart:YES];
82+
}
83+
return result;
7484
}
7585

7686
+ (BOOL)isRunningFromReadOnlyLocation {

SlowQuitApps/SQADialogs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- (void)informHotkeyRegistrationFailure;
77
- (void)informAccessibilityRequirement;
88
- (void)informMoveToApplicationsRequirement;
9+
- (void)informLoginItemRegistrationFailure;
910
- (void)informAutoStartDisabled;
1011
- (void)promptToReEnableAutoStart;
1112

SlowQuitApps/SQAPreferences.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
+ (BOOL)invertList;
88
+ (BOOL)displayOverlay;
99
+ (BOOL)disableAutostart;
10+
+ (void)setDisableAutostart:(BOOL)value;
11+
+ (BOOL)pendingAutoEnable;
12+
+ (void)setPendingAutoEnable:(BOOL)value;
1013

1114
@end

SlowQuitApps/SQAPreferences.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ + (NSUserDefaults *)defaults {
1111
@"whitelist": @[],
1212
@"invertList": @NO,
1313
@"displayOverlay": @YES,
14-
@"disableAutostart": @NO
14+
@"disableAutostart": @NO,
15+
@"pendingAutoEnable": @NO
1516
};
1617
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
1718
defaultsRegistered = YES;
@@ -58,4 +59,16 @@ + (BOOL)disableAutostart {
5859
return [[self defaults] boolForKey:@"disableAutostart"];
5960
}
6061

62+
+ (void)setDisableAutostart:(BOOL)value {
63+
[[self defaults] setBool:value forKey:@"disableAutostart"];
64+
}
65+
66+
+ (BOOL)pendingAutoEnable {
67+
return [[self defaults] boolForKey:@"pendingAutoEnable"];
68+
}
69+
70+
+ (void)setPendingAutoEnable:(BOOL)value {
71+
[[self defaults] setBool:value forKey:@"pendingAutoEnable"];
72+
}
73+
6174
@end

build-dmg.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ CONSOLE_UID=$(id -u "$CONSOLE_USER")
127127
echo "== SlowQuitApps Upgrade Assistant =="
128128
echo ""
129129
echo "Stopping running instances..."
130-
sudo -u "$CONSOLE_USER" defaults write com.dteoh.SlowQuitApps disableAutostart -bool YES >/dev/null 2>&1 || true
131130
pkill -x SlowQuitApps >/dev/null 2>&1 || true
132131
pkill -x SlowQuitAppsLauncher >/dev/null 2>&1 || true
133132
launchctl bootout gui/${CONSOLE_UID}/com.dteoh.SlowQuitAppsLauncher >/dev/null 2>&1 || true
@@ -137,12 +136,18 @@ echo "Copying new version to /Applications (password might be required)..."
137136
rm -rf "$DST_PATH"
138137
ditto "$SRC_PATH" "$DST_PATH"
139138
139+
echo ""
140+
echo "Requesting auto-start re-enable on next launch..."
141+
sudo -u "$CONSOLE_USER" defaults delete com.dteoh.SlowQuitApps disableAutostart >/dev/null 2>&1 || true
142+
sudo -u "$CONSOLE_USER" defaults write com.dteoh.SlowQuitApps disableAutostart -bool NO >/dev/null 2>&1
143+
sudo -u "$CONSOLE_USER" defaults write com.dteoh.SlowQuitApps pendingAutoEnable -bool YES >/dev/null 2>&1
144+
140145
echo ""
141146
echo "Relaunching SlowQuitApps..."
142147
sudo -u "$CONSOLE_USER" open "$DST_PATH"
143148
144149
echo ""
145-
echo "Upgrade complete. You can re-enable auto-start from SlowQuitApps if needed."
150+
echo "Upgrade complete. Auto-start will be re-enabled automatically on next launch."
146151
SCRIPT
147152
chmod +x "${UPGRADE_APP}/Contents/Resources/upgrade-helper.sh"
148153

@@ -156,7 +161,7 @@ Install:
156161
2. Launch the app, grant Accessibility permissions, and enable auto-start if desired.
157162
158163
Upgrade:
159-
1. Double-click "Upgrade SlowQuitApps.app". It stops running helpers, copies this build into /Applications (macOS may prompt for your password), and relaunches the updated app.
164+
1. Double-click "Upgrade SlowQuitApps.app". It stops running helpers, copies this build into /Applications (macOS may prompt for your password), and relaunches the updated app with auto-start queued to re-enable automatically.
160165
2. Alternatively, disable SlowQuitAppsLauncher in System Settings → General → Login Items, quit SlowQuitApps, replace the .app manually, then re-enable auto-start.
161166
DOC
162167

0 commit comments

Comments
 (0)