59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
from pathlib import Path
|
|
from datetime import datetime
|
|
import shutil
|
|
|
|
root = Path.cwd()
|
|
path = root / "OrionToolbar/OrionMenuView.swift"
|
|
|
|
source = path.read_text()
|
|
|
|
old = """ self.window = window
|
|
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
window.makeKeyAndOrderFront(nil)
|
|
window.orderFrontRegardless()
|
|
|
|
// Begin a non-blocking AppKit modal session."""
|
|
|
|
new = """ self.window = window
|
|
|
|
// MenuBarExtra uses a transient panel that can appear above
|
|
// ordinary floating windows. Dismiss it before showing Settings.
|
|
let dashboardWindows = NSApp.windows.filter {
|
|
$0 !== window &&
|
|
!$0.isSheet &&
|
|
($0 is NSPanel || $0.level.rawValue > NSWindow.Level.floating.rawValue)
|
|
}
|
|
|
|
for dashboard in dashboardWindows {
|
|
dashboard.orderOut(nil)
|
|
}
|
|
|
|
// Activate after dismissing the transient menu-bar panel.
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
window.makeKeyAndOrderFront(nil)
|
|
window.orderFrontRegardless()
|
|
|
|
// Begin a non-blocking AppKit modal session."""
|
|
|
|
if old not in source:
|
|
raise SystemExit(
|
|
"ERROR: Expected Settings window code not found. "
|
|
"No changes made."
|
|
)
|
|
|
|
backup = (
|
|
root / "backups"
|
|
/ datetime.now().strftime("%Y%m%d-%H%M%S-%f")
|
|
/ path.relative_to(root)
|
|
)
|
|
|
|
backup.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copy2(path, backup)
|
|
|
|
path.write_text(source.replace(old, new, 1))
|
|
|
|
print("UPDATED:", path)
|
|
print("BACKUP:", backup)
|
|
print("Settings foreground fix applied.")
|