Skip to content

Commit

Permalink
feat: Closes #47 - Add auto start on login
Browse files Browse the repository at this point in the history
  • Loading branch information
othyn committed Oct 29, 2022
1 parent baefcc9 commit 40e3326
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 69 deletions.
41 changes: 37 additions & 4 deletions auto-clicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
B510763727FF81A000BB1CDA /* PressKeyListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = B510763627FF81A000BB1CDA /* PressKeyListener.swift */; };
B510763B2800DDFF00BB1CDA /* NSEvent+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B510763A2800DDFF00BB1CDA /* NSEvent+Extensions.swift */; };
B5107640280113DB00BB1CDA /* Input.swift in Sources */ = {isa = PBXBuildFile; fileRef = B510763F280113DB00BB1CDA /* Input.swift */; };
B52C0507290D689600ECB0EE /* LaunchAtLogin in Frameworks */ = {isa = PBXBuildFile; productRef = B52C0506290D689600ECB0EE /* LaunchAtLogin */; };
B53027F5264C0D73002B8610 /* AutoClickSimulator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B53027F4264C0D73002B8610 /* AutoClickSimulator.swift */; };
B53027FA264C2748002B8610 /* DelayTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B53027F9264C2748002B8610 /* DelayTimer.swift */; };
B53BDC50264BED93001F8E57 /* AutoClickerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B53BDC4F264BED93001F8E57 /* AutoClickerApp.swift */; };
B53BDC54264BED95001F8E57 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B53BDC53264BED95001F8E57 /* Assets.xcassets */; };
B53BDC57264BED95001F8E57 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B53BDC56264BED95001F8E57 /* Preview Assets.xcassets */; };
B53BDC60264BF3A8001F8E57 /* NumberField.swift in Sources */ = {isa = PBXBuildFile; fileRef = B53BDC5F264BF3A8001F8E57 /* NumberField.swift */; };
B5B0B2AD2882DCCC00462F11 /* Zoop.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5B0B2AC2882DCCC00462F11 /* Zoop.swift */; };
B5B0B2AF2882EE6E00462F11 /* ACWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5B0B2AE2882EE6E00462F11 /* ACWindow.swift */; };
B5B6B46328032D3200C779FD /* PermissionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5B6B46228032D3200C779FD /* PermissionsView.swift */; };
B5B6B46528033A0F00C779FD /* PermissionsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5B6B46428033A0F00C779FD /* PermissionsService.swift */; };
Expand Down Expand Up @@ -99,7 +99,6 @@
B53BDC58264BED95001F8E57 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B53BDC59264BED95001F8E57 /* auto_clicker.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = auto_clicker.entitlements; sourceTree = "<group>"; };
B53BDC5F264BF3A8001F8E57 /* NumberField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberField.swift; sourceTree = "<group>"; };
B5B0B2AC2882DCCC00462F11 /* Zoop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Zoop.swift; sourceTree = "<group>"; };
B5B0B2AE2882EE6E00462F11 /* ACWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ACWindow.swift; sourceTree = "<group>"; };
B5B6B46228032D3200C779FD /* PermissionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PermissionsView.swift; sourceTree = "<group>"; };
B5B6B46428033A0F00C779FD /* PermissionsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PermissionsService.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -145,6 +144,7 @@
files = (
B510762827F4BD5500BB1CDA /* Defaults in Frameworks */,
B510760927F4A21500BB1CDA /* DateStrings in Frameworks */,
B52C0507290D689600ECB0EE /* LaunchAtLogin in Frameworks */,
B510760C27F4A23300BB1CDA /* KeyboardShortcuts in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -298,7 +298,6 @@
children = (
B53027F9264C2748002B8610 /* DelayTimer.swift */,
B53027F4264C0D73002B8610 /* AutoClickSimulator.swift */,
B5B0B2AC2882DCCC00462F11 /* Zoop.swift */,
);
path = "Observable Objects";
sourceTree = "<group>";
Expand Down Expand Up @@ -407,6 +406,7 @@
B53BDC48264BED93001F8E57 /* Sources */,
B53BDC49264BED93001F8E57 /* Frameworks */,
B53BDC4A264BED93001F8E57 /* Resources */,
B52C0508290D68ED00ECB0EE /* Copy “Launch at Login Helper” */,
B5FEAF342811D25B0099AAA7 /* Increment Build */,
B510762E27F4E72500BB1CDA /* Run Swiftlint */,
B5B6B466280345A700C779FD /* Reset Accessibility Permissions */,
Expand All @@ -420,6 +420,7 @@
B510760827F4A21500BB1CDA /* DateStrings */,
B510760B27F4A23300BB1CDA /* KeyboardShortcuts */,
B510762727F4BD5500BB1CDA /* Defaults */,
B52C0506290D689600ECB0EE /* LaunchAtLogin */,
);
productName = "auto-clicker";
productReference = B53BDC4C264BED93001F8E57 /* Auto Clicker.app */;
Expand Down Expand Up @@ -452,6 +453,7 @@
B510760727F4A21500BB1CDA /* XCRemoteSwiftPackageReference "DateStrings" */,
B510760A27F4A23300BB1CDA /* XCRemoteSwiftPackageReference "KeyboardShortcuts" */,
B510762627F4BD5500BB1CDA /* XCRemoteSwiftPackageReference "Defaults" */,
B52C0505290D689600ECB0EE /* XCRemoteSwiftPackageReference "LaunchAtLogin" */,
);
productRefGroup = B53BDC4D264BED93001F8E57 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -496,6 +498,25 @@
shellPath = /bin/sh;
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\n\nif which swiftlint > /dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download via: brew install swiftlint\"\nfi\n";
};
B52C0508290D68ED00ECB0EE /* Copy “Launch at Login Helper” */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Copy “Launch at Login Helper”";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# https://github.com/sindresorhus/LaunchAtLogin#swift-package-manager-1\n\"${BUILT_PRODUCTS_DIR}/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/copy-helper-swiftpm.sh\"\n";
};
B5B6B466280345A700C779FD /* Reset Accessibility Permissions */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down Expand Up @@ -592,7 +613,6 @@
B5F5C60B28039AA40049B04D /* FormState.swift in Sources */,
B510760F27F4A25400BB1CDA /* WindowStateService.swift in Sources */,
B5E92B1C27F1BA5E00A7FC63 /* ThemeService.swift in Sources */,
B5B0B2AD2882DCCC00462F11 /* Zoop.swift in Sources */,
C4345BB52846056000365CF9 /* ProcessInfo+Extensions.swift in Sources */,
B5E6395327CA62EB008B111A /* ThemedButtonStyle.swift in Sources */,
B510762127F4BB4900BB1CDA /* AppearanceSettingsTabView.swift in Sources */,
Expand Down Expand Up @@ -847,6 +867,14 @@
version = 6.2.1;
};
};
B52C0505290D689600ECB0EE /* XCRemoteSwiftPackageReference "LaunchAtLogin" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sindresorhus/LaunchAtLogin";
requirement = {
kind = exactVersion;
version = 4.2.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -865,6 +893,11 @@
package = B510762627F4BD5500BB1CDA /* XCRemoteSwiftPackageReference "Defaults" */;
productName = Defaults;
};
B52C0506290D689600ECB0EE /* LaunchAtLogin */ = {
isa = XCSwiftPackageProductDependency;
package = B52C0505290D689600ECB0EE /* XCRemoteSwiftPackageReference "LaunchAtLogin" */;
productName = LaunchAtLogin;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = B53BDC44264BED93001F8E57 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
"revision" : "0dcedd56994d871f243f3d9c76590bfd9f8aba69",
"version" : "1.5.0"
}
},
{
"identity" : "launchatlogin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sindresorhus/LaunchAtLogin",
"state" : {
"revision" : "e8171b3e38a2816f579f58f3dac1522aa39efe41",
"version" : "4.2.0"
}
}
],
"version" : 2
Expand Down
3 changes: 3 additions & 0 deletions auto-clicker/Localisation/en-GB.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"settings_general_app_should_quit_on_close" = "Quit app on main window close";
"settings_general_app_should_quit_on_close_help" = "When the main window of the application is closed, instead of keeping the app running in the background (macOS default behaviour), quit the app.";

