#!/bin/bash help() { cat < $CONTAINER_PATH/scale.txt wine_scale=`cat $CONTAINER_PATH/scale.txt` echo "检测到的缩放倍数为:$wine_scale" echo "Scale is $wine_scale" fi else wine_scale=`cat $CONTAINER_PATH/scale.txt` echo "检测到的缩放倍数为:$wine_scale" echo "Scale is $wine_scale" fi #####非deepin发行版似乎没有这个变量,暂时不清楚这个变量是哪个组件做的 else #######指定了缩放倍数 echo "使用了--set-scale-factor,直接指定" echo "--set-scale-factor detected. Arrange directly" if [ "$appointed_scale_factor" != "1.0" ] && [ "$appointed_scale_factor" != "1.25" ] && [ "$appointed_scale_factor" != "1.5" ] && [ "$appointed_scale_factor" != "1.75" ] && [ "$appointed_scale_factor" != "2.0" ] ;then echo "无法识别的倍数:$appointed_scale_factor,请参看$0 -h" echo "Unrecognizable number. Use $0 -h to get help" exit 1 fi #######没问题了再用 echo "$appointed_scale_factor" > $CONTAINER_PATH/scale.txt wine_scale=`cat $CONTAINER_PATH/scale.txt` fi ########开始设置 ########如果环境变量里没指定了APPRUN_CMD(在run.sh中)就替换,如果有就直接用来设置 if [ "$APPRUN_CMD" = "" ];then echo "没有检测到APPRUN_CMD环境变量,执行sed替换。如果要使用wine原生提供的方法,请在环境变量中指定(export)" case "$wine_scale" in 1.0*) reg_text="\"LogPixels\"=dword:00000060" ;; 1.25*) reg_text="\"LogPixels\"=dword:00000078" ;; 1.5*) reg_text="\"LogPixels\"=dword:00000090" ;; 1.75*) reg_text="\"LogPixels\"=dword:000000A8" ;; 2.0*) reg_text="\"LogPixels\"=dword:000000C0" ;; *) reg_text="\"LogPixels\"=dword:00000060" #可能不是Xorg ;; esac #####根据scale设置dword值 LogPixels_line=(`sed -n -e "/"LogPixels"/=" $CONTAINER_PATH/user.reg`) #####关键词行数取得 until [ "${#LogPixels_line[@]}" = "0" ];do line_num=${LogPixels_line[0]} sed -i "$line_num"c\ "$reg_text" "$CONTAINER_PATH/user.reg" LogPixels_line=(${LogPixels_line[@]:1}) done echo "已经完成替换。位置:$CONTAINER_PATH/user.reg" echo "在以下行数进行了替换,内容为$reg_text" echo `sed -n -e "/"LogPixels"/=" $CONTAINER_PATH/user.reg` echo "---------------------------------------" else #####用wine提供的方法 case "$wine_scale" in 1.0*) dpi="96" ;; 1.25*) dpi="120" ;; 1.5*) dpi="144" ;; 1.75*) dpi="168" ;; 2.0*) dpi="192" ;; *) dpi="96" #可能不是Xorg或者是其他错误 ;; esac echo "用$APPRUN_CMD执行指令" echo "指令为" echo "env WINEPREFIX="$CONTAINER_PATH" $APPRUN_CMD reg ADD 'HKCU\Control Panel\Desktop' /v LogPixels /t REG_DWORD /d $dpi /f" env WINEPREFIX="$CONTAINER_PATH" $APPRUN_CMD reg ADD 'HKCU\Control Panel\Desktop' /v LogPixels /t REG_DWORD /d $dpi /f fi