Commit 33064681 authored by Vladislav's avatar Vladislav

Added --add and --delete args for reg func

parent 6393c6f5
...@@ -1125,58 +1125,66 @@ combobox_fix () { ...@@ -1125,58 +1125,66 @@ combobox_fix () {
} }
get_and_set_reg_file () { 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 local line_reg find_number_line find_check_file name_for_set name_block_old
name_block=$1 name_block=$2
name_for_find=$2
name_for_set=$3
name_block_old=$name_block 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//\[/\\[} 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 if [[ -n $find_block ]] ; then
find_file=${find_block//:*/} find_file=${find_block//:*/}
find_line=${find_block//$find_file:/} find_line=${find_block//$find_file:/}
find_line=${find_line//:*/} find_line=${find_line//:*/}
else count=-1
if [[ -n $4 ]] ; then while IFS= read -r line_reg ; do
sed -i '$a\\n'"${name_block_old//\\/\\\\}" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/$4.reg" ((count++))
find_file=${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/$4.reg if [[ $line_reg =~ $name_for_find ]] ; then
find_line=$(wc -l "$find_file" | awk -F" " '{print $1}') find_number_line=$(( count + find_line ))
else find_check_file=1
print_error "$name_block_old not found in reg files" break
return 1 fi
fi [[ -z $line_reg ]] && break
done <<< $(sed -n "$find_line"',$p' $find_file)
IFS="$orig_IFS"
fi fi
count=-1 if [[ $1 == --add ]] ; then
while IFS= read -r line_reg ; do if [[ -z $find_block ]] ; then
((count++)) if [[ -n $name_for_new_block ]] ; then
if [[ $line_reg =~ $name_for_find ]] ; then sed -i '$a\\n'"${name_block_old//\\/\\\\}" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/$name_for_new_block.reg"
find_number_line=$(( count + find_line )) find_file=${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/$name_for_new_block.reg
find_check_file=1 find_line=$(wc -l "$find_file" | awk -F" " '{print $1}')
break find_line=$(( find_line - 1 ))
else
print_error "$name_block_old not found in reg files"
return 1
fi
fi fi
[[ -z $line_reg ]] && break if [[ $name_for_set =~ ^[0-9]+$ ]] ; then
done <<< $(sed -n "$find_line"',$p' $find_file) name_for_set=$(convert_dec_and_hex --dec "$name_for_set")
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 fi
else if [[ ! $name_for_set =~ ^[0-9]+$ ]] ; then
if [[ $find_check_file == 1 ]] ; then if [[ $find_check_file == 1 ]] ; then
sed -i "${find_number_line}s/$name_for_find.*/$name_for_find$name_for_set/" "$find_file" 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 else
print_info "Added ${name_for_find//=*} to reg file" if [[ $find_check_file == 1 ]] ; then
sed -i "$(( find_line + 1 ))a$name_for_find$name_for_set" "$find_file" 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 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 fi
} }
...@@ -3610,39 +3618,28 @@ start_portwine () { ...@@ -3610,39 +3618,28 @@ start_portwine () {
fi fi
if [[ "$PW_DINPUT_PROTOCOL" == "1" ]] ; then if [[ "$PW_DINPUT_PROTOCOL" == "1" ]] ; then
get_and_set_reg_file '[System\\CurrentControlSet\\Services\\winebus]' '"DisableHidraw"=dword:' "0" get_and_set_reg_file --add '[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]' '"Enable SDL"=dword:' "0"
else else
get_and_set_reg_file '[System\\CurrentControlSet\\Services\\winebus]' '"DisableHidraw"=dword:' "1" get_and_set_reg_file --add '[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]' '"Enable SDL"=dword:' "1"
fi fi
if [[ "$PW_WINE_DPI_VALUE" != "disabled" ]] ; then 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 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 [[ "${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
export PW_DISPLAY="env DISPLAY=" export PW_DISPLAY="env DISPLAY="
export PW_USE_RUNTIME="0" export PW_USE_RUNTIME="0"
get_and_set_reg_file --add '[Software\\Wine\\Drivers]' '"Graphics"=' "x11,wayland" "user"
else else
unset PW_DISPLAY unset PW_DISPLAY
if [[ "$WINE_WAYLAND_VAR" ]] ; then get_and_set_reg_file --delete '[Software\\Wine\\Drivers]' '"Graphics"=' "x11,wayland"
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
fi fi
if [[ "${PW_SOUND_DRIVER_USE}" != "disabled" ]] ; then if [[ "$PW_SOUND_DRIVER_USE" != "disabled" ]] ; then
get_and_set_reg_file '[Software\\Wine\\Drivers]' '"Audio"=' "$PW_SOUND_DRIVER_USE" "user" get_and_set_reg_file --add '[Software\\Wine\\Drivers]' '"Audio"=' "$PW_SOUND_DRIVER_USE" "user"
fi fi
pw_stop_progress_bar && pw_stop_progress_bar &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment