Skip to content

Commit

Permalink
Start using goreleaser. Update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed May 24, 2021
1 parent 851eab6 commit b1b4832
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 168 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
autocorrector
autocorrector-server.service

dist/
58 changes: 58 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=1
goos:
- linux
goarch:
- amd64

nfpms:
- id: github.com/joshuar/autocorrector
package_name: autocorrector
replacements:
amd64: 64-bit
linux: Tux
vendor: joshuar
homepage: https://github.com/joshuar/autocorrector
maintainer: Joshua Rich <[email protected]>
description: Autocorrector is a tool similar to Autokey or AutoHotKey, but targeted mainly at word replacements.
license: Apache 2.0
formats:
- deb
- rpm
dependencies:
- libappindicator-gtk3
contents:
- src: autocorrector-server.service
dst: /etc/systemd/system/autocorrector-server.service
- src: autocorrector-client.service
dst: /usr/local/share/autocorrector/autocorrector-client.service
- src: LICENSE
dst: /usr/local/share/autocorrector/LICENSE
- src: README.md
dst: /usr/local/share/autocorrector/README.md
- src: corrections.toml
dst: /usr/local/share/autocorrector/corrections.toml
archives:
- replacements:
linux: Linux
amd64: x86_64
files:
- LICENSE
- README.md
- corrections.toml
- autocorrector-client.service
- autocorrector-server.service
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ Icon taken from [here](https://pixabay.com/vectors/spellcheck-correct-typo-error

## Installation

1. Install [Mage](https://magefile.org/).

2. Run `mage build` to build the binary and to generate the systemd service files.

3. The program has a client-server model. The server runs as root (required to read devices from the kernel keyboard device) with `autocorrector --user <yourusername>`. The client runs as your user with `autocorrector client`. For convienience, there are two systemd service files you can use to start the client and server, which are generated with the build command above.
- Copy `autocorrector-server.service` to `/etc/systemd/system`, run `sudo systemctl daemon-reload && systemctl enable autocorrector-server && systemctl start autocorrector-server`.
- Copy `autocorrector-client.service` to `~/.config/systemd/user`, run `systemctl --user daemon-reload && systemctl enable autocorrector-client && systemctl start autocorrector-client`.


1. Download the latest release in an appropriate format.
2. Copy the files to the appropriate locations:
- `autocorrector-server.service` :arrow_forward: `/etc/systemd/system/autocorrector-server.service` (done automatically for deb/rpm packages)
- `autocorrector-client.service` :arrow_forward: `$HOME/.config/systemd/user/autocorrector-client.service`
- corrections.toml :arrow_forward: `$HOME/.config/autocorrector/corrections.toml`
3. Reload systemd and enable/start the services:
- `sudo systemctl daemon-reload && systemctl --user daemon-reload`
- `sudo systemctl enable autocorrector-server && sudo systemctl start autocorrector-server`
- `systemctl --user enable autocorrector-client && systemctl start autocorrector-client`
6 changes: 2 additions & 4 deletions autocorrector-client.service
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[Unit]
Description=Autocorrector Service
Requires=plasma-plasmashell.service
After=plasma-plasmashell.service
Description=Autocorrector Client

[Service]
Type=exec
RemainAfterExit=yes
ExecStart=%h/gocode/bin/autocorrector client --profile
ExecStart=/usr/local/bin/autocorrector client

[Install]
WantedBy=default.target
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ go 1.15
require (
github.com/adrg/xdg v0.3.3
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/davecgh/go-spew v1.1.1
github.com/fsnotify/fsnotify v1.4.9
github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28
github.com/getlantern/systray v1.1.0
github.com/joshuar/go-linuxkeyboard v0.0.0-20210426063733-47e494527ba1
github.com/magefile/mage v1.11.0 // indirect
github.com/magefile/mage v1.11.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.7.1
Expand Down
133 changes: 0 additions & 133 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion internal/control/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func NewSocket(username string) *Socket {
}
addr, err := net.ResolveUnixAddr("unixpacket", SocketPath)
checkFatal(err)
log.Debug("Creating socket and waiting for client connection...")
listener := listenOnSocket(addr, username)
conn := acceptOnSocket(listener)
s := &Socket{
Expand Down Expand Up @@ -112,7 +113,7 @@ func (s *Socket) recvEncrypted() {
var packet Packet
gobDec := gob.NewDecoder(s.Conn)
if err := gobDec.Decode(&packet); err != nil {
log.Errorf("Read error: %s", err)
log.Fatalf("Read error: %s", err)
}
var nonce [24]byte
copy(nonce[:], packet.EncryptedData[:24])
Expand Down
3 changes: 2 additions & 1 deletion internal/keytracker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func (kt *KeyTracker) Pause() error {

func (kt *KeyTracker) Resume() error {
log.Debug("Resuming keytracker...")
return kt.Start()
kt.paused = false
return nil
}

func (kt *KeyTracker) slurpWords() {
Expand Down
18 changes: 0 additions & 18 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"text/template"

"github.com/adrg/xdg"
"github.com/magefile/mage/sh"
)

Expand Down Expand Up @@ -37,20 +36,3 @@ func Build() error {
}
return nil
}

// Installs the binary and the systemd files
func Install() error {

systemdServerServiceFile := "/etc/systemd/system/autocorrector-server.service"
systemdClientServiceFile, err := xdg.ConfigFile("systemd/user/autocorrector-client.service")
if err != nil {
return err
}
if err := sh.Copy("autocorrector-server.service", systemdServerServiceFile); err != nil {
return err
}
if err := sh.Copy("autocorrector-client.service", systemdClientServiceFile); err != nil {
return err
}
return nil
}

0 comments on commit b1b4832

Please sign in to comment.