diff --git a/DockPhobia.xcodeproj/project.pbxproj b/DockPhobia.xcodeproj/project.pbxproj index 93f390d..496eb33 100644 --- a/DockPhobia.xcodeproj/project.pbxproj +++ b/DockPhobia.xcodeproj/project.pbxproj @@ -7,18 +7,18 @@ objects = { /* Begin PBXBuildFile section */ + A94BEC0F2DE23E8500D4811D /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = A94BEC0E2DE23E8500D4811D /* MainMenu.xib */; }; A966B4F42DE0842500C721A5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A966B4EE2DE0842400C721A5 /* AppDelegate.swift */; }; A966B4F52DE0842500C721A5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A966B4EF2DE0842400C721A5 /* Assets.xcassets */; }; - A966B4F62DE0842500C721A5 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = A966B4F22DE0842400C721A5 /* MainMenu.xib */; }; A966B4F82DE0852900C721A5 /* MouseTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A966B4F72DE0852900C721A5 /* MouseTracker.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + A94BEC0E2DE23E8500D4811D /* MainMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; }; A966B4D62DE0841000C721A5 /* DockPhobia.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DockPhobia.app; sourceTree = BUILT_PRODUCTS_DIR; }; A966B4EE2DE0842400C721A5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; A966B4EF2DE0842400C721A5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; A966B4F02DE0842400C721A5 /* DockPhobia.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DockPhobia.entitlements; sourceTree = ""; }; - A966B4F12DE0842400C721A5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; A966B4F72DE0852900C721A5 /* MouseTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MouseTracker.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -33,6 +33,22 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + A94BEC0A2DE21F8100D4811D /* Resources */ = { + isa = PBXGroup; + children = ( + A966B4EF2DE0842400C721A5 /* Assets.xcassets */, + ); + path = Resources; + sourceTree = ""; + }; + A94BEC102DE23ECE00D4811D /* Views */ = { + isa = PBXGroup; + children = ( + A94BEC0E2DE23E8500D4811D /* MainMenu.xib */, + ); + path = Views; + sourceTree = ""; + }; A966B4CD2DE0841000C721A5 = { isa = PBXGroup; children = ( @@ -54,9 +70,9 @@ children = ( A966B4EE2DE0842400C721A5 /* AppDelegate.swift */, A966B4F72DE0852900C721A5 /* MouseTracker.swift */, - A966B4EF2DE0842400C721A5 /* Assets.xcassets */, + A94BEC102DE23ECE00D4811D /* Views */, + A94BEC0A2DE21F8100D4811D /* Resources */, A966B4F02DE0842400C721A5 /* DockPhobia.entitlements */, - A966B4F22DE0842400C721A5 /* MainMenu.xib */, ); path = DockPhobia; sourceTree = ""; @@ -122,8 +138,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + A94BEC0F2DE23E8500D4811D /* MainMenu.xib in Resources */, A966B4F52DE0842500C721A5 /* Assets.xcassets in Resources */, - A966B4F62DE0842500C721A5 /* MainMenu.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -141,18 +157,6 @@ }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXVariantGroup section */ - A966B4F22DE0842400C721A5 /* MainMenu.xib */ = { - isa = PBXVariantGroup; - children = ( - A966B4F12DE0842400C721A5 /* Base */, - ); - name = MainMenu.xib; - sourceTree = ""; - usesTabs = 1; - }; -/* End PBXVariantGroup section */ - /* Begin XCBuildConfiguration section */ A966B4E12DE0841200C721A5 /* Debug */ = { isa = XCBuildConfiguration; @@ -287,10 +291,12 @@ ENABLE_HARDENED_RUNTIME = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_LSUIElement = YES; INFOPLIST_KEY_NSAppleEventsUsageDescription = _; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - INFOPLIST_KEY_NSMainNibFile = MainMenu; + INFOPLIST_KEY_NSMainNibFile = ""; INFOPLIST_KEY_NSPrincipalClass = NSApplication; + INFOPLIST_KEY_UIUserInterfaceStyle = Automatic; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", @@ -318,10 +324,12 @@ ENABLE_HARDENED_RUNTIME = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_LSUIElement = YES; INFOPLIST_KEY_NSAppleEventsUsageDescription = _; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - INFOPLIST_KEY_NSMainNibFile = MainMenu; + INFOPLIST_KEY_NSMainNibFile = ""; INFOPLIST_KEY_NSPrincipalClass = NSApplication; + INFOPLIST_KEY_UIUserInterfaceStyle = Automatic; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", diff --git a/DockPhobia/.DS_Store b/DockPhobia/.DS_Store index 7bfbe45..3f002f3 100644 Binary files a/DockPhobia/.DS_Store and b/DockPhobia/.DS_Store differ diff --git a/DockPhobia/AppDelegate.swift b/DockPhobia/AppDelegate.swift index 4de612c..d42c1c1 100644 --- a/DockPhobia/AppDelegate.swift +++ b/DockPhobia/AppDelegate.swift @@ -11,20 +11,17 @@ import AppKit @main class AppDelegate: NSObject, NSApplicationDelegate { - @IBOutlet var window: NSWindow! + public var statusItem: NSStatusItem! - @IBAction func startStopButton(_ sender: Any) { - if mouseTracker.monitor != nil { - mouseTracker.addMonitor() - } else { - mouseTracker.removeMonitor() - } - } var mouseTracker = MouseTracker() func applicationDidFinishLaunching(_ aNotification: Notification) { - // Insert code here to initialize your application + statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) + if let button = statusItem.button { + button.image = NSImage(named: "cursor") + } + setupMenus() } func applicationWillTerminate(_ aNotification: Notification) { @@ -34,4 +31,29 @@ class AppDelegate: NSObject, NSApplicationDelegate { func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { return true } + + func setupMenus() { + let menu = NSMenu() + let one = NSMenuItem(title: "hi", action: #selector(didTapStart), keyEquivalent: "s s") + menu.addItem(one) + + menu.addItem(NSMenuItem.separator()) + statusItem.menu = menu + } + + func changeMenuIcon(running: Bool) { + if let button = statusItem.button { + button.image = NSImage(named: "cursor\(running ? ".motion" : "")") + } + } + + @objc func didTapStart() { + if mouseTracker.running { + mouseTracker.removeMonitor() + changeMenuIcon(running: false) + } else { + mouseTracker.addMonitor() + changeMenuIcon(running: true) + } + } } diff --git a/DockPhobia/MouseTracker.swift b/DockPhobia/MouseTracker.swift index ee4fa34..47dd2a0 100644 --- a/DockPhobia/MouseTracker.swift +++ b/DockPhobia/MouseTracker.swift @@ -24,7 +24,9 @@ enum DockSide { class MouseTracker { var screen: Screen - var monitor: NSEvent? + var monitor: Any? + + var running: Bool = false init() { if let screen = NSScreen.main { @@ -37,8 +39,8 @@ class MouseTracker { } else { fatalError("no screen wtf???") } - addMonitor() moveDock(.left) + moveDock(.bottom) } func checkMouse(_ event: NSEvent) { @@ -53,11 +55,18 @@ class MouseTracker { } func addMonitor() { - self.monitor = NSEvent.addGlobalMonitorForEvents(matching: .mouseMoved, handler: checkMouse) as? NSEvent + self.monitor = NSEvent.addGlobalMonitorForEvents(matching: .mouseMoved, handler: checkMouse) + self.running = true + print("started tracking") } func removeMonitor() { - NSEvent.removeMonitor(monitor as Any) + if let monitor = monitor { + NSEvent.removeMonitor(monitor) + self.running = false + } + + print("stop tracking") } func moveDock(_ toSide: DockSide) { diff --git a/DockPhobia/Assets.xcassets/AccentColor.colorset/Contents.json b/DockPhobia/Resources/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from DockPhobia/Assets.xcassets/AccentColor.colorset/Contents.json rename to DockPhobia/Resources/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/DockPhobia/Assets.xcassets/AppIcon.appiconset/Contents.json b/DockPhobia/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from DockPhobia/Assets.xcassets/AppIcon.appiconset/Contents.json rename to DockPhobia/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/DockPhobia/Assets.xcassets/AppIcon.appiconset/DockPhobiaAppIcon 2.png b/DockPhobia/Resources/Assets.xcassets/AppIcon.appiconset/DockPhobiaAppIcon 2.png similarity index 100% rename from DockPhobia/Assets.xcassets/AppIcon.appiconset/DockPhobiaAppIcon 2.png rename to DockPhobia/Resources/Assets.xcassets/AppIcon.appiconset/DockPhobiaAppIcon 2.png diff --git a/DockPhobia/Assets.xcassets/Contents.json b/DockPhobia/Resources/Assets.xcassets/Contents.json similarity index 100% rename from DockPhobia/Assets.xcassets/Contents.json rename to DockPhobia/Resources/Assets.xcassets/Contents.json diff --git a/DockPhobia/Resources/Assets.xcassets/cursor.motion.symbolset/Contents.json b/DockPhobia/Resources/Assets.xcassets/cursor.motion.symbolset/Contents.json new file mode 100644 index 0000000..9dad9d4 --- /dev/null +++ b/DockPhobia/Resources/Assets.xcassets/cursor.motion.symbolset/Contents.json @@ -0,0 +1,12 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "symbols" : [ + { + "filename" : "cursorarrow.motionlines.svg", + "idiom" : "universal" + } + ] +} diff --git a/DockPhobia/Resources/Assets.xcassets/cursor.motion.symbolset/cursorarrow.motionlines.svg b/DockPhobia/Resources/Assets.xcassets/cursor.motion.symbolset/cursorarrow.motionlines.svg new file mode 100644 index 0000000..dc3ea82 --- /dev/null +++ b/DockPhobia/Resources/Assets.xcassets/cursor.motion.symbolset/cursorarrow.motionlines.svg @@ -0,0 +1,133 @@ + + + + + + + + + + Weight/Scale Variations + Ultralight + Thin + Light + Regular + Medium + Semibold + Bold + Heavy + Black + + + + + + + + + + + Design Variations + Symbols are supported in up to nine weights and three scales. + For optimal layout with text and other symbols, vertically align + symbols with the adjacent text. + + + + + + Margins + Leading and trailing margins on the left and right side of each symbol + can be adjusted by modifying the x-location of the margin guidelines. + Modifications are automatically applied proportionally to all + scales and weights. + + + + Exporting + Symbols should be outlined when exporting to ensure the + design is preserved when submitting to Xcode. + Template v.6.0 + Requires Xcode 16 or greater + Generated from cursorarrow.motionlines + Typeset at 100.0 points + Small + Medium + Large + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DockPhobia/Resources/Assets.xcassets/cursor.slash.symbolset/Contents.json b/DockPhobia/Resources/Assets.xcassets/cursor.slash.symbolset/Contents.json new file mode 100644 index 0000000..16e7fce --- /dev/null +++ b/DockPhobia/Resources/Assets.xcassets/cursor.slash.symbolset/Contents.json @@ -0,0 +1,12 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "symbols" : [ + { + "filename" : "cursorarrow.slash.svg", + "idiom" : "universal" + } + ] +} diff --git a/DockPhobia/Resources/Assets.xcassets/cursor.slash.symbolset/cursorarrow.slash.svg b/DockPhobia/Resources/Assets.xcassets/cursor.slash.symbolset/cursorarrow.slash.svg new file mode 100644 index 0000000..c1ad9fa --- /dev/null +++ b/DockPhobia/Resources/Assets.xcassets/cursor.slash.symbolset/cursorarrow.slash.svg @@ -0,0 +1,113 @@ + + + + + + + + + + Weight/Scale Variations + Ultralight + Thin + Light + Regular + Medium + Semibold + Bold + Heavy + Black + + + + + + + + + + + Design Variations + Symbols are supported in up to nine weights and three scales. + For optimal layout with text and other symbols, vertically align + symbols with the adjacent text. + + + + + + Margins + Leading and trailing margins on the left and right side of each symbol + can be adjusted by modifying the x-location of the margin guidelines. + Modifications are automatically applied proportionally to all + scales and weights. + + + + Exporting + Symbols should be outlined when exporting to ensure the + design is preserved when submitting to Xcode. + Template v.6.0 + Requires Xcode 16 or greater + Generated from cursorarrow.slash + Typeset at 100.0 points + Small + Medium + Large + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DockPhobia/Resources/Assets.xcassets/cursor.symbolset/Contents.json b/DockPhobia/Resources/Assets.xcassets/cursor.symbolset/Contents.json new file mode 100644 index 0000000..c114830 --- /dev/null +++ b/DockPhobia/Resources/Assets.xcassets/cursor.symbolset/Contents.json @@ -0,0 +1,12 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "symbols" : [ + { + "filename" : "cursorarrow.svg", + "idiom" : "universal" + } + ] +} diff --git a/DockPhobia/Resources/Assets.xcassets/cursor.symbolset/cursorarrow.svg b/DockPhobia/Resources/Assets.xcassets/cursor.symbolset/cursorarrow.svg new file mode 100644 index 0000000..54f7287 --- /dev/null +++ b/DockPhobia/Resources/Assets.xcassets/cursor.symbolset/cursorarrow.svg @@ -0,0 +1,103 @@ + + + + + + + + + + Weight/Scale Variations + Ultralight + Thin + Light + Regular + Medium + Semibold + Bold + Heavy + Black + + + + + + + + + + + Design Variations + Symbols are supported in up to nine weights and three scales. + For optimal layout with text and other symbols, vertically align + symbols with the adjacent text. + + + + + + Margins + Leading and trailing margins on the left and right side of each symbol + can be adjusted by modifying the x-location of the margin guidelines. + Modifications are automatically applied proportionally to all + scales and weights. + + + + Exporting + Symbols should be outlined when exporting to ensure the + design is preserved when submitting to Xcode. + Template v.6.0 + Requires Xcode 16 or greater + Generated from cursorarrow + Typeset at 100.0 points + Small + Medium + Large + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DockPhobia/Base.lproj/MainMenu.xib b/DockPhobia/Views/MainMenu.xib similarity index 86% rename from DockPhobia/Base.lproj/MainMenu.xib rename to DockPhobia/Views/MainMenu.xib index a4bc9a6..7b74c7d 100644 --- a/DockPhobia/Base.lproj/MainMenu.xib +++ b/DockPhobia/Views/MainMenu.xib @@ -3,7 +3,6 @@ - @@ -13,11 +12,7 @@ - - - - - + @@ -419,57 +414,19 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - -