settings: fix hidden options. grep -v -> grep -vx

pull/569/head
Botspot 5 years ago
parent 434ecea824
commit 9e80d92b54

@ -6,18 +6,16 @@ function error {
exit 1 exit 1
} }
exitloop='' #ensure settings dir exists
while [ -z $exitloop ];do if [ ! -d "${DIRECTORY}/data/settings" ];then
#ensure settings dir exists
if [ ! -d "${DIRECTORY}/data/settings" ];then
echo "creating settings directory" echo "creating settings directory"
mkdir -p "${DIRECTORY}/data/settings" mkdir -p "${DIRECTORY}/data/settings"
#create default files inside #create default files inside
echo '' > "${DIRECTORY}/data/settings/reinstall-after-update" echo '' > "${DIRECTORY}/data/settings/reinstall-after-update"
fi fi
#$1 is usually left blank. If it equals 'refresh', then empty settings will be created and then the script will exit. #$1 is usually left blank. If it equals 'refresh', then empty settings will be created and then the script will exit.
if [ "$1" == 'refresh' ];then if [ "$1" == 'refresh' ];then
#set default settings, if they don't exist #set default settings, if they don't exist
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')" settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
PREIFS="$IFS" PREIFS="$IFS"
@ -30,10 +28,10 @@ while [ -z $exitloop ];do
done done
IFS="$PREIFS" IFS="$PREIFS"
exit 0 exit 0
fi fi
#$1 is usually left blank. If it equals 'revert', then overwrite all settings with the defaults and then the script will exit. #$1 is usually left blank. If it equals 'revert', then overwrite all settings with the defaults and then the script will exit.
if [ "$1" == 'revert' ];then if [ "$1" == 'revert' ];then
#overwrite all settings with the defaults #overwrite all settings with the defaults
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')" settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
PREIFS="$IFS" PREIFS="$IFS"
@ -44,20 +42,23 @@ while [ -z $exitloop ];do
done done
IFS="$PREIFS" IFS="$PREIFS"
exit 0 exit 0
fi fi
if [ ! -f ~/.local/share/applications/pi-apps-settings.desktop ];then if [ ! -f ~/.local/share/applications/pi-apps-settings.desktop ];then
echo "Creating Settings menu button" echo "Creating Settings menu button"
echo "[Desktop Entry] echo "[Desktop Entry]
Name=Pi Apps Settings Name=Pi Apps Settings
Comment=Configure Pi-Apps or create an App Comment=Configure Pi-Apps or create an App
Exec=${DIRECTORY}/settings Exec=${DIRECTORY}/settings
Icon=${DIRECTORY}/icons/logo.png Icon=${DIRECTORY}/icons/logo.png
Terminal=false Terminal=false
Type=Application Type=Application
Categories=Settings;" > ~/.local/share/applications/pi-apps-settings.desktop Categories=Settings;" > ~/.local/share/applications/pi-apps-settings.desktop
fi fi
exitloop=''
while [ -z $exitloop ];do
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')" settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
yadparams='' yadparams=''
@ -77,7 +78,7 @@ while [ -z $exitloop ];do
#order params, with selected option first #order params, with selected option first
params="$(echo "$params" | grep -x "$curval") params="$(echo "$params" | grep -x "$curval")
$(echo "$params" | grep -v "$curval")" $(echo "$params" | grep -vx "$curval")"
params="$(echo "$params" | tr '\n' '!')" params="$(echo "$params" | tr '\n' '!')"
params="${params::-1}" params="${params::-1}"

Loading…
Cancel
Save