Skip to content

Commit 5b4fdee

Browse files
committed
Enable startup by default
1 parent a6c8e18 commit 5b4fdee

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/TrayAppContext.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ private NotifyIcon CreateNotifyIcon(IconType iconType, string tooltip, int index
4242
}
4343

4444
public TrayAppContext() {
45-
_launchOnStartup = IsStartupEnabled();
45+
_launchOnStartup = !StartupEntryExists() || IsStartupEnabled();
46+
4647

4748
_trayMenu = BuildContextMenu();
4849

@@ -159,6 +160,12 @@ private void RefreshIcons() {
159160
_trayIcons[1].Icon = IconManager.LoadIcon(_isPlaying ? IconType.Pause : IconType.Play);
160161
_trayIcons[2].Icon = IconManager.LoadIcon(IconType.Next);
161162
}
162-
163+
private bool StartupEntryExists() {
164+
try {
165+
using var runKey = Registry.CurrentUser.OpenSubKey(RegistryRunKey);
166+
return runKey?.GetValue(AppName) != null;
167+
}
168+
catch { return false; }
169+
}
163170
}
164171
}

0 commit comments

Comments
 (0)