"settings_general_launch_on_login" = "Launch app on macOS user login";
"settings_general_launch_on_login_help" = "When you login to your macOS account, automatically run Auto Clicker.";

"settings_general_menu_bar_show_icon_title" = "Menu Bar";
"settings_general_menu_bar_show_icon" = "Show menu bar icon";
"settings_general_menu_bar_show_icon_help" = "Always show an icon in the macOS menu bar where the app and quick access functionality can be accessed.";
Expand Down
47 changes: 0 additions & 47 deletions auto-clicker/Observable Objects/Zoop.swift

This file was deleted.

2 changes: 1 addition & 1 deletion auto-clicker/Views/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct SettingsView: View {
Label("settings_general", systemImage: "gear")
}
.onAppear {
self.changeFrameHeight(300)
self.changeFrameHeight(330)
}

KeyboardShortcutsSettingsTabView()
Expand Down
30 changes: 13 additions & 17 deletions auto-clicker/Views/Settings/Tabs/GeneralSettingsTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import Foundation
import SwiftUI
import Defaults
import LaunchAtLogin

struct GeneralSettingsTabView: View {
@StateObject private var zoop = Zoop()
@ObservedObject private var launchAtLogin = LaunchAtLogin.observable

@Default(.menuBarShowIcon) private var menuBarShowIcon
@Default(.appShouldQuitOnClose) private var appShouldQuitOnClose
Expand All @@ -19,15 +20,23 @@ struct GeneralSettingsTabView: View {
SettingsTabView {
SettingsTabItemView(
title: "settings_general_app_should_quit_on_close_title",
help: "settings_general_app_should_quit_on_close_help",
divider: true
help: "settings_general_app_should_quit_on_close_help"
) {
Defaults.Toggle(
" " + String(format: NSLocalizedString("settings_general_app_should_quit_on_close", comment: "App should quit on close toggle")),
key: .appShouldQuitOnClose
)
}

SettingsTabItemView(
help: "settings_general_launch_on_login_help",
divider: true
) {
Toggle(isOn: $launchAtLogin.isEnabled) {
Text(" " + String(format: NSLocalizedString("settings_general_launch_on_login", comment: "App should launch at login toggle")))
}
}

SettingsTabItemView(
title: "settings_general_menu_bar_show_icon_title",
help: "settings_general_menu_bar_show_icon_help"
Expand All @@ -53,8 +62,7 @@ struct GeneralSettingsTabView: View {
}

SettingsTabItemView(
help: "settings_general_menu_bar_hide_dock_help",
divider: true
help: "settings_general_menu_bar_hide_dock_help"
) {
Defaults.Toggle(
" " + String(format: NSLocalizedString("settings_general_menu_bar_hide_dock", comment: "Hide dock icon toggle")),
Expand All @@ -65,18 +73,6 @@ struct GeneralSettingsTabView: View {
}
.disabled(!self.menuBarShowIcon)
}

Spacer()

HStack {
Spacer()

Button(self.zoop.text, action: self.zoop.start)
.buttonStyle(.plain)
.font(.system(size: 28))

Spacer()
}
}
}
}
Expand Down

0 comments on commit 40e3326

Please sign in to comment.