Skip to content

Commit 0e0f9f4

Browse files
authoredFeb 27, 2023
Add optional dock icon to appease app review (#1)
* Rename MouseHouse scheme to CenterMouse * Update README.md * Add optional dock icon * Small updates * Bump build number to 3 * Add link to App Store download
1 parent 3644036 commit 0e0f9f4

File tree

15 files changed

+212
-222
lines changed

15 files changed

+212
-222
lines changed
 

‎CenterMouse.xcodeproj/project.pbxproj

+46-57
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,45 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
4A0ED9452899B4EC00C64485 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A0ED9442899B4EC00C64485 /* Settings.swift */; };
1110
4A0ED9472899B95100C64485 /* LocalizedStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A0ED9462899B95000C64485 /* LocalizedStrings.swift */; };
1211
4A1A0716289629680023B5AE /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A1A0715289629680023B5AE /* EventMonitor.swift */; };
13-
4A2BD5192926CAF70085E372 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A2BD5182926CAF70085E372 /* Font.swift */; };
1412
4A88A6B32896290000F63365 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A88A6B22896290000F63365 /* AppDelegate.swift */; };
1513
4A88A6B52896290000F63365 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A88A6B42896290000F63365 /* Assets.xcassets */; };
1614
4A88A6B82896290000F63365 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4A88A6B62896290000F63365 /* MainMenu.xib */; };
1715
4AA764152896DC61000C6A49 /* MouseMover.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA764142896DC61000C6A49 /* MouseMover.swift */; };
1816
4AE9B9002896EDAB00F8100D /* KeyboardShortcuts in Frameworks */ = {isa = PBXBuildFile; productRef = 4AE9B8FF2896EDAB00F8100D /* KeyboardShortcuts */; };
19-
4AE9B9062896EDD600F8100D /* Defaults in Frameworks */ = {isa = PBXBuildFile; productRef = 4AE9B9052896EDD600F8100D /* Defaults */; };
20-
4AE9B9092896EDE700F8100D /* Preferences in Frameworks */ = {isa = PBXBuildFile; productRef = 4AE9B9082896EDE700F8100D /* Preferences */; };
21-
4AF0685F2905CD2F0088F8A9 /* GeneralPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AF0685E2905CD2F0088F8A9 /* GeneralPreferencesView.swift */; };
2217
4AFDEE16292E8B9C00936A96 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AFDEE15292E8B9C00936A96 /* Extensions.swift */; };
18+
5B56C0E729AB8642006A17BB /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B56C0E629AB8642006A17BB /* SettingsView.swift */; };
19+
5B714B2529AC11E0002B04F3 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B714B2429AC11E0002B04F3 /* Font.swift */; };
20+
5B714B2729AC1BF4002B04F3 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B714B2629AC1BF4002B04F3 /* Settings.swift */; };
21+
5B714B2A29AC1D58002B04F3 /* LaunchAtLogin in Frameworks */ = {isa = PBXBuildFile; productRef = 5B714B2929AC1D58002B04F3 /* LaunchAtLogin */; };
22+
5BE460B029AC0EF600D1D0E9 /* Defaults in Frameworks */ = {isa = PBXBuildFile; productRef = 5BE460AF29AC0EF600D1D0E9 /* Defaults */; };
2323
/* End PBXBuildFile section */
2424

2525
/* Begin PBXFileReference section */
26-
4A0ED9442899B4EC00C64485 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
2726
4A0ED9462899B95000C64485 /* LocalizedStrings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedStrings.swift; sourceTree = "<group>"; };
2827
4A16F142292E858700FE994A /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
2928
4A1A0715289629680023B5AE /* EventMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventMonitor.swift; sourceTree = "<group>"; };
30-
4A2BD5182926CAF70085E372 /* Font.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
3129
4A88A6AF2896290000F63365 /* CenterMouse.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CenterMouse.app; sourceTree = BUILT_PRODUCTS_DIR; };
3230
4A88A6B22896290000F63365 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3331
4A88A6B42896290000F63365 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
3432
4A88A6B72896290000F63365 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
3533
4A88A6B92896290000F63365 /* CenterMouse.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = CenterMouse.entitlements; sourceTree = "<group>"; };
3634
4AA764142896DC61000C6A49 /* MouseMover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MouseMover.swift; sourceTree = "<group>"; };
37-
4AF0685E2905CD2F0088F8A9 /* GeneralPreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralPreferencesView.swift; sourceTree = "<group>"; };
3835
4AFDEE15292E8B9C00936A96 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
36+
5B56C0E629AB8642006A17BB /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
37+
5B714B2429AC11E0002B04F3 /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
38+
5B714B2629AC1BF4002B04F3 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
39+
5BC6600429ACFB820078B87A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3940
/* End PBXFileReference section */
4041

