This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.squareLength) | |
if let button = statusItem.button { | |
button.image = NSImage(named:NSImage.Name("ic_dock")) | |
button.action = #selector(doWhatYouWantToDo(_:)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func toggleDock2(show: Bool) -> Bool { | |
return show ? NSApp.setActivationPolicy(.regular) : NSApp.setActivationPolicy(.accessory) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The following activation policies control whether and how an application may be activated. They are determined by the Info.plist. */ | |
public enum ActivationPolicy : Int { | |
/* The application is an ordinary app that appears in the Dock and may have a user interface. This is the default for bundled apps, unless overridden in the Info.plist. */ | |
case regular | |
/* The application does not appear in the Dock and does not have a menu bar, but it may be activated programmatically or by clicking on one of its windows. This corresponds to LSUIElement=1 in the Info.plist. */ | |
case accessory | |
/* The application does not appear in the Dock and may not create windows or be activated. This corresponds to LSBackgroundOnly=1 in the Info.plist. This is also the default for unbundled executables that do not have Info.plists. */ | |
case prohibited | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Attempts to modify the application's activation policy. In OS X 10.9, any policy may be set; prior to 10.9, the activation policy may be changed to NSApplicationActivationPolicyProhibited or NSApplicationActivationPolicyRegular, but may not be changed to NSApplicationActivationPolicyAccessory. This returns YES if setting the activation policy is successful, and NO if not. | |
*/ | |
@available(OSX 10.6, *) | |
open func setActivationPolicy(_ activationPolicy: NSApplication.ActivationPolicy) -> Bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<key>LSUIElement</key> | |
<true/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func toggleDock(show: Bool) -> Bool { | |
// ProcessApplicationTransformState | |
let transformState = show ? | |
// show to foreground application | |
// or not show to background application | |
ProcessApplicationTransformState(kProcessTransformToForegroundApplication) | |
: ProcessApplicationTransformState(kProcessTransformToUIElementApplication) | |
// transform current application type. | |
var psn = ProcessSerialNumber(highLongOfPSN: 0, lowLongOfPSN: UInt32(kCurrentProcess)) | |
return TransformProcessType(&psn, transformState) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* TransformProcessType() | |
* | |
* Summary: | |
* Changes the 'type' of the process specified in the psn parameter. | |
* The type is specified in the transformState parameter. | |
* | |
* Discussion: | |
* Given a psn for an application, this call transforms that | |
* application into the given type. Foreground applications have a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if os(macOS) | |
import Cocoa | |
import RxSwift | |
import RxCocoa | |
extension Reactive where Base: NSProgressIndicator { | |
/// Bindable sink for `loading` and property. | |
public var loading: Binder<Bool> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if os(macOS) | |
import Cocoa | |
/// Add loading property for NSProgressIndicator | |
extension NSProgressIndicator { | |
struct Holder { | |
static var _loading: Bool = false | |
static var _hideWhenAnimationStop: Bool = false | |
} |