mirror of
https://github.com/sindresorhus/touch-bar-simulator
synced 2025-03-02 14:07:14 +00:00
Add ability to toggle it in the Services menu and with keyboard shortcut (#13)
This commit is contained in:
parent
eaca4e5de2
commit
88c5e92c2c
3 changed files with 28 additions and 3 deletions
|
@ -30,6 +30,22 @@
|
|||
<string>MIT License © Sindre Sorhus</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSServices</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSKeyEquivalent</key>
|
||||
<dict/>
|
||||
<key>NSMenuItem</key>
|
||||
<dict>
|
||||
<key>default</key>
|
||||
<string>Toggle Touch Bar</string>
|
||||
</dict>
|
||||
<key>NSMessage</key>
|
||||
<string>toggleView</string>
|
||||
<key>NSPortName</key>
|
||||
<string>Touch Bar Simulator</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>SUEnableAutomaticChecks</key>
|
||||
<true/>
|
||||
<key>SUFeedURL</key>
|
||||
|
|
|
@ -14,6 +14,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
|
|||
var toolbarView: NSView!
|
||||
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
NSApp.servicesProvider = self
|
||||
|
||||
_ = SUUpdater()
|
||||
|
||||
controller.window?.delegate = self
|
||||
|
@ -67,6 +69,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
|
|||
controller.window!.alphaValue = CGFloat(sender.doubleValue)
|
||||
UserDefaults.standard.set(sender.doubleValue, forKey: "windowTransparency")
|
||||
}
|
||||
|
||||
@objc func toggleView(_ pboard: NSPasteboard, userData: String, error: NSErrorPointer) {
|
||||
let a = controller.window!.isVisible
|
||||
controller.window!.setIsVisible(!a)
|
||||
}
|
||||
}
|
||||
|
||||
let app = NSApplication.shared()
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
> Use the Touch Bar on any Mac
|
||||
|
||||
Launch the Touch Bar simulator from anywhere without needing to have Xcode installed, whereas Apple requires you to launch it from inside Xcode. It also comes with a handy transparency slider and screenshot button.
|
||||
Launch the Touch Bar simulator from anywhere without needing to have Xcode installed, whereas Apple requires you to launch it from inside Xcode. It also comes with a handy transparency slider, a screenshot button, and a service to toggle the Touch Bar in the Services menu or with a keyboard shortcut.
|
||||
|
||||
You can add a shortcut in `System Preferences` → `Keyboard` → `Shortcuts` → `Services` → `Toggle Touch Bar`.
|
||||
|
||||
**[Discuss it on Product Hunt](https://www.producthunt.com/posts/touch-bar-simulator)**
|
||||
|
||||
|
@ -32,8 +34,8 @@ $ brew update && brew cask install touch-bar-simulator
|
|||
You can capture a screenshot of the Touch Bar by either:
|
||||
|
||||
1. Clicking the screenshot button in the Touch Bar window which saves it to `~/Desktop`.
|
||||
2. Pressing <kbd>Command</kbd> <kbd>Shift</kbd> <kbd>6</kbd> which saves it to `~/Desktop`.
|
||||
3. Pressing <kbd>Command</kbd> <kbd>Control</kbd> <kbd>Shift</kbd> <kbd>6</kbd> which saves it to the clipboard.
|
||||
2. Pressing ⇧⌘6 which saves it to `~/Desktop`.
|
||||
3. Pressing ⌃⇧⌘6 which saves it to the clipboard.
|
||||
|
||||
|
||||
## FAQ
|
||||
|
|
Loading…
Add table
Reference in a new issue