3 Commits
8 changed files with 15 additions and 13 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ GO ?= $(shell which go)
build:
mkdir -p build
cd src/; $(GO) build -ldflags "-w" -o ../build/typer
cd src/; $(GO) build -ldflags "-w -X 'main.sysconfdir=$(SYSCONFDIR)'" -o ../build/typer
install: build/typer
# Create directories
@@ -24,4 +24,4 @@ uninstall:
clean:
rm -r build/
.PHONY: build
.PHONY: build
+2 -2
View File
@@ -20,5 +20,5 @@ make
```
- Run the following command **with superuser privileges** to install Typer to your system
```shell
make install SYSCONFDIR=/etc
```
make install
```
+1 -1
View File
@@ -134,7 +134,7 @@ func (buffer *Buffer) Save() error {
}
// Append new line character at end of buffer contents if not present
if buffer.Contents[len(buffer.Contents)-1] != '\n' {
if buffer.Contents == "" || buffer.Contents[len(buffer.Contents)-1] != '\n' {
buffer.Contents += "\n"
}
+2 -2
View File
@@ -44,8 +44,8 @@ func readConfig() {
if err != nil {
log.Fatalf("Could not unmarshal config.yml: %s", err)
}
} else if _, err := os.Stat("/etc/typer/config.yml"); err == nil {
reader, err := os.Open("/etc/typer/config.yml")
} else if _, err := os.Stat(path.Join(sysconfdir, "typer/config.yml")); err == nil {
reader, err := os.Open(path.Join(sysconfdir, "typer/config.yml"))
if err != nil {
log.Fatalf("Could not read config.yml: %s", err)
}
+1 -1
View File
@@ -18,7 +18,7 @@ func RequestInput(window *Window, text string, defaultInput string) chan string
request := &TyperInputRequest{
Text: text,
input: defaultInput,
cursorPos: 0,
cursorPos: len(defaultInput),
inputChannel: make(chan string),
}
+2 -2
View File
@@ -40,8 +40,8 @@ func readKeybindings() {
if err != nil {
log.Fatalf("Could not unmarshal keybindings.yml: %s", err)
}
} else if _, err := os.Stat("/etc/typer/keybindings.yml"); err == nil {
reader, err := os.Open("/etc/typer/keybindings.yml")
} else if _, err := os.Stat(path.Join(sysconfdir, "typer/keybindings.yml")); err == nil {
reader, err := os.Open(path.Join(sysconfdir, "typer/keybindings.yml"))
if err != nil {
log.Fatalf("Could not read keybindings.yml: %s", err)
}
+2
View File
@@ -5,6 +5,8 @@ import (
"os"
)
var sysconfdir = "/etc/"
func main() {
// Read config
readConfig()
+3 -3
View File
@@ -94,14 +94,14 @@ func readStyles() {
}
}
}
if stat, err := os.Stat("/etc/typer/styles/"); err == nil && stat.IsDir() {
entries, err := os.ReadDir("/etc/typer/styles/")
if stat, err := os.Stat(path.Join(sysconfdir, "typer/styles/")); err == nil && stat.IsDir() {
entries, err := os.ReadDir(path.Join(sysconfdir, "typer/styles/"))
if err != nil {
log.Fatalf("Could not read user style directory: %s", err)
}
for _, entry := range entries {
entryPath := path.Join("/etc/typer/styles/", entry.Name())
entryPath := path.Join(path.Join(sysconfdir, "typer/styles/"), entry.Name())
style, err := readStyleYamlFile(entryPath)
if err != nil {
log.Fatalf("Could not read style file (%s): %s", entryPath, err)