added reg func and hack for XRDP

This commit is contained in:
Mikhail Tergoev 2025-04-14 12:47:19 +03:00
parent b43ca4d712
commit b9bb948738

@ -647,6 +647,105 @@ init_wine_ver () {
}
##### INITIAL WINEPREFIX SETTINGS #####
get_and_set_reg_file () {
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
}
local name_block name_for_find find_block find_file find_line count name_for_new_block name_for_find_old
local line_reg find_number_line find_check_file name_for_set name_type_reg name_fatal name_add_or_del
name_add_or_del=$1
name_block=$2
name_for_find=$3
name_type_reg=$4
name_for_set=$5
name_for_new_block=$6
name_for_find_old=$name_for_find
name_fatal="$name_block $name_for_find"
case $name_type_reg in
REG_DWORD)
name_for_find="\"$name_for_find\"=dword:"
name_for_set=$(convert_dec_and_hex --dec "$name_for_set") ;;
REG_SZ)
name_for_find="\"$name_for_find\"="
name_for_set="\"$name_for_set\"" ;;
*)
if [[ $name_add_or_del == --delete ]] ; then
name_for_find="\"$name_for_find\""
else
print_error "не задан тип ветки реестра: $name_fatal"
return 1
fi ;;
esac
name_block=${name_block//\\/\\\\\\\\}
if [[ -n $name_for_new_block ]] ; then
find_block=$(grep -n "\[$name_block\]" "$WINEPREFIX/$name_for_new_block.reg")
else
find_block=$(grep -n "\[$name_block\]" "$WINEPREFIX/"*.reg)
fi
if [[ -n $find_block ]] ; then
if [[ -n $name_for_new_block ]] ; then
find_file="$WINEPREFIX/$name_for_new_block.reg"
find_line=${find_block//:*/}
else
find_file=${find_block//:*/}
find_line=${find_block//$find_file:/}
find_line=${find_line//:*/}
fi
count=-1
while read -r line_reg ; do
((count++))
if [[ $line_reg =~ $name_for_find ]] ; then
if [[ $line_reg == $name_for_find$name_for_set ]] ; then
return 0
fi
find_number_line=$(( count + find_line ))
find_check_file=1
break
fi
[[ -z $line_reg ]] && break
done <<< "$(sed -n "$find_line"',$p' "$find_file")"
fi
if [[ $name_add_or_del == --add ]] ; then
if [[ -z $find_block ]] ; then
if [[ -n $name_for_new_block ]] ; then
sed -i '$a\\n'\["$name_block"\] "$WINEPREFIX/$name_for_new_block.reg"
find_file="$WINEPREFIX/$name_for_new_block.reg"
find_line=$(wc -l "$find_file" | awk -F" " '{print $1}')
find_line=$(( find_line - 1 ))
else
print_error "$name_fatal не найден в файле реестра"
return 1
fi
fi
if [[ $find_check_file == 1 ]] ; then
print_info "Меняем $name_for_find_old в файле реестра"
sed -i "${find_number_line}s|$name_for_find.*|$name_for_find$name_for_set|" "$find_file"
else
print_info "Добавляем $name_for_find_old в файл реестра"
sed -i "$(( find_line + 1 ))a$name_for_find$name_for_set" "$find_file"
fi
elif [[ $name_add_or_del == --delete ]] ; then
[[ $find_check_file != 1 ]] && return 0
print_info "Удаляем $name_for_find_old из файла реестра"
sed -i "${find_number_line}d" "$find_file"
fi
}
wait_wineserver () {
# while [[ -n "$(ls -l /proc/*/exe 2>/dev/null | grep -ie portproton | grep -E 'wine(64)?-preloader|wineserver' | awk -F/ '{print $3}')" ]] ; do
# sleep 1
@ -726,6 +825,16 @@ init_wineprefix () {
fi
try_remove_file "$DRIVE_C/windows/system32/winemenubuilder.exe"
# хак для XRDP сессии
if [[ $DISPLAY == *:10.0 ]] ; then
print_warning "Обнаружена сессия XRDP, настраиваем реестр:"
get_and_set_reg_file --add 'Software\Wine\X11 Driver' 'UseXRandR' 'REG_SZ' "N" "user"
get_and_set_reg_file --add 'Software\Wine\X11 Driver' 'UseXVidMode' 'REG_SZ' "N" "user"
else
get_and_set_reg_file --delete 'Software\Wine\X11 Driver' 'UseXRandR'
get_and_set_reg_file --delete 'Software\Wine\X11 Driver' 'UseXVidMode'
fi
}
##### KILL AUTOSTART AFTER INSTALLING #####