4142
/* Begin PBXFrameworksBuildPhase section */
4243
4A88A6AC2896290000F63365 /* Frameworks */ = {
4344
isa = PBXFrameworksBuildPhase;
4445
buildActionMask = 2147483647;
4546
files = (
46-
4AE9B9062896EDD600F8100D /* Defaults in Frameworks */,
47-
4AE9B9092896EDE700F8100D /* Preferences in Frameworks */,
47+
5B714B2A29AC1D58002B04F3 /* LaunchAtLogin in Frameworks */,
48+
5BE460B029AC0EF600D1D0E9 /* Defaults in Frameworks */,
4849
4AE9B9002896EDAB00F8100D /* KeyboardShortcuts in Frameworks */,
4950
);
5051
runOnlyForDeploymentPostprocessing = 0;
@@ -60,6 +61,7 @@
6061
4A88A6B02896290000F63365 /* Products */,
6162
);
6263
sourceTree = "<group>";
64+
usesTabs = 1;
6365
};
6466
4A88A6B02896290000F63365 /* Products */ = {
6567
isa = PBXGroup;
@@ -81,36 +83,29 @@
8183
4AA764162896DCDC000C6A49 /* Resources */ = {
8284
isa = PBXGroup;
8385
children = (
86+
5BC6600429ACFB820078B87A /* Info.plist */,
8487
4A88A6B42896290000F63365 /* Assets.xcassets */,
8588
4A88A6B62896290000F63365 /* MainMenu.xib */,
89+
4A88A6B92896290000F63365 /* CenterMouse.entitlements */,
8690
);
8791
path = Resources;
8892
sourceTree = "<group>";
8993
};
9094
4AA764172896DCDF000C6A49 /* Sources */ = {
9195
isa = PBXGroup;
9296
children = (
93-
4AF0685D2905CD1D0088F8A9 /* Preferences */,
9497
4A88A6B22896290000F63365 /* AppDelegate.swift */,
95-
4A0ED9462899B95000C64485 /* LocalizedStrings.swift */,
96-
4AFDEE15292E8B9C00936A96 /* Extensions.swift */,
97-
4A2BD5182926CAF70085E372 /* Font.swift */,
98+
5B714B2629AC1BF4002B04F3 /* Settings.swift */,
99+
5B56C0E629AB8642006A17BB /* SettingsView.swift */,
98100
4A1A0715289629680023B5AE /* EventMonitor.swift */,
99101
4AA764142896DC61000C6A49 /* MouseMover.swift */,
100-
4A88A6B92896290000F63365 /* CenterMouse.entitlements */,
102+
4AFDEE15292E8B9C00936A96 /* Extensions.swift */,
103+
5B714B2429AC11E0002B04F3 /* Font.swift */,
104+
4A0ED9462899B95000C64485 /* LocalizedStrings.swift */,
101105
);
102106
path = Sources;
103107
sourceTree = "<group>";
104108
};
105-
4AF0685D2905CD1D0088F8A9 /* Preferences */ = {
106-
isa = PBXGroup;
107-
children = (
108-
4A0ED9442899B4EC00C64485 /* Settings.swift */,
109-
4AF0685E2905CD2F0088F8A9 /* GeneralPreferencesView.swift */,
110-
);
111-
path = Preferences;
112-
sourceTree = "<group>";
113-
};
114109
/* End PBXGroup section */
115110

116111
/* Begin PBXNativeTarget section */
@@ -130,8 +125,8 @@
130125
name = CenterMouse;
131126
packageProductDependencies = (
132127
4AE9B8FF2896EDAB00F8100D /* KeyboardShortcuts */,
133-
4AE9B9052896EDD600F8100D /* Defaults */,
134-
4AE9B9082896EDE700F8100D /* Preferences */,
128+
5BE460AF29AC0EF600D1D0E9 /* Defaults */,
129+
5B714B2929AC1D58002B04F3 /* LaunchAtLogin */,
135130
);
136131
productName = CenterMouse;
137132
productReference = 4A88A6AF2896290000F63365 /* CenterMouse.app */;
@@ -163,8 +158,8 @@
163158
mainGroup = 4A88A6A62896290000F63365;
164159
packageReferences = (
165160
4AE9B8FE2896EDAB00F8100D /* XCRemoteSwiftPackageReference "KeyboardShortcuts" */,
166-
4AE9B9042896EDD600F8100D /* XCRemoteSwiftPackageReference "Defaults" */,
167-
4AE9B9072896EDE700F8100D /* XCRemoteSwiftPackageReference "Preferences" */,
161+
5BE460AE29AC0EF600D1D0E9 /* XCRemoteSwiftPackageReference "Defaults" */,
162+
5B714B2829AC1D58002B04F3 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */,
168163
);
169164
productRefGroup = 4A88A6B02896290000F63365 /* Products */;
170165
projectDirPath = "";
@@ -217,12 +212,12 @@
217212
files = (
218213
4AA764152896DC61000C6A49 /* MouseMover.swift in Sources */,
219214
4A88A6B32896290000F63365 /* AppDelegate.swift in Sources */,
220-
4A2BD5192926CAF70085E372 /* Font.swift in Sources */,
215+
5B714B2729AC1BF4002B04F3 /* Settings.swift in Sources */,
221216
4AFDEE16292E8B9C00936A96 /* Extensions.swift in Sources */,
217+
5B714B2529AC11E0002B04F3 /* Font.swift in Sources */,
218+
5B56C0E729AB8642006A17BB /* SettingsView.swift in Sources */,
222219
4A1A0716289629680023B5AE /* EventMonitor.swift in Sources */,
223220
4A0ED9472899B95100C64485 /* LocalizedStrings.swift in Sources */,
224-
4AF0685F2905CD2F0088F8A9 /* GeneralPreferencesView.swift in Sources */,
225-
4A0ED9452899B4EC00C64485 /* Settings.swift in Sources */,
226221
);
227222
runOnlyForDeploymentPostprocessing = 0;
228223
};
@@ -291,7 +286,7 @@
291286
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
292287
GCC_WARN_UNUSED_FUNCTION = YES;
293288
GCC_WARN_UNUSED_VARIABLE = YES;
294-
MACOSX_DEPLOYMENT_TARGET = 12.5;
289+
MACOSX_DEPLOYMENT_TARGET = 13.0;
295290
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
296291
MTL_FAST_MATH = YES;
297292
ONLY_ACTIVE_ARCH = YES;
@@ -346,7 +341,7 @@
346341
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
347342
GCC_WARN_UNUSED_FUNCTION = YES;
348343
GCC_WARN_UNUSED_VARIABLE = YES;
349-
MACOSX_DEPLOYMENT_TARGET = 12.5;
344+
MACOSX_DEPLOYMENT_TARGET = 13.0;
350345
MTL_ENABLE_DEBUG_INFO = NO;
351346
MTL_FAST_MATH = YES;
352347
SDKROOT = macosx;
@@ -359,26 +354,23 @@
359354
isa = XCBuildConfiguration;
360355
buildSettings = {
361356
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
362-
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
363-
CODE_SIGN_ENTITLEMENTS = CenterMouse/Sources/CenterMouse.entitlements;
357+
CODE_SIGN_ENTITLEMENTS = CenterMouse/Resources/CenterMouse.entitlements;
364358
CODE_SIGN_IDENTITY = "-";
365359
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
366360
CODE_SIGN_STYLE = Automatic;
367-
COMBINE_HIDPI_IMAGES = YES;
368-
CURRENT_PROJECT_VERSION = 1;
361+
CURRENT_PROJECT_VERSION = 3;
369362
DEAD_CODE_STRIPPING = YES;
370363
DEVELOPMENT_TEAM = F2J52QJQ9Y;
371364
ENABLE_HARDENED_RUNTIME = YES;
372365
GENERATE_INFOPLIST_FILE = YES;
366+
INFOPLIST_FILE = CenterMouse/Resources/Info.plist;
373367
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
374-
INFOPLIST_KEY_LSUIElement = YES;
375368
INFOPLIST_KEY_NSMainNibFile = MainMenu;
376369
INFOPLIST_KEY_NSPrincipalClass = NSApplication;
377370
LD_RUNPATH_SEARCH_PATHS = (
378371
"$(inherited)",
379372
"@executable_path/../Frameworks",
380373
);
381-
MACOSX_DEPLOYMENT_TARGET = 11.0;
382374
MARKETING_VERSION = 1.0.0;
383375
PRODUCT_BUNDLE_IDENTIFIER = software.level.CenterMouse;
384376
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -391,26 +383,23 @@
391383
isa = XCBuildConfiguration;
392384
buildSettings = {
393385
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
394-
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
395-
CODE_SIGN_ENTITLEMENTS = CenterMouse/Sources/CenterMouse.entitlements;
386+
CODE_SIGN_ENTITLEMENTS = CenterMouse/Resources/CenterMouse.entitlements;
396387
CODE_SIGN_IDENTITY = "-";
397388
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
398389
CODE_SIGN_STYLE = Automatic;
399-
COMBINE_HIDPI_IMAGES = YES;
400-
CURRENT_PROJECT_VERSION = 1;
390+
CURRENT_PROJECT_VERSION = 3;
401391
DEAD_CODE_STRIPPING = YES;
402392
DEVELOPMENT_TEAM = F2J52QJQ9Y;
403393
ENABLE_HARDENED_RUNTIME = YES;
404394
GENERATE_INFOPLIST_FILE = YES;
395+
INFOPLIST_FILE = CenterMouse/Resources/Info.plist;
405396
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
406-
INFOPLIST_KEY_LSUIElement = YES;
407397
INFOPLIST_KEY_NSMainNibFile = MainMenu;
408398
INFOPLIST_KEY_NSPrincipalClass = NSApplication;
409399
LD_RUNPATH_SEARCH_PATHS = (
410400
"$(inherited)",
411401
"@executable_path/../Frameworks",
412402
);
413-
MACOSX_DEPLOYMENT_TARGET = 11.0;
414403
MARKETING_VERSION = 1.0.0;
415404
PRODUCT_BUNDLE_IDENTIFIER = software.level.CenterMouse;
416405
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -451,20 +440,20 @@
451440
minimumVersion = 1.7.1;
452441
};
453442
};
454-
4AE9B9042896EDD600F8100D /* XCRemoteSwiftPackageReference "Defaults" */ = {
443+
5B714B2829AC1D58002B04F3 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */ = {
455444
isa = XCRemoteSwiftPackageReference;
456-
repositoryURL = "https://github.com/sindresorhus/Defaults";
445+
repositoryURL = "https://github.com/sindresorhus/LaunchAtLogin-Modern";
457446
requirement = {
458447
kind = upToNextMajorVersion;
459-
minimumVersion = 6.3.0;
448+
minimumVersion = 1.0.0;
460449
};
461450
};
462-
4AE9B9072896EDE700F8100D /* XCRemoteSwiftPackageReference "Preferences" */ = {
451+
5BE460AE29AC0EF600D1D0E9 /* XCRemoteSwiftPackageReference "Defaults" */ = {
463452
isa = XCRemoteSwiftPackageReference;
464-
repositoryURL = "https://github.com/sindresorhus/Preferences";
453+
repositoryURL = "https://github.com/sindresorhus/Defaults";
465454
requirement = {
466455
kind = upToNextMajorVersion;
467-
minimumVersion = 2.6.0;
456+
minimumVersion = 7.1.0;
468457
};
469458
};
470459
/* End XCRemoteSwiftPackageReference section */
@@ -475,15 +464,15 @@
475464
package = 4AE9B8FE2896EDAB00F8100D /* XCRemoteSwiftPackageReference "KeyboardShortcuts" */;
476465
productName = KeyboardShortcuts;
477466
};
478-
4AE9B9052896EDD600F8100D /* Defaults */ = {
467+
5B714B2929AC1D58002B04F3 /* LaunchAtLogin */ = {
479468
isa = XCSwiftPackageProductDependency;
480-
package = 4AE9B9042896EDD600F8100D /* XCRemoteSwiftPackageReference "Defaults" */;
481-
productName = Defaults;
469+
package = 5B714B2829AC1D58002B04F3 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */;
470+
productName = LaunchAtLogin;
482471
};
483-
4AE9B9082896EDE700F8100D /* Preferences */ = {
472+
5BE460AF29AC0EF600D1D0E9 /* Defaults */ = {
484473
isa = XCSwiftPackageProductDependency;
485-
package = 4AE9B9072896EDE700F8100D /* XCRemoteSwiftPackageReference "Preferences" */;
486-
productName = Preferences;
474+
package = 5BE460AE29AC0EF600D1D0E9 /* XCRemoteSwiftPackageReference "Defaults" */;
475+
productName = Defaults;
487476
};
488477
/* End XCSwiftPackageProductDependency section */
489478
};

‎CenterMouse.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
"kind" : "remoteSourceControl",
66
"location" : "https://github.com/sindresorhus/Defaults",
77
"state" : {
8-
"revision" : "981ccb0a01c54abbe3c12ccb8226108527bbf115",
9-
"version" : "6.3.0"
8+
"revision" : "d71bfd8ffbf944ef08eacbca5fb96d6f69bf7696",
9+
"version" : "7.1.0"
1010
}
1111
},
1212
{
1313
"identity" : "keyboardshortcuts",
1414
"kind" : "remoteSourceControl",
1515
"location" : "https://github.com/sindresorhus/KeyboardShortcuts",
1616
"state" : {
17-
"revision" : "aa50ffb413ce83a443a8c08eb20c76c226e9bce6",
18-
"version" : "1.9.0"
17+
"revision" : "8c90a95cb9f94d5c26182cb7d447c54ba5416984",
18+
"version" : "1.9.4"
1919
}
2020
},
2121
{
22-
"identity" : "preferences",
22+
"identity" : "launchatlogin-modern",
2323
"kind" : "remoteSourceControl",
24-
"location" : "https://github.com/sindresorhus/Preferences",
24+
"location" : "https://github.com/sindresorhus/LaunchAtLogin-Modern",
2525
"state" : {
26-
"revision" : "2651cd144615009242c994b087508fef99e9275c",
27-
"version" : "2.6.0"
26+
"revision" : "638e6c426b8d113eae255baeba59ed2d9d9a7c4d",
27+
"version" : "1.0.0"
2828
}
2929
}
3030
],

