pallotron / yubiswitch

OSX status bar application to enable/disable Yubikey Nano
Other
877 stars 65 forks source link

Feature request: support enable/disable from the cli #7

Closed mhorowitz closed 10 years ago

mhorowitz commented 10 years ago

This way, I can write a wrapper around ssh which enables the key so I don't need to mess with the menu. This could be done with an applescript hook, and some sample osascript invocations somewhere.

pallotron commented 10 years ago

One way to solve this temporarily until I code something is using a stupid apple script to send the global hotkey, like this:

$ cat ~/bin/yubiswitch-toggle
tell application "System Events"
    keystroke "y" using {command down, option down}
end tell
[Exit code 0 @ 11:42:39]

assuming you are using command-option-y it toggles the yubikey status off and on.

Long term solution is to have the application expose am XPC service that enables callers to toggle key on and off, then write a CLI Object-C tool that can call the service. It's explained here:

https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingXPCServices.html

mhorowitz commented 10 years ago

Writing a standalone cli tool seems awfully heavyweight. Why not just provide a scripting hook? I'd look up stuff in the docs, but developer.apple.com seems to be 404ing for everything right now.

pallotron commented 10 years ago

i'm pretty n00b with objective-c, yubiswitch was basically the occasion to start learning something about it. i'll look more at the developer site.

pallotron commented 10 years ago

I found this:

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_intro/SAppsIntro.html

Who Should Read This Document

This document is intended for developers who want to make their Cocoa applications scriptable or > who need to know more about how Cocoa applications interact with AppleScript and Apple events."

pallotron commented 10 years ago

I'll release a new binary shortly.

pallotron commented 10 years ago

Done, download it at https://github.com/pallotron/yubiswitch/releases/tag/v0.5 Let me know if it works well for you :)