mb-setvar - utility to set/change config variables

master
Daniel Napora 2020-09-05 15:28:11 +02:00
parent 7149da49fb
commit 21b54444d5
2 changed files with 29 additions and 1 deletions

27
bin/mb-setvar 100755
View File

@ -0,0 +1,27 @@
#!/bin/bash
# mb-setvar: utility to set/change config variables
# Copyright (C) 2020 napcok <napcok@gmail.com>
if [[ $# < 1 ]]; then
self=$(basename $0)
echo "Usage: $self variable=value [/PATH/TO/CONFIG_FILE]"
exit 2
fi
if [[ $1 != *"="* ]]; then
self=$(basename $0)
echo "$self: First argument must be variable=value"
exit 2
fi
FILE=${2:-$HOME/.config/mabox/mabox.conf}
search=$(echo $1|cut -d= -f1)
if grep -Rq $search $FILE
then #found
sed -i s/^"$search=".*$/"$1"/ $FILE
else #not found
echo $1 >> $FILE
fi

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
# # mcc: Mabox Control Center
# Copyright (C) 2019 napcok <napcok@gmail.com>
# #
EDITOR=geany EDITOR=geany
case $LANG in case $LANG in