From 5becab314200d856901ce5620a548e75a1538300 Mon Sep 17 00:00:00 2001 From: Htylol Date: Thu, 31 Oct 2024 19:17:44 +0500 Subject: [PATCH 1/5] Added PW_WINE_DPI_VALUE --- data_from_portwine/scripts/functions_helper | 91 ++++++++++++++++----- 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper index ae7e145a..7e69e781 100755 --- a/data_from_portwine/scripts/functions_helper +++ b/data_from_portwine/scripts/functions_helper @@ -1124,6 +1124,22 @@ combobox_fix () { fi } +convert_dec_and_hex () { + local type=$1 + local num=$2 + + case "$type" in + --dec) + # Преобразование из десятичного в шестнадцатеричный + echo -n $(printf "%08x" $num) ;; + --hex) + # Преобразование из шестнадцатеричного в десятичный + echo $(( 0x$num )) ;; + *) + echo "Неверный тип преобразования. Используйте --dec или --hex." ;; + esac +} + restart_pp () { case "$1" in --userconf) export RESTART_PP_USED="userconf" ;; @@ -1493,7 +1509,7 @@ regdlloverrides () { wait_wineserver () { while ls -l /proc/*/exe >/dev/null 2>&1 | grep -ie PortProton | grep -E 'wine(64)?-preloader|wineserver' do - sleep 1 + sleep 0.1 done "$WINESERVER" -w return 0 @@ -2542,7 +2558,7 @@ pw_find_exe () { pw_stop_progress_bar unset FIND_TO_GUI - while read line; do + while read -r line; do FIND_TO_GUI+="${line}%" done < "${PW_TMPFS_PATH}/tmp_yad_find_exe" @@ -3532,14 +3548,14 @@ start_portwine () { echo "Set to win${PW_WINDOWS_VER}" fi - if [[ "${portwine_exe}" == *-Shipping.exe ]] ; then + if [[ "$portwine_exe" == *-Shipping.exe ]] ; then echo "Disable EAC" - [[ -z "${LAUNCH_PARAMETERS}" ]] && export LAUNCH_PARAMETERS+=" -eac-nop-loaded " + [[ -z "$LAUNCH_PARAMETERS" ]] && export LAUNCH_PARAMETERS+=" -eac-nop-loaded " fi HIDRAW_VAR="$(grep "DisableHidraw" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/system.reg")" SDL_VAR="$(grep "Enable SDL" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/system.reg")" - if [[ "${PW_DINPUT_PROTOCOL}" == "1" ]] ; then + if [[ "$PW_DINPUT_PROTOCOL" == "1" ]] ; then if [[ "$HIDRAW_VAR" ]] \ && [[ "$SDL_VAR" ]] then @@ -3554,9 +3570,11 @@ start_portwine () { print_info "Added DisableHidraw = 0 to reg file" ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ "${WINELOADER}" reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\winebus" /v "DisableHidraw" /t REG_DWORD /d 0 /f + wait_wineserver print_info "Added Enable SDL = 0 to reg file" ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ "${WINELOADER}" reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\winebus" /v "Enable SDL" /t REG_DWORD /d 0 /f + wait_wineserver fi else # var_winedlloverride_update "xinput1_1,xinput1_2,xinput1_3,xinput9_1_0=b" @@ -3575,9 +3593,27 @@ start_portwine () { print_info "Added DisableHidraw = 1 to reg file" ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ "${WINELOADER}" reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\winebus" /v "DisableHidraw" /t REG_DWORD /d 1 /f + wait_wineserver print_info "Added Enable SDL = 1 to reg file" ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ "${WINELOADER}" reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\winebus" /v "Enable SDL" /t REG_DWORD /d 1 /f + wait_wineserver + fi + fi + + WINE_DPI_VAR="$(grep -A200 '\[Control Panel\\\\Desktop\]' "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" | grep '"LogPixels"=')" + if [[ "$PW_WINE_DPI_VALUE" != "disabled" ]] ; then + PW_WINE_DPI_VALUE=${PW_WINE_DPI_VALUE// (*/} + if [[ -n $WINE_DPI_VAR ]] ; then + GREP_NUMBER_DPI=$(grep -n '"LogPixels"=' user.reg) + GREP_NUMBER_DPI=${GREP_NUMBER_DPI//:*/} + PW_WINE_DPI_VALUE_NEW=$(convert_dec_and_hex --dec "$PW_WINE_DPI_VALUE") + sed -i ${GREP_NUMBER_DPI}s'/"LogPixels"=dword:[0-9]*/\"LogPixels"=dword:'$PW_WINE_DPI_VALUE_NEW/ "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" + else + print_info "Added LogPixels (for DPI) to reg file" + ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ + "${WINELOADER}" reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v "LogPixels" /t REG_DWORD /d $PW_WINE_DPI_VALUE /f + wait_wineserver fi fi @@ -3587,6 +3623,7 @@ start_portwine () { print_info "Enable experimental Wayland support" ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ "${WINELOADER}" reg add "HKEY_CURRENT_USER\Software\Wine\Drivers" /v "Graphics" /t REG_SZ /d "x11,wayland" /f + wait_wineserver fi export PW_DISPLAY="env DISPLAY=" export PW_USE_RUNTIME="0" @@ -3595,7 +3632,8 @@ start_portwine () { if [[ "$WINE_WAYLAND_VAR" ]] ; then print_info "Disable experimental Wayland support" ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ - "${WINELOADER}" reg delete "HKEY_CURRENT_USER\Software\Wine\Drivers" /v Graphics /f + "${WINELOADER}" reg delete "HKEY_CURRENT_USER\Software\Wine\Drivers" /v "Graphics" /f + wait_wineserver fi fi @@ -3618,7 +3656,6 @@ start_portwine () { pw_stop_progress_bar && if ! check_start_from_steam ; then pw_tray_icon - sleep 0.5 fi if [[ "${PW_CHECK_AUTOINSTALL}" != "1" ]] ; then @@ -3873,6 +3910,8 @@ pw_run () { wait_wineserver fi fi + + return 0 } export -f pw_run @@ -4234,8 +4273,6 @@ pw_tray_icon () { PW_GUI_TRAY_PATH="${PW_GUI_THEMES_PATH}/tray" env LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}" "${PW_GUI_TRAY_PATH}/tray_gui_pp" & fi - - return 0 } # GUI GET OTHER WINE @@ -5428,45 +5465,54 @@ gui_userconf () { --field=" $NEW_STEAM_BEHAVIOR ${translations[steam covers download]}"!"$PW_GUI_ICON_PATH/$BUTTON_SIZE_MM.png"!"${translations[If downloading steam covers is enabled, they will be downloaded and created. (Disablement is provided in cases where their downloading is unavailable for some reason)]}":"FBTN" '@bash -c "button_click --userconf change_download_grid"' \ 2>/dev/null & - if [[ -n "${PW_SOUND_DRIVER_USE}" ]] \ - && [[ "${PW_SOUND_DRIVER_USE}" != "disabled" ]] + if [[ -n "$PW_SOUND_DRIVER_USE" ]] \ + && [[ "$PW_SOUND_DRIVER_USE" != "disabled" ]] then - SOUND_DRIVER_VAR="${PW_SOUND_DRIVER_USE}" + SOUND_DRIVER_VAR="$PW_SOUND_DRIVER_USE" else SOUND_DRIVER_VAR="disabled" fi - if [[ -n "${PW_GPU_USE}" ]] \ - && [[ "${PW_GPU_USE}" != "disabled" ]] + if [[ -n "$PW_GPU_USE" ]] \ + && [[ "$PW_GPU_USE" != "disabled" ]] then - GPU_VAR="${PW_GPU_USE}" + GPU_VAR="$PW_GPU_USE" else GPU_VAR="disabled" fi - if [[ -n "${DESKTOP_WITH_TIME}" ]] \ - && [[ "${DESKTOP_WITH_TIME}" != "disabled" ]] + if [[ -n "$DESKTOP_WITH_TIME" ]] \ + && [[ "$DESKTOP_WITH_TIME" != "disabled" ]] then DESKTOP_WITH_TIME="enabled" else DESKTOP_WITH_TIME="disabled" fi - if [[ -n "${SORT_WITH_TIME}" ]] \ - && [[ "${SORT_WITH_TIME}" == "disabled" ]] + if [[ -n "$SORT_WITH_TIME" ]] \ + && [[ "$SORT_WITH_TIME" == "disabled" ]] then SORT_WITH_TIME="disabled" else SORT_WITH_TIME="enabled" fi - "${pw_yad}" --plug=$KEY_USERCONF_GUI --tabnum="2" --form --columns=1 --separator="%" --homogeneous-row \ + if [[ -n "$PW_WINE_DPI_VALUE" ]] \ + && [[ "$PW_WINE_DPI_VALUE" != "disabled" ]] + then + YAD_DPI_VAR="$PW_WINE_DPI_VALUE" + else + YAD_DPI_VAR="disabled" + fi + + "${pw_yad}" --plug=$KEY_USERCONF_GUI --tabnum="2" --form --columns=1 --separator="@" --homogeneous-row \ --gui-type-text="$PANED_GUI_TYPE_TEXT_DOWN" --gui-type-layout="$PANED_GUI_TYPE_LAYOUT_DOWN" \ --field="${translations[Choose a graphics card to run the game]}!${translations[Select which video card will be used to run the game (used for all running games and programs in PortProton)]} :CB" "$(combobox_fix --disabled "$GPU_VAR" "$GET_GPU_NAMES")" \ --field="${translations[Choice wine audio driver]}!${translations[Fixes sound popling if choice alsa]} :CB" "$(combobox_fix --disabled "$SOUND_DRIVER_VAR" "alsa!oss!pulse")" \ --field="${translations[Choice gui themes]}!${translations[Allows you to select a theme for PortProton]} :CB" "$(combobox_fix "$GUI_THEME" "default!compact!classic")" \ --field="${translations[Time display]}!${translations[Displays time spent in an application or game]} :CB" "$(combobox_fix --disabled "$DESKTOP_WITH_TIME" "enabled")" \ --field="${translations[Sort shortcuts by time]}!${translations[This setting sorts the shortcuts in the main menu depending on the time spent in the application or game]} :CB" "$(combobox_fix --disabled "$SORT_WITH_TIME" "enabled")" \ + --field="${translations[Force dpi for fonts]}!${translations[Here you can set forced dpi for fonts in wine]} :CB" "$(combobox_fix --disabled "$YAD_DPI_VAR" "96 (100%)!120 (125%)!144 (150%)!168 (175%)!192 (200%)!216 (225%)!240 (250%)!264 (275%)!288 (300%)")" \ 1> "${PW_TMPFS_PATH}/tmp_yad_userconf_set_cb" 2>/dev/null & "${pw_yad}" --key=$KEY_USERCONF_GUI --paned --sensitive \ @@ -5497,14 +5543,15 @@ gui_userconf () { gui_open_user_conf ;; 166) - IFS='%' read -r -a PW_ADD_SETTINGS_UC <"${PW_TMPFS_PATH}/tmp_yad_userconf_set_cb" + IFS='@' read -r -a PW_ADD_SETTINGS_UC <"${PW_TMPFS_PATH}/tmp_yad_userconf_set_cb" IFS="$orig_IFS" PW_GPU_USE="${PW_ADD_SETTINGS_UC[0]}" PW_SOUND_DRIVER_USE="${PW_ADD_SETTINGS_UC[1]}" GUI_THEME="${PW_ADD_SETTINGS_UC[2]}" DESKTOP_WITH_TIME="${PW_ADD_SETTINGS_UC[3]}" SORT_WITH_TIME="${PW_ADD_SETTINGS_UC[4]}" - edit_user_conf_from_gui PW_GPU_USE PW_SOUND_DRIVER_USE GUI_THEME DESKTOP_WITH_TIME SORT_WITH_TIME + PW_WINE_DPI_VALUE="${PW_ADD_SETTINGS_UC[5]}" + edit_user_conf_from_gui PW_GPU_USE PW_SOUND_DRIVER_USE GUI_THEME DESKTOP_WITH_TIME SORT_WITH_TIME PW_WINE_DPI_VALUE restart_pp ;; esac From 6bbfd9fd24596893b32bb36ab98a14b45eef4769 Mon Sep 17 00:00:00 2001 From: Htylol Date: Thu, 31 Oct 2024 20:24:31 +0500 Subject: [PATCH 2/5] Update --- data_from_portwine/locales/PortProton.pot | 8 +++++++- .../locales/es/LC_MESSAGES/PortProton.po | 8 +++++++- .../locales/ru/LC_MESSAGES/PortProton.po | 11 +++++++++-- data_from_portwine/scripts/functions_helper | 18 ++++++++---------- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/data_from_portwine/locales/PortProton.pot b/data_from_portwine/locales/PortProton.pot index 62eef70a..ec43598d 100644 --- a/data_from_portwine/locales/PortProton.pot +++ b/data_from_portwine/locales/PortProton.pot @@ -7,7 +7,7 @@ msgid "" msgstr "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" - "POT-Creation-Date: 2024-10-26 06:41+0500\n" + "POT-Creation-Date: 2024-10-31 19:55+0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1388,6 +1388,12 @@ msgid "Select which video card will be used to run the game (used for all " "running games and programs in PortProton)" msgstr "" +msgid "Force dpi for fonts" +msgstr "" + +msgid "Here you can set forced dpi for fonts in wine" +msgstr "" + msgid "Choice wine audio driver" msgstr "" diff --git a/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po b/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po index e4b59990..ba5a206e 100644 --- a/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po +++ b/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-26 06:41+0500\n" +"POT-Creation-Date: 2024-10-31 19:54+0500\n" "PO-Revision-Date: 2024-10-26 13:58+0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -1814,6 +1814,12 @@ msgstr "" "Selecciona qué tarjeta de vídeo se utilizará para ejecutar el juego (se " "utiliza para todos los juegos y programas en ejecución en PortProton)" +msgid "Force dpi for fonts" +msgstr "" + +msgid "Here you can set forced dpi for fonts in wine" +msgstr "" + msgid "Choice wine audio driver" msgstr "Controlador de audio de vino elegido" diff --git a/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po b/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po index 3c2bff35..a02b555a 100644 --- a/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po +++ b/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-26 06:41+0500\n" -"PO-Revision-Date: 2024-10-26 06:43+0500\n" +"POT-Creation-Date: 2024-10-31 19:54+0500\n" +"PO-Revision-Date: 2024-10-31 19:55+0500\n" "Last-Translator: \n" "Language-Team: \n" "Language: ru_RU\n" @@ -1792,6 +1792,13 @@ msgstr "" "Выбор видеокарты для запуска игры (используется для всех запущенных игр и " "программ в PortProton)" +msgid "Force dpi for fonts" +msgstr "Принудительное разрешение шрифтов" + +msgid "Here you can set forced dpi for fonts in wine" +msgstr "" +"Здесь вы можете установить принудительное разрешение для шрифтов в Wine" + msgid "Choice wine audio driver" msgstr "Выбрать звуковой драйвер" diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper index 7e69e781..faabd64b 100755 --- a/data_from_portwine/scripts/functions_helper +++ b/data_from_portwine/scripts/functions_helper @@ -3608,7 +3608,7 @@ start_portwine () { GREP_NUMBER_DPI=$(grep -n '"LogPixels"=' user.reg) GREP_NUMBER_DPI=${GREP_NUMBER_DPI//:*/} PW_WINE_DPI_VALUE_NEW=$(convert_dec_and_hex --dec "$PW_WINE_DPI_VALUE") - sed -i ${GREP_NUMBER_DPI}s'/"LogPixels"=dword:[0-9]*/\"LogPixels"=dword:'$PW_WINE_DPI_VALUE_NEW/ "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" + sed -i ${GREP_NUMBER_DPI}s'/"LogPixels"=dword:.*/\"LogPixels"=dword:'$PW_WINE_DPI_VALUE_NEW/ "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" else print_info "Added LogPixels (for DPI) to reg file" ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ @@ -3910,8 +3910,6 @@ pw_run () { wait_wineserver fi fi - - return 0 } export -f pw_run @@ -5508,11 +5506,11 @@ gui_userconf () { "${pw_yad}" --plug=$KEY_USERCONF_GUI --tabnum="2" --form --columns=1 --separator="@" --homogeneous-row \ --gui-type-text="$PANED_GUI_TYPE_TEXT_DOWN" --gui-type-layout="$PANED_GUI_TYPE_LAYOUT_DOWN" \ --field="${translations[Choose a graphics card to run the game]}!${translations[Select which video card will be used to run the game (used for all running games and programs in PortProton)]} :CB" "$(combobox_fix --disabled "$GPU_VAR" "$GET_GPU_NAMES")" \ + --field="${translations[Force dpi for fonts]}!${translations[Here you can set forced dpi for fonts in wine]} :CB" "$(combobox_fix --disabled "$YAD_DPI_VAR" "96 (100%)!120 (125%)!144 (150%)!168 (175%)!192 (200%)!216 (225%)!240 (250%)!264 (275%)!288 (300%)")" \ --field="${translations[Choice wine audio driver]}!${translations[Fixes sound popling if choice alsa]} :CB" "$(combobox_fix --disabled "$SOUND_DRIVER_VAR" "alsa!oss!pulse")" \ --field="${translations[Choice gui themes]}!${translations[Allows you to select a theme for PortProton]} :CB" "$(combobox_fix "$GUI_THEME" "default!compact!classic")" \ --field="${translations[Time display]}!${translations[Displays time spent in an application or game]} :CB" "$(combobox_fix --disabled "$DESKTOP_WITH_TIME" "enabled")" \ --field="${translations[Sort shortcuts by time]}!${translations[This setting sorts the shortcuts in the main menu depending on the time spent in the application or game]} :CB" "$(combobox_fix --disabled "$SORT_WITH_TIME" "enabled")" \ - --field="${translations[Force dpi for fonts]}!${translations[Here you can set forced dpi for fonts in wine]} :CB" "$(combobox_fix --disabled "$YAD_DPI_VAR" "96 (100%)!120 (125%)!144 (150%)!168 (175%)!192 (200%)!216 (225%)!240 (250%)!264 (275%)!288 (300%)")" \ 1> "${PW_TMPFS_PATH}/tmp_yad_userconf_set_cb" 2>/dev/null & "${pw_yad}" --key=$KEY_USERCONF_GUI --paned --sensitive \ @@ -5546,12 +5544,12 @@ gui_userconf () { IFS='@' read -r -a PW_ADD_SETTINGS_UC <"${PW_TMPFS_PATH}/tmp_yad_userconf_set_cb" IFS="$orig_IFS" PW_GPU_USE="${PW_ADD_SETTINGS_UC[0]}" - PW_SOUND_DRIVER_USE="${PW_ADD_SETTINGS_UC[1]}" - GUI_THEME="${PW_ADD_SETTINGS_UC[2]}" - DESKTOP_WITH_TIME="${PW_ADD_SETTINGS_UC[3]}" - SORT_WITH_TIME="${PW_ADD_SETTINGS_UC[4]}" - PW_WINE_DPI_VALUE="${PW_ADD_SETTINGS_UC[5]}" - edit_user_conf_from_gui PW_GPU_USE PW_SOUND_DRIVER_USE GUI_THEME DESKTOP_WITH_TIME SORT_WITH_TIME PW_WINE_DPI_VALUE + PW_WINE_DPI_VALUE="${PW_ADD_SETTINGS_UC[1]}" + PW_SOUND_DRIVER_USE="${PW_ADD_SETTINGS_UC[2]}" + GUI_THEME="${PW_ADD_SETTINGS_UC[3]}" + DESKTOP_WITH_TIME="${PW_ADD_SETTINGS_UC[4]}" + SORT_WITH_TIME="${PW_ADD_SETTINGS_UC[5]}" + edit_user_conf_from_gui PW_GPU_USE PW_WINE_DPI_VALUE PW_SOUND_DRIVER_USE GUI_THEME DESKTOP_WITH_TIME SORT_WITH_TIME restart_pp ;; esac From 96f6460813f3d629facc3ea26da7dde34bfec076 Mon Sep 17 00:00:00 2001 From: Htylol Date: Fri, 1 Nov 2024 05:37:28 +0500 Subject: [PATCH 3/5] Added get_and_set_reg_file --- data_from_portwine/scripts/functions_helper | 49 +++++++++++++++------ 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper index faabd64b..1a8dd453 100755 --- a/data_from_portwine/scripts/functions_helper +++ b/data_from_portwine/scripts/functions_helper @@ -1124,6 +1124,41 @@ combobox_fix () { fi } +get_and_set_reg_file () { +local name_block name_for_find find_block find_file find_line count +local line_reg find_number_line find_check_file name_for_set +name_block=$1 +name_for_find=$2 +name_for_set=$3 +name_block=${name_block//\\/\\\\} +name_block=${name_block//\[/\\[} +name_block=${name_block//\]/\\]} +find_block=$(grep -n "$name_block" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/"*.reg) +find_file=${find_block//:*/} +find_line=${find_block//$find_file:/} +find_line=${find_line//:*/} +count=-1 +while IFS= read -r line_reg ; do + ((count++)) + if [[ $line_reg =~ $name_for_find ]] ; then + find_number_line=$(( count + find_line )) + find_check_file=1 + break + fi + [[ -z $line_reg ]] && break +done <<< $(sed -n "$find_line"',$p' $find_file) +IFS="$orig_IFS" +if [[ $name_for_set =~ ^[0-9]+$ ]] ; then + name_for_set=$(convert_dec_and_hex --dec "$name_for_set") +fi +if [[ $find_check_file == 1 ]] ; then + sed -i "${find_number_line}s/$name_for_find.*/$name_for_find$name_for_set/" "$find_file" +else + print_info "Added ${name_for_find//=*} to reg file" + sed -i "$(( find_line + 1 ))a$name_for_find$name_for_set" "$find_file" +fi +} + convert_dec_and_hex () { local type=$1 local num=$2 @@ -3601,20 +3636,8 @@ start_portwine () { fi fi - WINE_DPI_VAR="$(grep -A200 '\[Control Panel\\\\Desktop\]' "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" | grep '"LogPixels"=')" if [[ "$PW_WINE_DPI_VALUE" != "disabled" ]] ; then - PW_WINE_DPI_VALUE=${PW_WINE_DPI_VALUE// (*/} - if [[ -n $WINE_DPI_VAR ]] ; then - GREP_NUMBER_DPI=$(grep -n '"LogPixels"=' user.reg) - GREP_NUMBER_DPI=${GREP_NUMBER_DPI//:*/} - PW_WINE_DPI_VALUE_NEW=$(convert_dec_and_hex --dec "$PW_WINE_DPI_VALUE") - sed -i ${GREP_NUMBER_DPI}s'/"LogPixels"=dword:.*/\"LogPixels"=dword:'$PW_WINE_DPI_VALUE_NEW/ "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" - else - print_info "Added LogPixels (for DPI) to reg file" - ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ - "${WINELOADER}" reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v "LogPixels" /t REG_DWORD /d $PW_WINE_DPI_VALUE /f - wait_wineserver - fi + get_and_set_reg_file '[Control Panel\\Desktop]' '"LogPixels"=dword:' "${PW_WINE_DPI_VALUE// (*/}" fi WINE_WAYLAND_VAR="$(grep "x11,wayland" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg")" From 6393c6f50761091293ea71c0745df3c70b89363a Mon Sep 17 00:00:00 2001 From: Htylol Date: Fri, 1 Nov 2024 07:30:53 +0500 Subject: [PATCH 4/5] Updated func --- data_from_portwine/scripts/functions_helper | 171 ++++++++------------ 1 file changed, 70 insertions(+), 101 deletions(-) diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper index 1a8dd453..75217ad9 100755 --- a/data_from_portwine/scripts/functions_helper +++ b/data_from_portwine/scripts/functions_helper @@ -1125,54 +1125,75 @@ combobox_fix () { } get_and_set_reg_file () { -local name_block name_for_find find_block find_file find_line count -local line_reg find_number_line find_check_file name_for_set -name_block=$1 -name_for_find=$2 -name_for_set=$3 -name_block=${name_block//\\/\\\\} -name_block=${name_block//\[/\\[} -name_block=${name_block//\]/\\]} -find_block=$(grep -n "$name_block" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/"*.reg) -find_file=${find_block//:*/} -find_line=${find_block//$find_file:/} -find_line=${find_line//:*/} -count=-1 -while IFS= read -r line_reg ; do - ((count++)) - if [[ $line_reg =~ $name_for_find ]] ; then - find_number_line=$(( count + find_line )) - find_check_file=1 - break + local name_block name_for_find find_block find_file find_line count + local line_reg find_number_line find_check_file name_for_set name_block_old + name_block=$1 + name_for_find=$2 + name_for_set=$3 + name_block_old=$name_block + name_block=${name_block//\\/\\\\} + name_block=${name_block//\[/\\[} + name_block=${name_block//\]/\\]} + find_block=$(grep -n "$name_block" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/"*.reg) + if [[ -n $find_block ]] ; then + find_file=${find_block//:*/} + find_line=${find_block//$find_file:/} + find_line=${find_line//:*/} + else + if [[ -n $4 ]] ; then + sed -i '$a\\n'"${name_block_old//\\/\\\\}" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/$4.reg" + find_file=${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/$4.reg + find_line=$(wc -l "$find_file" | awk -F" " '{print $1}') + else + print_error "$name_block_old not found in reg files" + return 1 + fi + fi + count=-1 + while IFS= read -r line_reg ; do + ((count++)) + if [[ $line_reg =~ $name_for_find ]] ; then + find_number_line=$(( count + find_line )) + find_check_file=1 + break + fi + [[ -z $line_reg ]] && break + done <<< $(sed -n "$find_line"',$p' $find_file) + IFS="$orig_IFS" + if [[ $name_for_set =~ ^[0-9]+$ ]] ; then + name_for_set=$(convert_dec_and_hex --dec "$name_for_set") + fi + if [[ ${name_for_set,,} =~ ^[a-z]+$ ]] ; then + if [[ $find_check_file == 1 ]] ; then + sed -i "${find_number_line}s/$name_for_find.*/$name_for_find\"$name_for_set\"/" "$find_file" + else + print_info "Added ${name_for_find//=*} to reg file" + sed -i "$(( find_line + 1 ))a$name_for_find\"$name_for_set\"" "$find_file" + fi + else + if [[ $find_check_file == 1 ]] ; then + sed -i "${find_number_line}s/$name_for_find.*/$name_for_find$name_for_set/" "$find_file" + else + print_info "Added ${name_for_find//=*} to reg file" + sed -i "$(( find_line + 1 ))a$name_for_find$name_for_set" "$find_file" + fi fi - [[ -z $line_reg ]] && break -done <<< $(sed -n "$find_line"',$p' $find_file) -IFS="$orig_IFS" -if [[ $name_for_set =~ ^[0-9]+$ ]] ; then - name_for_set=$(convert_dec_and_hex --dec "$name_for_set") -fi -if [[ $find_check_file == 1 ]] ; then - sed -i "${find_number_line}s/$name_for_find.*/$name_for_find$name_for_set/" "$find_file" -else - print_info "Added ${name_for_find//=*} to reg file" - sed -i "$(( find_line + 1 ))a$name_for_find$name_for_set" "$find_file" -fi } convert_dec_and_hex () { - local type=$1 - local num=$2 + local type=$1 + local num=$2 - case "$type" in - --dec) - # Преобразование из десятичного в шестнадцатеричный - echo -n $(printf "%08x" $num) ;; - --hex) - # Преобразование из шестнадцатеричного в десятичный - echo $(( 0x$num )) ;; - *) - echo "Неверный тип преобразования. Используйте --dec или --hex." ;; - esac + case "$type" in + --dec) + # Преобразование из десятичного в шестнадцатеричный + echo -n $(printf "%08x" $num) ;; + --hex) + # Преобразование из шестнадцатеричного в десятичный + echo $(( 0x$num )) ;; + *) + echo "Неверный тип преобразования. Используйте --dec или --hex." ;; + esac } restart_pp () { @@ -3588,52 +3609,12 @@ start_portwine () { [[ -z "$LAUNCH_PARAMETERS" ]] && export LAUNCH_PARAMETERS+=" -eac-nop-loaded " fi - HIDRAW_VAR="$(grep "DisableHidraw" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/system.reg")" - SDL_VAR="$(grep "Enable SDL" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/system.reg")" if [[ "$PW_DINPUT_PROTOCOL" == "1" ]] ; then - if [[ "$HIDRAW_VAR" ]] \ - && [[ "$SDL_VAR" ]] - then - if [[ "${HIDRAW_VAR: -1}" != "0" ]] ; then - sed -i "s/${HIDRAW_VAR}/${HIDRAW_VAR%?}0/" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/system.reg" - fi - - if [[ "${SDL_VAR: -1}" != "0" ]] ; then - sed -i "s/${SDL_VAR}/${SDL_VAR%?}0/" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/system.reg" - fi - else - print_info "Added DisableHidraw = 0 to reg file" - ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ - "${WINELOADER}" reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\winebus" /v "DisableHidraw" /t REG_DWORD /d 0 /f - wait_wineserver - print_info "Added Enable SDL = 0 to reg file" - ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ - "${WINELOADER}" reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\winebus" /v "Enable SDL" /t REG_DWORD /d 0 /f - wait_wineserver - fi + get_and_set_reg_file '[System\\CurrentControlSet\\Services\\winebus]' '"DisableHidraw"=dword:' "0" + get_and_set_reg_file '[System\\CurrentControlSet\\Services\\winebus]' '"Enable SDL"=dword:' "0" else - # var_winedlloverride_update "xinput1_1,xinput1_2,xinput1_3,xinput9_1_0=b" - - if [[ "$HIDRAW_VAR" ]] \ - && [[ "$SDL_VAR" ]] - then - if [[ "${HIDRAW_VAR: -1}" != "1" ]] ; then - sed -i "s/${HIDRAW_VAR}/${HIDRAW_VAR%?}1/" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/system.reg" - fi - - if [[ "${SDL_VAR: -1}" != "1" ]] ; then - sed -i "s/${SDL_VAR}/${SDL_VAR%?}1/" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/system.reg" - fi - else - print_info "Added DisableHidraw = 1 to reg file" - ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ - "${WINELOADER}" reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\winebus" /v "DisableHidraw" /t REG_DWORD /d 1 /f - wait_wineserver - print_info "Added Enable SDL = 1 to reg file" - ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ - "${WINELOADER}" reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\winebus" /v "Enable SDL" /t REG_DWORD /d 1 /f - wait_wineserver - fi + get_and_set_reg_file '[System\\CurrentControlSet\\Services\\winebus]' '"DisableHidraw"=dword:' "1" + get_and_set_reg_file '[System\\CurrentControlSet\\Services\\winebus]' '"Enable SDL"=dword:' "1" fi if [[ "$PW_WINE_DPI_VALUE" != "disabled" ]] ; then @@ -3660,20 +3641,8 @@ start_portwine () { fi fi - if [[ "${PW_SOUND_DRIVER_USE}" != "disabled" ]] \ - && grep -v "\"Audio\"=\"$PW_SOUND_DRIVER_USE\"" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" &>/dev/null - then - if grep "\"Audio\"=" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" &>/dev/null ; then - sed -i 's/"Audio"=".*"/"Audio"="'${PW_SOUND_DRIVER_USE}'"/' "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" - else - echo -e '\n[Software\\Wine\\Drivers]\n"Audio"="'${PW_SOUND_DRIVER_USE}'"' >> "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" - fi - kill_portwine - elif [[ "${PW_SOUND_DRIVER_USE}" == "disabled" ]] \ - && grep -v "\"Audio\"=" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" &>/dev/null - then - sed -i '/\[Software\\Wine\\Drivers\]/d' "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" &>/dev/null - sed -i "/\"Audio\"=/d" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg" &>/dev/null + if [[ "${PW_SOUND_DRIVER_USE}" != "disabled" ]] ; then + get_and_set_reg_file '[Software\\Wine\\Drivers]' '"Audio"=' "$PW_SOUND_DRIVER_USE" "user" fi pw_stop_progress_bar && From 33064681a16ade94bcdb1ef6bedfa0219ec63e16 Mon Sep 17 00:00:00 2001 From: Htylol Date: Fri, 1 Nov 2024 18:38:12 +0500 Subject: [PATCH 5/5] Added --add and --delete args for reg func --- data_from_portwine/scripts/functions_helper | 119 ++++++++++---------- 1 file changed, 58 insertions(+), 61 deletions(-) diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper index 75217ad9..07100bbb 100755 --- a/data_from_portwine/scripts/functions_helper +++ b/data_from_portwine/scripts/functions_helper @@ -1125,58 +1125,66 @@ combobox_fix () { } get_and_set_reg_file () { - local name_block name_for_find find_block find_file find_line count + local name_block name_for_find find_block find_file find_line count name_for_new_block local line_reg find_number_line find_check_file name_for_set name_block_old - name_block=$1 - name_for_find=$2 - name_for_set=$3 + name_block=$2 name_block_old=$name_block + name_for_find=$3 + name_for_set=$4 + name_for_new_block=$5 name_block=${name_block//\\/\\\\} name_block=${name_block//\[/\\[} - name_block=${name_block//\]/\\]} - find_block=$(grep -n "$name_block" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/"*.reg) + find_block=$(grep -n "${name_block//\]/\\]}" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/"*.reg) if [[ -n $find_block ]] ; then find_file=${find_block//:*/} find_line=${find_block//$find_file:/} find_line=${find_line//:*/} - else - if [[ -n $4 ]] ; then - sed -i '$a\\n'"${name_block_old//\\/\\\\}" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/$4.reg" - find_file=${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/$4.reg - find_line=$(wc -l "$find_file" | awk -F" " '{print $1}') - else - print_error "$name_block_old not found in reg files" - return 1 - fi + count=-1 + while IFS= read -r line_reg ; do + ((count++)) + if [[ $line_reg =~ $name_for_find ]] ; then + find_number_line=$(( count + find_line )) + find_check_file=1 + break + fi + [[ -z $line_reg ]] && break + done <<< $(sed -n "$find_line"',$p' $find_file) + IFS="$orig_IFS" fi - count=-1 - while IFS= read -r line_reg ; do - ((count++)) - if [[ $line_reg =~ $name_for_find ]] ; then - find_number_line=$(( count + find_line )) - find_check_file=1 - break + if [[ $1 == --add ]] ; then + if [[ -z $find_block ]] ; then + if [[ -n $name_for_new_block ]] ; then + sed -i '$a\\n'"${name_block_old//\\/\\\\}" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/$name_for_new_block.reg" + find_file=${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/$name_for_new_block.reg + find_line=$(wc -l "$find_file" | awk -F" " '{print $1}') + find_line=$(( find_line - 1 )) + else + print_error "$name_block_old not found in reg files" + return 1 + fi fi - [[ -z $line_reg ]] && break - done <<< $(sed -n "$find_line"',$p' $find_file) - IFS="$orig_IFS" - if [[ $name_for_set =~ ^[0-9]+$ ]] ; then - name_for_set=$(convert_dec_and_hex --dec "$name_for_set") - fi - if [[ ${name_for_set,,} =~ ^[a-z]+$ ]] ; then - if [[ $find_check_file == 1 ]] ; then - sed -i "${find_number_line}s/$name_for_find.*/$name_for_find\"$name_for_set\"/" "$find_file" + if [[ $name_for_set =~ ^[0-9]+$ ]] ; then + name_for_set=$(convert_dec_and_hex --dec "$name_for_set") + fi + if [[ ! $name_for_set =~ ^[0-9]+$ ]] ; then + if [[ $find_check_file == 1 ]] ; then + sed -i "${find_number_line}s/$name_for_find.*/$name_for_find\"$name_for_set\"/" "$find_file" + else + print_info "Added ${name_for_find//=*} to reg file" + sed -i "$(( find_line + 1 ))"'a\\n'"$name_for_find\"$name_for_set\"" "$find_file" + fi else - print_info "Added ${name_for_find//=*} to reg file" - sed -i "$(( find_line + 1 ))a$name_for_find\"$name_for_set\"" "$find_file" - fi - else - if [[ $find_check_file == 1 ]] ; then - sed -i "${find_number_line}s/$name_for_find.*/$name_for_find$name_for_set/" "$find_file" - else - print_info "Added ${name_for_find//=*} to reg file" - sed -i "$(( find_line + 1 ))a$name_for_find$name_for_set" "$find_file" + if [[ $find_check_file == 1 ]] ; then + sed -i "${find_number_line}s/$name_for_find.*/$name_for_find$name_for_set/" "$find_file" + else + print_info "Added ${name_for_find//=*} to reg file" + sed -i "$(( find_line + 1 ))"'a\\n'"$name_for_find$name_for_set" "$find_file" + fi fi + elif [[ $1 == --delete ]] ; then + [[ $find_check_file != 1 ]] && return 0 + print_info "Delete ${name_for_find//=*} to reg file" + sed -i "${find_number_line}d" "$find_file" fi } @@ -3610,39 +3618,28 @@ start_portwine () { fi if [[ "$PW_DINPUT_PROTOCOL" == "1" ]] ; then - get_and_set_reg_file '[System\\CurrentControlSet\\Services\\winebus]' '"DisableHidraw"=dword:' "0" - get_and_set_reg_file '[System\\CurrentControlSet\\Services\\winebus]' '"Enable SDL"=dword:' "0" + get_and_set_reg_file --add '[System\\CurrentControlSet\\Services\\winebus]' '"DisableHidraw"=dword:' "0" + get_and_set_reg_file --add '[System\\CurrentControlSet\\Services\\winebus]' '"Enable SDL"=dword:' "0" else - get_and_set_reg_file '[System\\CurrentControlSet\\Services\\winebus]' '"DisableHidraw"=dword:' "1" - get_and_set_reg_file '[System\\CurrentControlSet\\Services\\winebus]' '"Enable SDL"=dword:' "1" + get_and_set_reg_file --add '[System\\CurrentControlSet\\Services\\winebus]' '"DisableHidraw"=dword:' "1" + get_and_set_reg_file --add '[System\\CurrentControlSet\\Services\\winebus]' '"Enable SDL"=dword:' "1" fi if [[ "$PW_WINE_DPI_VALUE" != "disabled" ]] ; then - get_and_set_reg_file '[Control Panel\\Desktop]' '"LogPixels"=dword:' "${PW_WINE_DPI_VALUE// (*/}" + get_and_set_reg_file --add '[Control Panel\\Desktop]' '"LogPixels"=dword:' "${PW_WINE_DPI_VALUE// (*/}" fi - WINE_WAYLAND_VAR="$(grep "x11,wayland" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/user.reg")" - if [[ "${PW_USE_NATIVE_WAYLAND}" == "1" ]] ; then - if [[ ! "$WINE_WAYLAND_VAR" ]] ; then - print_info "Enable experimental Wayland support" - ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ - "${WINELOADER}" reg add "HKEY_CURRENT_USER\Software\Wine\Drivers" /v "Graphics" /t REG_SZ /d "x11,wayland" /f - wait_wineserver - fi + if [[ "$PW_USE_NATIVE_WAYLAND" == "1" ]] ; then export PW_DISPLAY="env DISPLAY=" export PW_USE_RUNTIME="0" + get_and_set_reg_file --add '[Software\\Wine\\Drivers]' '"Graphics"=' "x11,wayland" "user" else unset PW_DISPLAY - if [[ "$WINE_WAYLAND_VAR" ]] ; then - print_info "Disable experimental Wayland support" - ${pw_runtime} LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \ - "${WINELOADER}" reg delete "HKEY_CURRENT_USER\Software\Wine\Drivers" /v "Graphics" /f - wait_wineserver - fi + get_and_set_reg_file --delete '[Software\\Wine\\Drivers]' '"Graphics"=' "x11,wayland" fi - if [[ "${PW_SOUND_DRIVER_USE}" != "disabled" ]] ; then - get_and_set_reg_file '[Software\\Wine\\Drivers]' '"Audio"=' "$PW_SOUND_DRIVER_USE" "user" + if [[ "$PW_SOUND_DRIVER_USE" != "disabled" ]] ; then + get_and_set_reg_file --add '[Software\\Wine\\Drivers]' '"Audio"=' "$PW_SOUND_DRIVER_USE" "user" fi pw_stop_progress_bar &&