Skip to content

Commit

Permalink
add NSDistributedNotificationCenter for better sketchybar support
Browse files Browse the repository at this point in the history
Co-authored-by: Nikita Bobko <[email protected]>

closes nikitabobko#76
closes nikitabobko#80
  • Loading branch information
MatthiasGrandl authored and nikitabobko committed Jan 1, 2024
1 parent e14b7d8 commit 3114978
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/command/WorkspaceCommand.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Common
import Foundation

struct WorkspaceCommand : Command {
let info: CmdStaticInfo = WorkspaceCmdArgs.info
Expand Down
8 changes: 6 additions & 2 deletions src/focused.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ private var _focusedWorkspaceName: String = focusedMonitorInaccurate?.activeWork
var focusedWorkspaceName: String { // todo change to focused monitor
get { _focusedWorkspaceName }
set {
if newValue != _focusedWorkspaceName {
let changed = newValue != _focusedWorkspaceName
_focusedWorkspaceName = newValue
if changed {
// Firing Notification for e.g Sketchybar Integration
DistributedNotificationCenter.default().postNotificationName(NSNotification.Name("bobko.aerospace.focusedWorkspaceChanged"), object: nil)

previousFocusedWorkspaceName = _focusedWorkspaceName
}
_focusedWorkspaceName = newValue
}
}
var previousFocusedWorkspaceName: String? = nil

0 comments on commit 3114978

Please sign in to comment.