‎CenterMouse/Resources/Assets.xcassets/AccentColor.colorset/Contents.json

-38
This file was deleted.

‎CenterMouse/Resources/Base.lproj/MainMenu.xib

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
</connections>
2727
</menuItem>
2828
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
29-
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
29+
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW">
30+
<connections>
31+
<action selector="settingsMenuItemActivated:" target="Voe-Tx-rLC" id="tkS-Yd-Rwx"/>
32+
</connections>
33+
</menuItem>
3034
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
3135
<menuItem title="Services" id="NMo-om-nkz">
3236
<modifierMask key="keyEquivalentModifierMask"/>

‎CenterMouse/Sources/CenterMouse.entitlements ‎CenterMouse/Resources/CenterMouse.entitlements

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>com.apple.security.app-sandbox</key>
6-
<true/>
7-
<key>com.apple.security.files.user-selected.read-only</key>
8-
<true/>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
97
</dict>
108
</plist>

‎CenterMouse/Resources/Info.plist

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>ITSAppUsesNonExemptEncryption</key>
6+
<false/>
7+
</dict>
8+
</plist>

‎CenterMouse/Sources/AppDelegate.swift

+38-24
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,56 @@
11
import AppKit
22
import Defaults
3-
import Preferences
43
import SwiftUI
54

