初步实现高级打包器脚本文件的抽离(未测试可用性)

This commit is contained in:
2024-08-03 08:42:53 +08:00
parent 81576681e8
commit 9ae95d6008
65 changed files with 605 additions and 880 deletions

View File

@@ -0,0 +1,36 @@
#!/bin/bash
source $(dirname $0)/log-function.bashimport
Get_Dist_Name()
{
if grep -Eqii "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then
DISTRO='Deepin'
elif grep -Eqi "UnionTech" /etc/issue || grep -Eq "UnionTech" /etc/*-release; then
DISTRO='UniontechOS'
elif grep -Eqi "UOS" /etc/issue || grep -Eq "UOS" /etc/*-release; then
DISTRO='UniontechOS'
else
DISTRO='OtherOS'
fi
}
Get_Dist_Name
## 1. If WINEPREFIX is not set, use ~/.wine
if [ "$WINEPREFIX" = "" ];then
export WINEPREFIX=$HOME/.wine
fi
if [ "$DISTRO" != "Deepin" ] && [ "$DISTRO" != "UniontechOS" ];then
log.warn "WARNING:USING BOX64 INSTEAD OF DEEPIN-BOX64,SOME APP MAY FAIL TO LAUNCH"
spark-box64 /opt/deepin-wine8-stable/bin/wine "$@"
else
deepin-wine8-stable "$@"
fi

View File

@@ -0,0 +1,39 @@
# ===== Log =====
# log.info xxx
# log.warn xxx
# log.info xxx
# log.debug xxx
# 带颜色的echo
function log.color_output() {
local color=$1
shift 1
echo >&2 -e "\033[${color}m$@\033[0m"
return 0
}
# Log is named without prefix "utils." for convenience
# Usage: log.log <level> ...content
function log.log() {
if [[ $# < 2 ]]; then
return -1
fi
local level=$1
shift 1
case $level in
error) log.color_output "0;31" "[ERROR] $@" ;;
warn) log.color_output "1;33" "[WARN] $@" ;;
info) log.color_output "1;37" "[INFO] $@" ;;
debug) log.color_output "1;30" "[DEBUG] $@" ;;
esac
return 0
}
function log.error() { log.log "error" "$@"; }
function log.warn() { log.log "warn" $@; }
function log.info() { log.log "info" $@; }
function log.debug() { log.log "debug" $@; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

View File

@@ -0,0 +1,127 @@
#!/usr/bin/env python3
import os
import sys
import time
import subprocess
import threading
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
def check_window():
# 使用 wmctrl 命令列出所有窗口,并使用 grep 过滤出特定的 WMCLASS
windows = subprocess.getoutput(f'wmctrl -lx | grep "{target_wmclass}"')
# 如果窗口存在,则关闭提示
if windows.replace("\n", "").replace(" ", "") != "":
# 提取窗口ID
window_id = windows.replace(" ", " ").split(" ")[0]
print(f"Window with WMCLASS '{target_wmclass}' found")
return 1
# else:
# print(f"Window with WMCLASS '{target_wmclass}' not found.")
def check_wmclass():
if timeout:
time.sleep(timeout)
window.close()
return
# 循环检测窗口是否存在的函数
# 每隔一段时间检测一次窗口是否存在
showtimeout = 20 # 为防止因为应用无法打开而无法正常关闭窗口,于是设置 time out
while True:
if check_window():
break
# 等待一段时间后再次检测
time.sleep(1)
AppInfoShowerRefresh()
showtimeout -= 1
if showtimeout <= 0:
break
window.close()
timeout = 0
if os.getenv("WAYLAND_DISPLAY"):
timeout = 3
if os.system("which wmctrl"):
print("No wmctrl installed. Do not check wmclass")
timeout = 3
target_wmclass = os.getenv("WINE_WMCLASS")
def GetRecommendWindowSize(window: QMainWindow):
# 计算屏幕分辨率
screen = QGuiApplication.primaryScreen()
width = screen.geometry().width()
height = screen.geometry().height()
# 如果为竖状屏幕
if width < height:
temp = height
height = width
width = temp
return [int(width / 4), window.geometry().height()]
def SetWindowSize(window: QMainWindow):
# 计算比例
size = GetRecommendWindowSize(window)
window.resize(size[0], size[1])
def MoveCenter(window: QMainWindow):
# 计算屏幕分辨率
screen = QGuiApplication.primaryScreen()
width = screen.geometry().width()
height = screen.geometry().height()
print(window.geometry().height())
# 计算窗口坐标
window.move(int(width / 2 - window.geometry().width() / 2),
int(height / 2.8 - window.geometry().height() / 2)
)
def AppInfoShowerRefresh():
global appInfoShowerTime
appInfoShower.setText(f"<h3 align='center'>星火Windows应用兼容助手</h3><p align='center'>正在为您启动以下应用:{os.getenv('WINE_APP_NAME')} {'.' * (appInfoShowerTime % 3 + 1)}</p>")
appInfoShowerTime += 1
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
app = QApplication(sys.argv)
# 构建窗口
window = QMainWindow()
widget = QWidget()
layout = QGridLayout()
appInfoShower = QLabel()
appInfoShowerTime = 0
AppInfoShowerRefresh()
# GXDE 彩蛋
if os.path.exists("/usr/share/gxde-resources/spark-dwine-helper.png"):
backgroundImgPath = "/usr/share/gxde-resources/spark-dwine-helper.png"
##########
if os.path.exists(f"{programPath}/fallback.png"):
backgroundImgPath = f"{programPath}/fallback.png"
if os.path.exists(f"/opt/apps/{os.getenv('DEB_PACKAGE_NAME')}/files/banner.png"):
backgroundImgPath = f"/opt/apps/{os.getenv('DEB_PACKAGE_NAME')}/files/banner.png"
window.setWindowTitle("星火Windows应用兼容助手")
layout.addWidget(QLabel(f""), 1, 0)
layout.addWidget(appInfoShower, 2, 0)
layout.addWidget(QLabel(f"<hr>由 Wine 运行器提供支持"), 4, 0)
widget.setLayout(layout)
window.setCentralWidget(widget)
window.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint)
MoveCenter(window)
SetWindowSize(window)
window.show()
layout.addWidget(QLabel(f"<p align='center'><img width='{window.geometry().width()}' src='{backgroundImgPath}'></p>"), 0, 0)
threading.Thread(target=check_wmclass).start()
MoveCenter(window)
app.exec_()

View File

@@ -0,0 +1,92 @@
___
( )
| | .-. ___ ___ .--. .--.
| |/ \ ( )( ) / \ / \
| .-. . | | | | ; ,-. ' | .-. ;
| | | | | | | | | | | | | | | |
| | | | | | | | | | | | | |/ |
| | | | | | | | | | | | | ' _.'
| | | | | | ; ' | ' | | | .'.-.
| | | | ' `-' / ' `-' | ' `-' /
(___)(___) '.__.' `.__. | `.__.'
( `-' ;
`.__.
___
( )
| |.-. .---. ___ .-. .--. ___ .-.
| / \ / .-, \ ( ) \ / \ ( ) \
| .-. | (__) ; | | ' .-. ; | .-. ; | .-. .
| | | | .'` | | / (___) | | | | | | | |
| | | | / .'| | | | | | | | | | | |
| | | | | / | | | | | | | | | | | |
| ' | | ; | ; | | | | ' | | | | | |
' `-' ; ' `-' | | | ' `-' / | | | |
`.__. `.__.'_. (___) `.__.' (___)(___)
___
( )
| |.-. ___ ___ ___ .-. ___ .-. ___ ___
| / \ ( )( ) ( ) \ ( ) \ ( )( )
| .-. | | | | | | .-. . | .-. . | | | |
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | ' | |
| | | | | | | | | | | | | | | | ' `-' |
| ' | | | | ; ' | | | | | | | | `.__. |
' `-' ; ' `-' / | | | | | | | | ___ | |
`.__. '.__.' (___)(___) (___)(___) ( )' |
; `-' '
.__.'
............ .....]OOOo]`....
... ........ ...=OOOOOOOOO\..
.../OOOOOOO`.... ..=OOO@/[\OOOOO.
..=OOOOOOOOO\... .,@OO^/....O@O@`
..OOOOOO[[OOO@`. .=OO@,...=.OOOO.
..OOOOO./O^,@OO` .=OO^....,.@OO^.
..\OOO@^...=OOOO.... .OOO^*..,`/OOO..
...\OOOOOOOooooO^... .=OO^...`=OO@`..
..=@O@OooOOOOO@`...........=@@O]].,@O@`...
.,@OoOO`...O@^......,]]]]/OOOOOOO@@... .
...\OO@]]]OOOO@@@@@@@@@@@@@@@@@@@OO.....
.....[@@OOO@@@@@@@@@@@@@@@@@@@@@@@@@@`..
..OOO@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`....
.,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\...
....=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@^..
...=@@@@@@@@@@@@@@@@@@@@@@`,\@@@@@@@@@@@@@^.
..,@@@@@@@@@@@@@@@@@@@@@@@O,[].\@@@@@@@@@@@.
../@@@@@@@@@@@@O@@@@@@@@@@@......\@@@@@@@@@^
.,@@@@@@@@@@@O`.\@@@@@@@@@/........\@@@@@@@@...
.=@@@@@@@@@/.....\@@@@@@@@/`...[O`..\@@@@@@@`...
.=@@@@@@@^,O[..,`.,@@@@@/../@@O[`...,@@@@@@@....
....@@@@@@@O`,@@O[]..,@/[`..=oo@O`,^...@@@@@@@@`..
....O@@@@@@@@`,OOO@^*\.........\..../.../@`.=^..
.. ...,@^=@@@^.\`...,^...........[[......O]//...
..,\]@@@\...[`....................=@@/....
.=@@\............,]/`........../@@@\.. .
.....@@@@@\.....................,/@@@@@@\...
...=@@@@@@@@\]..............]@@@@@@@@@@@@`.
...,@@@@@@@@@@@@@@/[\O@@O/[*./@@@@@@@@@@@@@\.......
...@@@@@@@@@@@@@@@^.,O@@@@^../@@@@@@@@@@@@@@@\.....
..........@@@@@@@@@@@@@@@@@`..`\/`../@@@@@@@@@@@@@@@@@@@@]]
........,@@@@@@@@@@@@@@@@/*[\].,`]/[[@@@@@@@@@@@@@@,[[[[`..
..,O\/@@@@@@@@@@@@@@@@@@@`...........O@@O@@@@@@@@@@\....
.....\@@@@@@@@@@@@@@@@@@@OO\`,O.. .,@OOO@@@@@@@@@@. ..
..../@@@@@@@@@@@@@@OO@`.^,O. ..=@OOO@@@@@@@@@.. .
...=@@@@@@@@@@@@@@@@@O[[.... ...\@@@@@@@@@@@/.. .
...=@@@@@@@@@@@@@@,^ ....O...\@@@@@@`
....@@@@@@@@@@@@@/.. ...^/\]/[\@@@@`.
.@@@@/@@@@@@@^O..... ...,@@^]..]@/...
...\@`.[@@@@@@...... .=`@@@@@^..^....
....`....[@@@O\.[,..........OO@@@@@^.,[[....
............\@@@\`...,`**,]@@@@@@@^.........
.. .,@@@@@@@@@@@@@@@@@@/...
..O@@@@@@@@@@@@@@@@@^...
..O@@@@@@^...=@@@@@@@...
..@@@@@@@\...=@@@@@@@^..
.=@@@@@@@@...=@@@@@@@O..
.=@@@@@@@@`..=@@@@@@@@..
.=@@@O@@@@^..=@@OO@@@@^.
.O@OOOOO@O^..=@OOOOOOO^.
.Oo/[\O/\O@..=/[\O/\o*O.
.O^......=O...^......*/.
.=\.....]O^...\\...]//.. .. ........

