added mouse tracking, jank ui, and an amazing icon

This commit is contained in:
neon443
2025-03-13 20:30:49 +00:00
parent a6aad44e8a
commit 9f60a4e124
17 changed files with 162 additions and 27 deletions

View File

@@ -23,6 +23,19 @@
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
A98E7EA02D836FBB0004DA00 /* Embed XPC Services */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "$(CONTENTS_FOLDER_PATH)/XPCServices";
dstSubfolderSpec = 16;
files = (
);
name = "Embed XPC Services";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
A91E849D2D82CF4100FC2E5F /* DockPhobia.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DockPhobia.app; sourceTree = BUILT_PRODUCTS_DIR; };
A91E84AE2D82CF4300FC2E5F /* DockPhobiaTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DockPhobiaTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -102,6 +115,7 @@
A91E84992D82CF4100FC2E5F /* Sources */,
A91E849A2D82CF4100FC2E5F /* Frameworks */,
A91E849B2D82CF4100FC2E5F /* Resources */,
A98E7EA02D836FBB0004DA00 /* Embed XPC Services */,
);
buildRules = (
);
@@ -392,6 +406,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = DockPhobia/DockPhobia.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
@@ -401,7 +416,7 @@
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_LSUIElement = NO;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@@ -420,6 +435,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = DockPhobia/DockPhobia.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
@@ -429,7 +445,7 @@
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_LSUIElement = NO;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",

View File

@@ -9,6 +9,11 @@
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>DockPhobiaHelper.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
</dict>
</plist>

View File

@@ -1,51 +1,61 @@
{
"images" : [
{
"filename" : "DockPhobiaAppIcon 16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "DockPhobiaAppIcon 33.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "DockPhobiaAppIcon 32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "DockPhobiaAppIcon 64.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "DockPhobiaAppIcon 128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "DockPhobiaAppIcon 256.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "DockPhobiaAppIcon 257.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "DockPhobiaAppIcon 512.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "DockPhobiaAppIcon 513.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "DockPhobiaAppIcon 1024.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -8,13 +8,24 @@
import SwiftUI
struct ContentView: View {
@Binding var enabled: Bool
@State var mouseloc = NSEvent.mouseLocation
var body: some View {
VStack {
Text("\(NSEvent.mouseLocation)")
Toggle("on", isOn: $enabled)
.toggleStyle(SwitchToggleStyle())
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
Spacer()
Button("df") {
startTrackingMouse()
}
Button("undf") {
stopTrackingMouse()
}
Button() {
NSApp.terminate(nil)
} label: {
@@ -26,5 +37,5 @@ struct ContentView: View {
}
#Preview {
ContentView()
ContentView(enabled: .constant(true))
}

View File

@@ -5,34 +5,122 @@
// Created by neon443 on 13/03/2025.
//
import Foundation
import SwiftUI
import Cocoa
import CoreGraphics
//@main
//struct DockPhobiaApp: App {
// @State var enabled: Bool = true
// var body: some Scene {
// WindowGroup {
// ContentView(enabled: $enabled)
// }
// MenuBarExtra(
// "Menu Bar",
// systemImage: "cursorarrow\(enabled ? "" : ".slash")"
// ) {
//
// Button("One") {
// enabled.toggle()
// }
// .keyboardShortcut("1")
//// ContentView(enabled: $enabled)
//// .frame(width: 300, height: 200)
// }
// .menuBarExtraStyle(.window)
// }
//// NSEvent.addGlobalMonitorForEvents(matching: [.mouseMoved]) { event in
//// print("event:", event)
//// }
//
//}
////struct DockPhobiaApp: App {
//// var body: some Scene {
//// WindowGroup {
//// ContentView()
//// }
//// }
////}
import Foundation
func moveDock() {
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/osascript")
if let scriptPath = Bundle.main.path(forResource: "/Users/neon443/Documents/Xcode/DockPhobia/DockPhobia/script.scpt", ofType: "scpt") {
process.arguments = [scriptPath]
do {
try process.run()
process.waitUntilExit()
} catch {
print("error")
}
} else {
print("error script not found")
}
}
@main
struct DockPhobiaApp: App {
enum DockPosition: String {
case left
case right
case bottom
}
@State var enabled: Bool = true
var body: some Scene {
MenuBarExtra(
"Menu Bar",
systemImage: "star"
) {
ContentView()
.overlay(alignment: .topLeading) {
Button() {
NSApp.terminate(nil)
} label: {
Image(systemName: "xmark.circle.fill")
.foregroundStyle(.blue)
WindowGroup {
ContentView(enabled: $enabled)
}
.buttonStyle(PlainButtonStyle())
MenuBarExtra("Dock Phobia", systemImage: "cursorarrow\(enabled ? "" : ".slash")") {
Toggle(enabled ? "Enabled" : "Disabled", isOn: $enabled)
Divider()
Button("Right") {
moveDock()
}
.frame(width: 300, height: 180)
Button("Quit") {
NSApplication.shared.terminate(nil)
}
.menuBarExtraStyle(.window)
.keyboardShortcut("q")
}
}
}
// global event tap
var eventTap: CFMachPort?
func startTrackingMouse() {
let mask = CGEventMask(1 << CGEventType.mouseMoved.rawValue)
//try creating event tap
eventTap = CGEvent.tapCreate(
tap: .cgSessionEventTap,
place: .headInsertEventTap,
options: CGEventTapOptions.defaultTap,
eventsOfInterest: mask,
callback: { (proxy, type, event, userInfo) -> Unmanaged<CGEvent>? in
let location = event.location
print("mouse at \(location)")
//TODO: add Dock moving here
return Unmanaged.passRetained(event)
},
userInfo: nil
)
//event tap started checking
if let eventTap = eventTap {
let runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0)
CFRunLoopAddSource(CFRunLoopGetMain(), runLoopSource, .commonModes)
CGEvent.tapEnable(tap: eventTap, enable: true)
print(" mouse tracking started!")
} else {
print(" failed to create event tap.")
}
}
//struct DockPhobiaApp: App {
// var body: some Scene {
// WindowGroup {
// ContentView()
// }
// }
//}

5
DockPhobia/script.scpt Normal file
View File

@@ -0,0 +1,5 @@
tell application "System Events"
tell dock preferences
set screen edge to right
end tell
end tell

View File

Binary file not shown.