Skip to content

Commit

Permalink
small fixes if XDG variables aren't set
Browse files Browse the repository at this point in the history
  • Loading branch information
0neGal committed Nov 9, 2022
1 parent 00e77e1 commit 7d52145
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions viper-sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/sh

VERSION="1.0.1"
VERSION="1.0.2"

CONFIGDIR="${XDG_CONFIG_HOME:-$HOME/.config}"

ARGS="$@"
JSONPATH="$(jq -r .gamepath "$XDG_CONFIG_HOME/viper.json" 2> /dev/null)"
JSONPATH="$(jq -r .gamepath "$CONFIGDIR/viper.json" 2> /dev/null)"
GAMEPATH="${GAMEPATH:-$JSONPATH}"

LATESTJSON=""
Expand Down Expand Up @@ -107,16 +109,16 @@ EOF
ARG="$(echo $i | sed 's/--setpath=//')"

[ "$ARG" != "" ] && {
CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}"
CONFIG="$CONFIGDIR/viper.json"

[ -f "$CONFIG/viper.json" ] && {
JSON="$(jq ".gamepath = \"$ARG\"" "$CONFIG/viper.json")"
echo $JSON > "$CONFIG/viper.json"
[ -f "$CONFIG" ] && {
JSON="$(jq ".gamepath = \"$ARG\"" "$CONFIG")"
echo $JSON > "$CONFIG"
exit
}

JSON="$(echo "{\"gamepath\": \"$ARG\"}" | jq)"
echo $JSON > "$CONFIG/viper.json"
echo $JSON > "$CONFIG"

exit
}
Expand Down

0 comments on commit 7d52145

Please sign in to comment.