Changed install to be in userspace and no root is required

This commit is contained in:
2025-11-07 23:14:25 +01:00
parent 4ab9fab20b
commit 5b39640ec1
2 changed files with 14 additions and 4 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
EXECUTABLE = cheatsh EXECUTABLE = cheatsh
PACKAGES = ./src/. PACKAGES = ./src/.
BINDIR = bin BINDIR = bin
SYSCONFDIR = /etc/cheatsh SYSCONFDIR = $(HOME)/.config/cheatsh
PREFIX ?= /usr/local PREFIX ?= $(HOME)/.local
all: build all: build
+12 -2
View File
@@ -7,6 +7,7 @@ import (
"encoding/json" "encoding/json"
"log" "log"
"sort" "sort"
"path/filepath"
) )
type CmdGroup struct { type CmdGroup struct {
@@ -39,10 +40,19 @@ func main() {
flag.Parse() flag.Parse()
configFile := "/etc/cheatsh/commands.json" var configFile string
home, err := os.UserHomeDir()
if err == nil {
userConf := filepath.Join(home, ".config", "cheatsh")
if info, err := os.Stat(userConf); err == nil && info.IsDir() {
configFile = filepath.Join(userConf, "commands.json")
} else {
configFile = "/etc/cheatsh/commands.json"
}
}
var commands CmdList var commands CmdList
var err error
if *configFlag != "" { if *configFlag != "" {
commands, err = loadCommands(*configFlag) commands, err = loadCommands(*configFlag)