Added edit_mh_config_from_gui function (dont rewrite edit_db_from_gui)

This commit is contained in:
Boria138 2024-01-24 10:52:31 +06:00
parent 2fadc9ed72
commit 8ce87d05b9
2 changed files with 23 additions and 7 deletions

@ -1037,17 +1037,32 @@ update_winetricks () {
edit_db_from_gui () {
print_info "edit_db_from_gui PORTWINE_DB_FILE=$PORTWINE_DB_FILE"
for mod_db in "$@" ; do
for mod_db in $@ ; do
print_info "${mod_db}=${!mod_db}"
escaped_value=$(printf "%s" "${!mod_db}" | sed 's/\\/\\\\/g; s/,/\\,/g')
if [ -z "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}="`" ] ; then
echo "export ${mod_db}=\"${!mod_db}\"" >> "${PORTWINE_DB_FILE}"
elif [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}=" | grep -v "#"`" ] ; then
if [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}=" | grep -v "#"`" != "export ${mod_db}=\"${!mod_db}\"" ] ; then
sed -ri "s/^export ${mod_db}=.*/export ${mod_db}=\"${!mod_db}\"/" "${PORTWINE_DB_FILE}"
fi
elif [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}="`" != "export ${mod_db}=${!mod_db}" ] ; then
sed -ri "s/.*export ${mod_db}=.*/export ${mod_db}=\"${!mod_db}\"/g" "${PORTWINE_DB_FILE}"
fi
done
return 0
}
if [ -z "`grep "export ${mod_db}=" "${PORTWINE_DB_FILE}"`" ] ; then
edit_mh_config_from_gui () {
print_info "edit_mh_config_from_gui MANGOHUD_CONFIG=$MANGOHUD_CONFIG"
for mod_db in $@ ; do
escaped_value=$(printf "%s" "${!mod_db}" | sed 's/\\/\\\\/g; s/,/\\,/g')
if [ -z "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}="`" ] ; then
echo "export ${mod_db}=\"${escaped_value}\"" >> "${PORTWINE_DB_FILE}"
elif [ "`grep "export ${mod_db}=" "${PORTWINE_DB_FILE}" | grep -v "#"`" ] ; then
if [ "`grep "export ${mod_db}=" "${PORTWINE_DB_FILE}" | grep -v "#"`" != "export ${mod_db}=\"${escaped_value}\"" ] ; then
elif [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}=" | grep -v "#"`" ] ; then
if [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}=" | grep -v "#"`" != "export ${mod_db}=\"${escaped_value}\"" ] ; then
sed -ri "s/^export ${mod_db}=.*/export ${mod_db}=\"${escaped_value}\"/" "${PORTWINE_DB_FILE}"
fi
elif [ "`grep "export ${mod_db}=" "${PORTWINE_DB_FILE}"`" != "export ${mod_db}=${escaped_value}" ] ; then
elif [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}="`" != "export ${mod_db}=${escaped_value}" ] ; then
sed -ri "s/.*export ${mod_db}=.*/export ${mod_db}=\"${escaped_value}\"/g" "${PORTWINE_DB_FILE}"
fi
done

@ -619,7 +619,8 @@ gui_MangoHud () {
export MANGOHUD_CONFIG="${GUI_MH_RESULT}"
edit_db_from_gui MANGOHUD_CONFIG PW_MANGOHUD PW_FPS_LIMIT
edit_db_from_gui PW_MANGOHUD PW_FPS_LIMIT
edit_mh_config_from_gui MANGOHUD_CONFIG
/usr/bin/env bash -c "${pw_full_command_line[*]}" &
exit 0
}