View File

@@ -0,0 +1,86 @@
#/bin/bash
source ${SHELL_DIR}/bashimport/transhell.bashimport
load_transhell_debug
#########>>>>>>>函数段
Get_Dist_Name()
{
if grep -Eqii "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then
DISTRO='Deepin'
elif grep -Eqi "UnionTech" /etc/issue || grep -Eq "UnionTech" /etc/*-release; then
DISTRO='UniontechOS'
elif grep -Eqi "UOS" /etc/issue || grep -Eq "UOS" /etc/*-release; then
DISTRO='UniontechOS'
else
DISTRO='OtherOS'
fi
}
#########<<<<<<<
if [ $# -lt 1 ]; then
echo "无参数无法启动。这是一个set-wine-scale的组件一般来说你不会需要单独启动这个脚本"
echo "请参考set-wine-scale.sh使用"
echo "参数为CONTAINER_PATH"
echo "只读取第一个,其他参数会被放弃"
fi
CONTAINER_PATH="$1"
if [ ! -f "$CONTAINER_PATH/user.reg" ];then
echo "错误找不到user.reg退出。你应当在文件解压结束后调用此脚本"
echo "E: Can not find user.reg. Exit. You should use this script after the extraction"
exit 1
fi
mkdir -p $HOME/.config/spark-wine/
#####全局参数位置
#####能到这一步的说明已经是没有自定义参数了,直接读全局覆盖没问题
#####
if [ -f "$HOME/.config/spark-wine/scale.txt" ];then
cat $HOME/.config/spark-wine/scale.txt > $CONTAINER_PATH/scale.txt
echo "检测到已经设置过全局参数,直接复制"
echo "全局参数的位置在$HOME/.config/spark-wine/scale.txt如果需要更换请删除此文件重新生成"
exit
fi
Get_Dist_Name
if [ "$DISTRO" = "UniontechOS" ];then
echo 1.0 > $HOME/.config/spark-wine/scale.txt
cat $HOME/.config/spark-wine/scale.txt > $CONTAINER_PATH/scale.txt
#####就是1倍缩放
exit
fi
dimensions=`xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/'`
scale_factor=`zenity --list \
--width=700 \
--height=350 \
--title="${TRANSHELL_CONTENT_YOUR_DIMENSION_IS} $dimensions ${TRANSHELL_CONTENT_PLEASE_CHOOSE_ONE_BELOW}" \
--column="${TRANSHELL_CONTENT_OPTION}" \
1.0 \
1.25 \
1.5 \
1.75 \
2.0 \
2.5 \
3.0 \
3.5 \
4.0`
case "$scale_factor" in
"")
zenity --info --text="${TRANSHELL_CONTENT_1_SCALE_AS_DEFAULT}${TRANSHELL_CONTENT_YOU_CAN_USE_SPARK_WINE_HELPER_SETTINGS_TO_ADJUST}" --width=500 --height=150
scale_factor="1.0"
;;
*)
zenity --info --text="${TRANSHELL_CONTENT_SCALE_IS} $scale_factor ${TRANSHELL_CONTENT_SAVED}${TRANSHELL_CONTENT_YOU_CAN_USE_SPARK_WINE_HELPER_SETTINGS_TO_ADJUST}" --width=500 --height=150
;;
esac
echo "$scale_factor" > $HOME/.config/spark-wine/scale.txt
cat $HOME/.config/spark-wine/scale.txt > $CONTAINER_PATH/scale.txt

View File

@@ -0,0 +1,210 @@
#!/bin/bash
help() {
cat <<EOF
用法:$0 [-h|--help] [-s|--set-scale-factor] path
-h|--help 显示这个帮助
-s|--set-scale-factor 直接指定缩放。支持1.01.251.51.752.0,2.5,3.0,3.5,4.0
path 容器目录
本脚本具有超级兔力。
--------------------------------------------------------------------
Usage: $0 [-h|--help] [-s|--set-scale-factor] path
-h|--help Show this text
-s|--set-scale-factor Set scale factor direcly. Support 1.01.251.51.752.0,2.5,3.0,3.5,4.0
path Wine Container directory path
This script have super bunny power.
EOF
}
#########################帮助文件结束#############################
parse_args() {
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
help
exit
;;
-s|--set-scale-factor)
appointed_scale_factor="$2"
;;
"bunny")
cat ${SHELL_DIR}/spark-dwine-helper/scale-set-helper/bunny.txt
exit
;;
*)
CONTAINER_PATH="$1"
;;
esac
shift
done
}
################
parse_args "$@"
#####先看看PATH对不对
if [ ! -f "$CONTAINER_PATH/user.reg" ];then
echo "错误找不到user.reg退出。你应当在文件解压结束后调用此脚本。"
echo "如果你不清楚如何使用这个脚本,请使用 $0 -h"
echo "E: Can not find user.reg. Exit. You should use this script after the extraction"
echo "If you don't know how to use this script, try $0 -h"
exit 1
fi
if [ "$appointed_scale_factor" = "" ];then
#########未指定下,读取$CONTAINER_PATH/scale.txt。如果没有优先$DEEPIN_WINE_SCALE设置然后是手动
if [ ! -f "$CONTAINER_PATH/scale.txt" ];then
echo "E: No SCALE profile found. try to use DEEPIN_WINE_SCALE"
echo "错误没有检测到缩放设置读取DEEPIN_WINE_SCALE"
if [ "$DEEPIN_WINE_SCALE" = "" ];then
echo "E: No DEEPIN_WINE_SCALE found. Use get-scale.sh to Set "
echo "错误没有检测到DEEPIN_WINE_SCALE用get-scale.sh设置"
${SHELL_DIR}/spark-dwine-helper/scale-set-helper/get-scale.sh "$CONTAINER_PATH"
wine_scale=`cat $CONTAINER_PATH/scale.txt`
echo "检测到的缩放倍数为:$wine_scale"
echo "Scale is $wine_scale"
else
echo "$DEEPIN_WINE_SCALE" > $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" ] && [ "$appointed_scale_factor" != "2.5" ] && [ "$appointed_scale_factor" != "3.0" ] && [ "$appointed_scale_factor" != "3.5" ] && [ "$appointed_scale_factor" != "4.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"
;;
2.5*)
reg_text="\"LogPixels\"=dword:000000F0"
;;
3.0*)
reg_text="\"LogPixels\"=dword:00000120"
;;
3.5*)
reg_text="\"LogPixels\"=dword:00000150"
;;
4.0*)
reg_text="\"LogPixels\"=dword:00000180"
;;
*)
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"
;;
2.5*)
dpi="240"
;;
3.0*)
dpi="288"
;;
3.5*)
dpi="336"
;;
4.0*)
dpi="384"
;;
*)
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

View File

@@ -0,0 +1,8 @@
#!/bin/bash
TRANSHELL_CONTENT_OPTION="Options"
TRANSHELL_CONTENT_YOUR_DIMENSION_IS="Your dimension is "
TRANSHELL_CONTENT_PLEASE_CHOOSE_ONE_BELOW="Please choose one option below"
TRANSHELL_CONTENT_1_SCALE_AS_DEFAULT="Setting 1.0 scale as default"
TRANSHELL_CONTENT_SCALE_IS="Scale multiple is "
TRANSHELL_CONTENT_SAVED="saved."
TRANSHELL_CONTENT_YOU_CAN_USE_SPARK_WINE_HELPER_SETTINGS_TO_ADJUST="You can use spark wine helper settings to adjust settings"

View File

@@ -0,0 +1,8 @@
#!/bin/bash
TRANSHELL_CONTENT_OPTION="选项"
TRANSHELL_CONTENT_YOUR_DIMENSION_IS="您的分辨率是:"
TRANSHELL_CONTENT_PLEASE_CHOOSE_ONE_BELOW="请在以下选项中选择一个"
TRANSHELL_CONTENT_1_SCALE_AS_DEFAULT="默认为1倍缩放。"
TRANSHELL_CONTENT_SCALE_IS="缩放倍数为"
TRANSHELL_CONTENT_SAVED="已保存"
TRANSHELL_CONTENT_YOU_CAN_USE_SPARK_WINE_HELPER_SETTINGS_TO_ADJUST="您可以使用星火wine助手设置来重新设置"

View File

@@ -0,0 +1,201 @@
#!/bin/bash
SHELL_DIR=$(dirname $(realpath $0))
# 函数:获取所有应用列表
# 函数:获取所有应用列表
get_apps_list() {
local apps_list=()
local app_dirs=($(find /opt/apps -mindepth 1 -maxdepth 1 -type d -exec test -f {}/files/run.sh \; -print))
if [ ${#app_dirs[@]} -eq 0 ]; then
zenity --error --text="请至少在应用商店安装一个wine应用后启动" --width 200
exit 1
fi
for app_dir in "${app_dirs[@]}"; do
local package_name=$(basename "$app_dir")
local run_script="$app_dir/files/run.sh"
local bottle_name="无法读取"
local version="无法读取"
local use_spark="否"
if [ -f "$run_script" ]; then
bottle_name=$(grep -oP 'BOTTLENAME="\K[^"]+' "$run_script")
version=$(grep -oP 'APPVER="\K[^"]+' "$run_script")
if [ -z "$version" ]; then
version="无法读取"
fi
# START_SHELL_PATH=XXX/spark_run_v4.sh
if grep START_SHELL_PATH= "$run_script" | grep spark_run_v4.sh; then
use_spark="是"
fi
fi
local app_name=$(get_app_name "$package_name")
apps_list+=("$app_name" "$package_name" "$bottle_name" "$version" "$use_spark")
done
echo "${apps_list[@]}"
}
# 函数:获取应用名称
get_app_name() {
local app_name_orig=$(grep -m 1 '^Name=' "/usr/share/applications/$1.desktop" | cut -d '=' -f 2)
local app_name_i18n=$(grep -m 1 "^Name\[$LANGUAGE\]\=" "/usr/share/applications/$1.desktop" | cut -d '=' -f 2)
local app_name=""
if [ -z "$app_name_i18n" ]; then
app_name="$app_name_orig"
else
app_name="$app_name_i18n"
fi
echo "$app_name"
}
# 函数:选择应用
select_app() {
local apps_list=($(get_apps_list))
local app=$(zenity --print-column=2 --width=800 --height=600 --list --title="选择应用" --text="选择要执行的应用" --column="应用名" --column="包名" --column="容器名" --column="版本号" --column="是否使用星火wine助手" "${apps_list[@]}")
if [ -n "$app" ]; then
local app_dir="/opt/apps/$app"
local run_script="$app_dir/files/run.sh"
local use_spark="否"
if if grep START_SHELL_PATH= "$run_script" | grep spark_run_v4.sh; then
use_spark="是"
fi
if [ "$use_spark" == "是" ]; then
select_spark_action "$app" "$(get_app_name $app)"
else
select_non_spark_action "$app" "$(get_app_name $app)"
fi
fi
}
select_non_spark_action(){
local app="$1"
local app_name="$2"
local options=("在终端中打开" "打开容器目录" "清理并重置容器目录" "更多操作")
local choice=$(zenity --width=800 --height=600 --list --title="选择操作" --text="选择要对$app_name执行的操作" --column="操作" "${options[@]}")
case "$choice" in
"在终端中打开")
local app_dir="/opt/apps/$app"
local run_script="$app_dir/files/run.sh"
x-terminal-emulator -e "$run_script"
;;
"打开容器目录")
local app_dir="/opt/apps/$app"
local run_script="$app_dir/files/run.sh"
local bottle_name=$(grep -oP 'BOTTLENAME="\K[^"]+' "$run_script")
xdg-open file:///home/$(whoami)/.deepinwine/${bottle_name}
;;
"清理并重置容器目录")
local app_dir="/opt/apps/$app"
local run_script="$app_dir/files/run.sh"
local bottle_name=$(grep -oP 'BOTTLENAME="\K[^"]+' "$run_script")
$SHELL_DIR/../kill.sh ${bottle_name}
rm -rf /home/$(whoami)/.deepinwine/${bottle_name}/*
zenity --info --width=300 --text="操作已完成请重启Wine应用查看"
;;
"更多操作")
if [ -e /usr/bin/deepin-wine-runner ];then
/usr/bin/deepin-wine-runner
elif [ $(command -v spark-store) ];then
spark-store spk://store/tools/spark-deepin-wine-runner
elif [ $(command -v deepin-home-appstore-client) ];then
xdg-open appstore://deepin-home-appstore-client?app_detail_info/spark-deepin-wine-runner
else
xdg-open https://gitee.com/gfdgd-xi/deep-wine-runner/releases
fi
;;
esac
}
# 函数选择星火wine助手操作
select_spark_action() {
local app="$1"
local app_name="$2"
local options=("在终端中打开" "打开容器目录" "清理并重置容器目录" "修改应用缩放" "修改全局缩放" "更多操作")
local choice=$(zenity --width=800 --height=600 --list --title="选择操作" --text="选择要对$app_name执行的操作" --column="操作" "${options[@]}")
case "$choice" in
"在终端中打开")
local app_dir="/opt/apps/$app"
local run_script="$app_dir/files/run.sh"
x-terminal-emulator -e "$run_script"
;;
"打开容器目录")
local app_dir="/opt/apps/$app"
local run_script="$app_dir/files/run.sh"
local bottle_name=$(grep -oP 'BOTTLENAME="\K[^"]+' "$run_script")
xdg-open file:///home/$(whoami)/.deepinwine/${bottle_name}
;;
"清理并重置容器目录")
local app_dir="/opt/apps/$app"
local run_script="$app_dir/files/run.sh"
local bottle_name=$(grep -oP 'BOTTLENAME="\K[^"]+' "$run_script")
$SHELL_DIR/../spark_kill.sh ${bottle_name}
rm -rf /home/$(whoami)/.deepinwine/${bottle_name}/*
zenity --info --width=300 --text="操作已完成请重启Wine应用查看"
;;
"修改应用缩放")
select_scale_action "应用" "$app"
;;
"修改全局缩放")
select_scale_action "全局" "$app"
;;
"更多操作")
if [ -e /usr/bin/deepin-wine-runner ];then
/usr/bin/deepin-wine-runner
elif [ $(command -v spark-store) ];then
spark-store spk://store/tools/spark-deepin-wine-runner
elif [ $(command -v deepin-home-appstore-client) ];then
xdg-open appstore://deepin-home-appstore-client?app_detail_info/spark-deepin-wine-runner
else
xdg-open https://gitee.com/gfdgd-xi/deep-wine-runner/releases
fi
;;
*)
;;
esac
}
# 函数:选择缩放操作
select_scale_action() {
local scale_type="$1"
local app="$2"
local app_dir="/opt/apps/$app"
local run_script="$app_dir/files/run.sh"
local bottle_name=$(grep -oP 'BOTTLENAME="\K[^"]+' "$run_script")
local scale_factors=("1.0" "1.25" "1.5" "1.75" "2.0" "2.5" "3.0" "3.5" "4.0" "恢复默认")
local choice=$(zenity --width=800 --height=600 --list --title="选择缩放比例" --text="选择要设置的缩放比例" --column="比例" "${scale_factors[@]}")
if [ -n "$choice" ]; then
local scale_factor="$choice"
if [ "$scale_type" == "应用" ]; then
if [ "$scale_factor" == "恢复默认" ];then
rm $HOME/.deepinwine/$bottle_name/scale.txt
else
$SHELL_DIR/scale-set-helper/set-wine-scale.sh -s "$scale_factor" "$HOME/.deepinwine/$bottle_name"
fi
elif [ "$scale_type" == "全局" ]; then
if [ "$scale_factor" == "恢复默认" ];then
rm $HOME/.config/spark-wine/scale.txt
else
echo "$scale_factor" > "$HOME/.config/spark-wine/scale.txt"
find "$HOME/.deepinwine/" -name "scale.txt" -type f -print -exec rm -rf {} \;
fi
fi
fi
zenity --info --width=300 --text="操作已完成请重启Wine应用查看"
}
select_app