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

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

@ -6,59 +6,60 @@ function error {
exit 1
}
exitloop=''
while [ -z $exitloop ];do
#ensure settings dir exists
if [ ! -d "${DIRECTORY}/data/settings" ];then
echo "creating settings directory"
mkdir -p "${DIRECTORY}/data/settings"
#create default files inside
echo '' > "${DIRECTORY}/data/settings/reinstall-after-update"
fi
#$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
#set default settings, if they don't exist
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
PREIFS="$IFS"
IFS='|'
for name in $settings
do
if [ ! -f "${DIRECTORY}/data/settings/${name}" ] || [ -z "$(cat "${DIRECTORY}/data/settings/${name}")" ];then
cat "${DIRECTORY}/etc/setting-params/${name}" | grep -v '#' | head -n1 > "${DIRECTORY}/data/settings/${name}"
fi
done
IFS="$PREIFS"
exit 0
fi
#$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
#overwrite all settings with the defaults
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
PREIFS="$IFS"
IFS='|'
for name in $settings
do
#ensure settings dir exists
if [ ! -d "${DIRECTORY}/data/settings" ];then
echo "creating settings directory"
mkdir -p "${DIRECTORY}/data/settings"
#create default files inside
echo '' > "${DIRECTORY}/data/settings/reinstall-after-update"
fi
#$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
#set default settings, if they don't exist
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
PREIFS="$IFS"
IFS='|'
for name in $settings
do
if [ ! -f "${DIRECTORY}/data/settings/${name}" ] || [ -z "$(cat "${DIRECTORY}/data/settings/${name}")" ];then
cat "${DIRECTORY}/etc/setting-params/${name}" | grep -v '#' | head -n1 > "${DIRECTORY}/data/settings/${name}"
done
IFS="$PREIFS"
exit 0
fi
fi
done
IFS="$PREIFS"
exit 0
fi
#$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
#overwrite all settings with the defaults
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
PREIFS="$IFS"
IFS='|'
for name in $settings
do
cat "${DIRECTORY}/etc/setting-params/${name}" | grep -v '#' | head -n1 > "${DIRECTORY}/data/settings/${name}"
done
IFS="$PREIFS"
exit 0
fi
if [ ! -f ~/.local/share/applications/pi-apps-settings.desktop ];then
echo "Creating Settings menu button"
echo "[Desktop Entry]
Name=Pi Apps Settings
Comment=Configure Pi-Apps or create an App
Exec=${DIRECTORY}/settings
Icon=${DIRECTORY}/icons/logo.png
Terminal=false
Type=Application
Categories=Settings;" > ~/.local/share/applications/pi-apps-settings.desktop
if [ ! -f ~/.local/share/applications/pi-apps-settings.desktop ];then
echo "Creating Settings menu button"
echo "[Desktop Entry]
Name=Pi Apps Settings
Comment=Configure Pi-Apps or create an App
Exec=${DIRECTORY}/settings
Icon=${DIRECTORY}/icons/logo.png
Terminal=false
Type=Application
Categories=Settings;" > ~/.local/share/applications/pi-apps-settings.desktop
fi
fi
exitloop=''
while [ -z $exitloop ];do
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
yadparams=''
tooltips=''
@ -77,7 +78,7 @@ while [ -z $exitloop ];do
#order params, with selected option first
params="$(echo "$params" | grep -x "$curval")
$(echo "$params" | grep -v "$curval")"
$(echo "$params" | grep -vx "$curval")"
params="$(echo "$params" | tr '\n' '!')"
params="${params::-1}"

Loading…
Cancel
Save