Merge pull request #6 from toothbrush/autostart

Add instructions for auto-launch.
This commit is contained in:
Paul 2019-07-03 21:24:14 +10:00 committed by GitHub
commit cdbe6e8fda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 2 deletions

View File

@ -1,6 +1,9 @@
.PHONY: all
all: debounce all: debounce
debounce: debounce.m debounce: debounce.m
clang -fobjc-arc -framework Cocoa ./debounce.m -o $@ clang -fobjc-arc -framework Cocoa $^ -o $@
.PHONY: all .PHONY: install
install: debounce
cp $< /usr/local/bin

View File

@ -26,6 +26,50 @@ $ sudo ./debounce
It needs root because it intercepts keystrokes. It needs root because it intercepts keystrokes.
If you really want, you can "install" it. Assuming that
`/usr/local/bin` is in your `$PATH` (which it is if you use Homebrew)
you can:
```ShellSession
$ make install
```
### Auto-start at login
Another [helpful
contribution](https://github.com/toothbrush/debounce-mac/issues/2),
this time from @cpouldev. If you'd like to auto-start `debounce` at
login, you might find something like the [included LaunchAgent
configuration](./com.debounceMac.app.plist) helpful.
Put that somewhere `launchctl` can find it, like
`~/Library/LaunchAgents/com.debounceMac.app.plist`, then load the
configuration. macOS will automatically prompt you to give `debounce`
Accessibility access, this is needed to be able to intercept and
modify keystrokes.
```ShellSession
$ launchctl load ~/Library/LaunchAgents/com.debounceMac.app.plist
```
macOS will automatically prompt you to give `debounce` Accessibility
access, this is needed to be able to intercept and modify keystrokes.
When that's done, start it.
```ShellSession
$ launchctl start com.debounceMac.app
```
To remove / uninstall completely:
```ShellSession
$ launchctl stop com.debounceMac.app
$ launchctl unload ~/Library/LaunchAgents/com.debounceMac.app.plist
$ rm ~/Library/LaunchAgents/com.debounceMac.app.plist
$ launchctl list
$ rm /usr/local/bin/debounce
```
### Accessibility / permissions ### Accessibility / permissions
You might get an error something like the following, even when running You might get an error something like the following, even when running

24
com.debounceMac.app.plist Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin</string>
</dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<true/>
</dict>
<key>Label</key>
<string>com.debounceMac.app</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/debounce</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>