65
@main
7-
class AppDelegate: NSObject, NSApplicationDelegate {
6+
final class AppDelegate: NSObject, NSApplicationDelegate {
87

9-
var window: NSWindow?
10-
var eventMonitor: EventMonitor?
8+
private var window: NSWindow!
9+
private var windowController: NSWindowController!
10+
11+
private var eventMonitor = EventMonitor()
1112

1213
func applicationDidFinishLaunching(_ notification: Notification) {
13-
eventMonitor = EventMonitor()
14-
openPreferencesWindow()
14+
window = NSWindow(
15+
contentRect: NSZeroRect,
16+
styleMask: [.closable, .titled],
17+
backing: .buffered,
18+
defer: true
19+
)
20+
21+
window.title = "CenterMouse"
22+
window.contentView = NSHostingView(rootView: SettingsView())
23+
windowController = NSWindowController(window: window)
24+
25+
Settings.setActivationPolicy()
26+
27+
openSettingsWindow()
1528
}
1629

1730
func applicationDidBecomeActive(_ notification: Notification) {
18-
openPreferencesWindow()
31+
openSettingsWindow()
32+
}
33+
34+
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
35+
openSettingsWindow()
36+
return true
37+
}
38+
39+
@IBAction func settingsMenuItemActivated(_ sender: Any) {
40+
openSettingsWindow()
1941
}
2042

21-
private func openPreferencesWindow() {
43+
func openSettingsWindow() {
2244
// Works around an annoyance where the app always comes to the foreground when
2345
// being previewed in Xcode's SwiftUI Canvas.
24-
if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != "1" {
25-
preferencesWindowController.show()
46+
guard
47+
ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != "1"
48+
else {
49+
return
2650
}
27-
}
2851

29-
lazy var preferencesWindowController: PreferencesWindowController = {
30-
return PreferencesWindowController(panes: [
31-
Preferences.Pane(
32-
identifier: .general,
33-
title: "General",
34-
toolbarIcon: NSImage(
35-
systemSymbolName: "gearshape",
36-
accessibilityDescription: "General Preferences"
37-
)!,
38-
contentView: { GeneralPreferencesView() }
39-
)
40-
])
41-
}()
52+
windowController.window?.center()
53+
windowController.showWindow(self)
54+
NSApp.activate(ignoringOtherApps: true)
55+
}
4256
}

‎CenterMouse/Sources/EventMonitor.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Cocoa
22
import Combine
3+
import Defaults
34
import KeyboardShortcuts
45

56
final class EventMonitor {
@@ -26,9 +27,13 @@ final class EventMonitor {
2627
.sink(receiveValue: MouseMover.moveMouseToCenterOfMainScreen(_:))
2728
.store(in: &subscriptions)
2829

29-
KeyboardShortcuts.onKeyUp(for: .moveMouseToHouse) {
30+
KeyboardShortcuts.onKeyUp(for: .centerMousePointer) {
3031
MouseMover.moveMouseToCenterOfMainScreen()
3132
}
33+
34+
Defaults.publisher(.hideDockIcon)
35+
.sink { Settings.setActivationPolicy(hideDockIcon: $0.newValue) }
36+
.store(in: &subscriptions)
3237
}
3338

3439
deinit {

‎CenterMouse/Sources/MouseMover.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ final class MouseMover {
55
public static func moveMouseToCenterOfMainScreen(_ notification: Notification? = nil) {
66
if let notification {
77
print(notification.name)
8-
guard Defaults[.systemEventMonitoringEnabled] else {
9-
print("System event monitoring is disabled. Ignoring event.")
10-
return
11-
}
128
}
9+
10+
guard Defaults[.monitorSystemEvents] == true else {
11+
print("System event monitoring is disabled. Ignoring event.")
12+
return
13+
}
14+
1315
guard let mainScreen = NSScreen.main else { return }
1416
let centerOfMainScreen = CGPoint(x: mainScreen.frame.midX, y: mainScreen.frame.midY)
1517
let result = CGWarpMouseCursorPosition(centerOfMainScreen)

‎CenterMouse/Sources/Preferences/GeneralPreferencesView.swift

-65
This file was deleted.

‎CenterMouse/Sources/Preferences/Settings.swift

-20
This file was deleted.

‎CenterMouse/Sources/Settings.swift

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import AppKit
2+
import Defaults
3+
4+
extension Defaults.Keys {
5+
static let hideDockIcon = Key<Bool>("hideDockIcon", default: false)
6+
static let monitorSystemEvents = Key<Bool>("monitorSystemEvents", default: true)
7+
}
8+
9+
enum Settings {
10+
static func setActivationPolicy(hideDockIcon: Bool = Defaults[.hideDockIcon]) {
11+
NSApp.setActivationPolicy(hideDockIcon ? .accessory : .regular)
12+
NSApp.activate(ignoringOtherApps: true)
13+
}
14+
}
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import Defaults
2+
import KeyboardShortcuts
3+
import LaunchAtLogin
4+
import SwiftUI
5+
6+
extension KeyboardShortcuts.Name {
7+
static let centerMousePointer = Self("centerMousePointer")
8+
}
9+
10+
struct SettingsView: View {
11+
var body: some View {
12+
Form {
13+
LabeledContent("Behavior:") {
14+
LaunchAtLogin.Toggle()
15+
}
16+
Defaults.Toggle("Move mouse to center on system events", key: .monitorSystemEvents)
17+
Group {
18+
Text("System events include:")
19+
Text("\u{2022} Waking from sleep")
20+
Text("\u{2022} Locking the screen")
21+
Text("\u{2022} Unlocking the screen")
22+
Text("\u{2022} Exiting the screen saver")
23+
}.settingDescription()
24+
25+
LabeledContent("Keyboard Shortcut:") {
26+
KeyboardShortcuts.Recorder(for: .centerMousePointer)
27+
}
28+
Text("Define a global keyboard shortcut to move the mouse")
29+
.settingDescription()
30+
31+
LabeledContent("User Interface:") {
32+
Defaults.Toggle("Hide Dock icon", key: .hideDockIcon)
33+
}
34+
Text(#"When the Dock icon is hidden, CenterMouse will run in "headless" mode. You can safely close this window, and the app will continue to run in the background."#)
35+
.settingDescription()
36+
37+
VStack(alignment: .trailing) {
38+
HStack {
39+
Spacer()
40+
Button("About") {
41+
NSApp.orderFrontStandardAboutPanel(
42+
options: [
43+
.applicationIcon: NSWorkspace.shared.icon(forFile: Bundle.main.bundlePath),
44+
.credits: LocalizedStrings.credits
45+
]
46+
)
47+
}
48+
Button("Quit") {
49+
NSApp.terminate(nil)
50+
}
51+
}
52+
}
53+
}
54+
.frame(width: 480, height: 300)
55+
.padding([.leading, .trailing], 40)
56+
}
57+
}
58+
59+
struct SettingsView_Previews: PreviewProvider {
60+
static var previews: some View {
61+
SettingsView()
62+
}
63+
}
64+
65+
extension View {
66+
/// Applies font and color for a label used for describing a setting.
67+
public func settingDescription() -> some View {
68+
font(.system(size: 11.0))
69+
.foregroundStyle(.secondary)
70+
}
71+
}

‎README.md

+8
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
# CenterMouse
2+
3+
CenterMouse is a simple macOS utility app. It runs silently in the background, and responds to certain events — wake from sleep, exit screensaver, custom keyboard shortcut — by moving the mouse pointer to the center of your primary display.
4+
5+
This is helpful for those of us that have multiple monitors, making it easy and predictable to know where the mouse pointer will be when coming back to your computer.
6+
7+
CenterMouse is open source, and 100% free to download and use!
8+
9+
[Download the app from the Mac App Store](https://apps.apple.com/app/centermouse/id6444685140)

0 commit comments

Comments
 (0)
Please sign in to comment.