From 92d86fb4960d686e2befa14f518f04b53e329f8a Mon Sep 17 00:00:00 2001 From: Htylol Date: Mon, 28 Oct 2024 23:19:21 +0500 Subject: [PATCH 1/2] Added --launch and --edit-db for cli --- data_from_portwine/scripts/functions_helper | 12 ++++++++++++ data_from_portwine/scripts/start.sh | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper index ae7e145..a00ae2f 100755 --- a/data_from_portwine/scripts/functions_helper +++ b/data_from_portwine/scripts/functions_helper @@ -63,6 +63,18 @@ export -f make_abbreviation check_variables () { [[ -z ${!1} ]] && export $1="$2" ;} +cli_edit_db () { + local key value + unset keys_all + while (( $# > 0 )); do + key=$(echo "$1" | cut -d'=' -f1) + value=$(echo "$1" | cut -d'=' -f2) + keys_all+="$key " + export "$key"="$value" + shift + done +} + add_to_var () { if ! echo ${!1} | grep "$2" &>/dev/null then export $1="${!1} $2" diff --git a/data_from_portwine/scripts/start.sh b/data_from_portwine/scripts/start.sh index 69a6cd6..2c79325 100755 --- a/data_from_portwine/scripts/start.sh +++ b/data_from_portwine/scripts/start.sh @@ -59,11 +59,11 @@ elif [[ -f "$OLDPWD/$1" ]] \ && [[ "$1" == *.[Ee][Xx][Ee] || "$1" == *.[Bb][Aa][Tt] || "$1" == *.[Rr][Ee][Gg] || "$1" == *.[Mm][Ss][Ii] ]] then portwine_exe="$(realpath -s "$OLDPWD/$1")" -elif [[ "$1" == "--debug" ]] \ +elif [[ "$1" =~ (^--debug$|^--launch$|^--edit-db$) ]] \ && [[ -f "$2" ]] then portwine_exe="$(realpath -s "$2")" -elif [[ "$1" == "--debug" ]] \ +elif [[ "$1" =~ (^--debug$|^--launch$|^--edit-db$) ]] \ && [[ -f "$OLDPWD/$2" ]] \ && [[ "$2" == *.[Ee][Xx][Ee] || "$2" == *.[Bb][Aa][Tt] || "$2" == *.[Rr][Ee][Gg] || "$2" == *.[Mm][Ss][Ii] ]] then @@ -360,7 +360,7 @@ fi ### CLI ### -case "${1}" in +case "$1" in '--help' ) files_from_autoinstall=$(ls "${PORT_SCRIPTS_PATH}/pw_autoinstall") echo -e " @@ -413,6 +413,18 @@ use: [--repair] [--reinstall] [--autoinstall] '--update' ) gui_pw_update ;; + + '--launch' ) + export START_FROM_STEAM=1 + export LD_PRELOAD= + portwine_launch + stop_portwine ;; + + '--edit-db' ) + # --edit-db /полный/путь/до/файла.exe PW_MANGOHUD=1 PW_VKBASALT=0 (и т.д) для примера + cli_edit_db ${@:3} + edit_db_from_gui $keys_all + exit 0 ;; esac ### GUI ### From 0e0ec3028d713758805d7eff698e10b0c3f641b0 Mon Sep 17 00:00:00 2001 From: Htylol Date: Mon, 28 Oct 2024 23:49:24 +0500 Subject: [PATCH 2/2] minor edition --- data_from_portwine/scripts/functions_helper | 11 +++++++---- data_from_portwine/scripts/start.sh | 10 ++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper index a00ae2f..a52d32c 100755 --- a/data_from_portwine/scripts/functions_helper +++ b/data_from_portwine/scripts/functions_helper @@ -63,12 +63,15 @@ export -f make_abbreviation check_variables () { [[ -z ${!1} ]] && export $1="$2" ;} -cli_edit_db () { +# Эксортирует несколько переменных за один раз (одной командой) +# и создаёт список этих переменных в $keys_all +# К примеру set_several_variables PW_MANGOHUD=1 PW_VKBASALT=0 +set_several_variables () { local key value unset keys_all - while (( $# > 0 )); do - key=$(echo "$1" | cut -d'=' -f1) - value=$(echo "$1" | cut -d'=' -f2) + while (( $# > 0 )) ; do + key=${1//=*/} + value=${1//*=/} keys_all+="$key " export "$key"="$value" shift diff --git a/data_from_portwine/scripts/start.sh b/data_from_portwine/scripts/start.sh index 2c79325..27aa9e6 100755 --- a/data_from_portwine/scripts/start.sh +++ b/data_from_portwine/scripts/start.sh @@ -56,7 +56,7 @@ if [[ "$1" == *.[Pp][Pp][Aa][Cc][Kk] ]] ; then elif [[ -f "$1" ]] ; then portwine_exe="$(realpath -s "$1")" elif [[ -f "$OLDPWD/$1" ]] \ -&& [[ "$1" == *.[Ee][Xx][Ee] || "$1" == *.[Bb][Aa][Tt] || "$1" == *.[Rr][Ee][Gg] || "$1" == *.[Mm][Ss][Ii] ]] +&& [[ "$1" =~ (.[Ee][Xx][Ee]$|.[Bb][Aa][Tt]$|.[Mm][Ss][Ii]$|.[Rr][Ee][Gg]$) ]] then portwine_exe="$(realpath -s "$OLDPWD/$1")" elif [[ "$1" =~ (^--debug$|^--launch$|^--edit-db$) ]] \ @@ -65,10 +65,10 @@ then portwine_exe="$(realpath -s "$2")" elif [[ "$1" =~ (^--debug$|^--launch$|^--edit-db$) ]] \ && [[ -f "$OLDPWD/$2" ]] \ -&& [[ "$2" == *.[Ee][Xx][Ee] || "$2" == *.[Bb][Aa][Tt] || "$2" == *.[Rr][Ee][Gg] || "$2" == *.[Mm][Ss][Ii] ]] +&& [[ "$2" =~ (.[Ee][Xx][Ee]$|.[Bb][Aa][Tt]$|.[Mm][Ss][Ii]$|.[Rr][Ee][Gg]$) ]] then portwine_exe="$(realpath -s "$OLDPWD/$2")" -elif [[ "$1" == *.[Ee][Xx][Ee] || "$1" == *.[Bb][Aa][Tt] || "$1" == *.[Mm][Ss][Ii] || "$1" == *.[Rr][Ee][Gg] ]] +elif [[ "$1" =~ (.[Ee][Xx][Ee]$|.[Bb][Aa][Tt]$|.[Mm][Ss][Ii]$|.[Rr][Ee][Gg]$) ]] then portwine_exe="$1" MISSING_DESKTOP_FILE="1" @@ -415,14 +415,12 @@ use: [--repair] [--reinstall] [--autoinstall] gui_pw_update ;; '--launch' ) - export START_FROM_STEAM=1 - export LD_PRELOAD= portwine_launch stop_portwine ;; '--edit-db' ) # --edit-db /полный/путь/до/файла.exe PW_MANGOHUD=1 PW_VKBASALT=0 (и т.д) для примера - cli_edit_db ${@:3} + set_several_variables ${@:3} edit_db_from_gui $keys_all exit 0 ;; esac