mirror of
https://github.com/neon443/DockPhobia.git
synced 2026-03-11 06:49:12 +00:00
applescript, just need to allow system events
This commit is contained in:
@@ -2,9 +2,7 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-only</key>
|
||||
<key>com.apple.security.automation.apple-events</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -15,6 +15,12 @@ struct Screen {
|
||||
var height: CGFloat
|
||||
}
|
||||
|
||||
enum DockSide {
|
||||
case left
|
||||
case right
|
||||
case bottom
|
||||
}
|
||||
|
||||
class MouseTracker {
|
||||
var screen: Screen
|
||||
|
||||
@@ -32,6 +38,7 @@ class MouseTracker {
|
||||
fatalError("no screen wtf???")
|
||||
}
|
||||
addMonitor()
|
||||
moveDock(.left)
|
||||
}
|
||||
|
||||
func checkMouse(_ event: NSEvent) {
|
||||
@@ -40,6 +47,9 @@ class MouseTracker {
|
||||
#if DEBUG
|
||||
print(location)
|
||||
#endif
|
||||
if location.y > 1000 {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func addMonitor() {
|
||||
@@ -50,6 +60,17 @@ class MouseTracker {
|
||||
NSEvent.removeMonitor(monitor as Any)
|
||||
}
|
||||
|
||||
func moveDock(_ toSide: DockSide) {
|
||||
let script = """
|
||||
tell application "System Events"
|
||||
tell dock preferences
|
||||
set screen edge to \(toSide)
|
||||
end tell
|
||||
end tell
|
||||
"""
|
||||
applescript(script)
|
||||
}
|
||||
|
||||
func applescript(_ script: String) {
|
||||
var error: NSDictionary?
|
||||
if let scriptObject = NSAppleScript(source: script) {
|
||||
|
||||
Reference in New Issue
Block a user