Add load_config_value() and get_config_display_action()

Add these two functions for use in config-gui.sh for future toggles.

load_config_value() obtains the value of a config setting, defaulting
to 'n'.  get_config_display_action() displays 'Enable' or 'Disable'
depending on the current value.

Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
This commit is contained in:
Jonathon Hall 2022-11-10 13:53:56 -05:00
parent 606c29f0ec
commit 39c655ae1d
No known key found for this signature in database
GPG Key ID: 1E9C3CA91AE25114

View File

@ -101,3 +101,21 @@ show_system_info()
whiptail $BG_COLOR_MAIN_MENU --title 'System Info' \
--msgbox "${BOARD_NAME}\n\nFW_VER: ${FW_VER}\nKernel: ${kernel}\n\nCPU: ${cpustr}\nRAM: ${memtotal} GB\n$battery_status\n$(fdisk -l | grep -e '/dev/sd.:' -e '/dev/nvme.*:' | sed 's/B,.*/B/')" 16 60
}
# Load a config value to a variable, defaulting to 'n'
load_config_value()
{
local config_name="$1"
if grep -q "$config_name" /tmp/config; then
grep "$config_name=" /tmp/config | tail -n1 | cut -f2 -d '=' | tr -d '"'
else
echo n
fi
}
# Get "Enable" or "Disable" to display in the configuration menu, based on a
# setting value
get_config_display_action()
{
[ "$1" = "y" ] && echo "Disable" || echo "Enable"
}