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
+12 -2
View File
@@ -7,6 +7,7 @@ import (
"encoding/json"
"log"
"sort"
"path/filepath"
)
type CmdGroup struct {
@@ -39,10 +40,19 @@ func main() {
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 err error
if *configFlag != "" {
commands, err = loadCommands(*configFlag)