Skip to content

Commit 2e573a0

Browse files
committed
update
1 parent b4909dc commit 2e573a0

File tree

7 files changed

+190
-54
lines changed

7 files changed

+190
-54
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ git clone https://github.com/licyk/ani2xcur
1515
- 2、进入目录并给予执行权限
1616
```
1717
cd ani2xcur
18-
chmod +x ani2xcur
18+
chmod +x ani2xcur.sh
1919
```
2020

2121
- 3、创建并进入虚拟环境
2222
>该步骤为可选步骤
2323
```
24-
python -m venv venv
24+
python3 -m venv venv
2525
source venv/bin/activate
2626
```
2727

@@ -57,7 +57,7 @@ source venv/bin/activate
5757

5858
在 Ani2xcur 文件浏览器中选中其中一种格式后即可开始转换,转换好的鼠标指针文件将保存在 Ani2xcur 文件夹中的`output`文件夹
5959

60-
Ani2xcur 也支持命令行模式运行,通过启动参数指定`安装鼠标指针的配置文件`的路径后即可进行转换
60+
Ani2xcur 也支持命令行模式运行(以命令行模式启动时不再检测 Dialog 是否安装),通过启动参数指定`安装鼠标指针的配置文件`的路径后即可进行转换
6161
例如
6262
```
6363
./ani2xcur.sh --inf "/home/licyk/Downloads/咩咩/lingdang.ani"
@@ -68,13 +68,15 @@ Ani2xcur 也支持命令行模式运行,通过启动参数指定`安装鼠标
6868
Ani2xcur 支持以下启动参数
6969
```
7070
使用:
71-
./ani2xcur.sh --help [--set-python-path python_path] [--inf inf_file_path] [--install-win2xcur] [--remove-win2xcur]
71+
./ani2xcur.sh [--help] [--set-python-path python_path] [--win2xcur-path win2xcur_path] [--inf inf_file_path] [--install-win2xcur] [--remove-win2xcur]
7272
7373
参数:
7474
--help
7575
显示 Ani2xcur 启动参数帮助
7676
--set-python-path python_path
7777
指定 Python 解释器路径。推荐在 Python 虚拟环境中启动 Ani2xcur, 这将可省去使用启动参数指定 Python 路径
78+
--win2xcur-path win2xcur_path
79+
指定 win2xcur 的路径
7880
--inf inf_file_path
7981
指定 inf 鼠标配置文件路径, 若路径有效, 则 Ani2xcur 将以命令行模式启动, 直接进行鼠标指针转换
8082
--install-win2xcur

ani2xcur.sh

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ ani_launch_args_manager()
102102
--inf)
103103
set_inf_file_path $ani_launch_args
104104
;;
105+
--win2xcur-path)
106+
set_win2xcur_path $ani_launch_args
107+
;;
105108
esac
106109
ani_launch_args_input= # 清除选项,留给下一次判断
107110
fi
@@ -119,6 +122,9 @@ ani_launch_args_manager()
119122
--set-python-path)
120123
ani_launch_args_input="--set-python-path"
121124
;;
125+
--win2xcur-path)
126+
ani_launch_args_input="--win2xcur-path"
127+
;;
122128
--inf)
123129
ani_launch_args_input="--inf"
124130
;;
@@ -141,13 +147,15 @@ ani_args_help()
141147
{
142148
cat<<EOF
143149
使用:
144-
./ani2xcur.sh --help [--set-python-path python_path] [--inf inf_file_path] [--install-win2xcur] [--remove-win2xcur]
150+
./ani2xcur.sh [--help] [--set-python-path python_path] [--win2xcur-path win2xcur_path] [--inf inf_file_path] [--install-win2xcur] [--remove-win2xcur]
145151
146152
参数:
147153
--help
148154
显示 Ani2xcur 启动参数帮助
149155
--set-python-path python_path
150156
指定 Python 解释器路径。推荐在 Python 虚拟环境中启动 Ani2xcur, 这将可省去使用启动参数指定 Python 路径
157+
--win2xcur-path win2xcur_path
158+
指定 win2xcur 的路径
151159
--inf inf_file_path
152160
指定 inf 鼠标配置文件路径, 若路径有效, 则 Ani2xcur 将以命令行模式启动, 直接进行鼠标指针转换
153161
--install-win2xcur
@@ -163,6 +171,7 @@ set_python_path()
163171
if [ -z "$*" ];then
164172
ani_echo "输入 Python 解释器路径为空"
165173
ani_echo "使用系统默认 Python"
174+
sleep 3
166175
else
167176
ani_echo "设置 Python 解释器路径: $@"
168177
ani_python_path=$@
@@ -177,7 +186,7 @@ set_inf_file_path()
177186
ani_echo "取消使用命令行模式, 将启动 Ani2xcur 界面"
178187
sleep 3
179188
else
180-
if [ -f "$@" ];then
189+
if [ -f "$*" ];then
181190
ani_echo "指定 inf 鼠标指针配置文件路径: $@"
182191
inf_file_path=$@
183192
else
@@ -188,6 +197,25 @@ set_inf_file_path()
188197
fi
189198
}
190199

200+
# 设置win2xcur路径
201+
set_win2xcur_path()
202+
{
203+
if [ -z "$*" ];then
204+
ani_echo "win2xcur 路径为空"
205+
ani_echo "将使用默认值"
206+
win2xcur_path="win2xcur"
207+
sleep 3
208+
elif which "$@" > /dev/null 2>&1; then
209+
ani_echo "使用自定义 win2xcur 路径: $@"
210+
win2xcur_path=$@
211+
else
212+
ani_echo "win2xcur 路径无效"
213+
ani_echo "将使用默认值"
214+
win2xcur_path="win2xcur"
215+
sleep 3
216+
fi
217+
}
218+
191219
# 测试输入值是参数还是选项,选项输出0,参数输出1(用于实现getopt命令的功能)
192220
ani_test_args()
193221
{
@@ -205,6 +233,7 @@ ani_unknown_args_echo()
205233
# 主程序
206234
main()
207235
{
236+
ani2xcur_ver="0.0.4"
208237
local cli_mode=1
209238
local missing_depend_info=0
210239
local missing_depend
@@ -284,6 +313,13 @@ main()
284313
fi
285314
fi
286315

316+
# 检测自定义win2xcur路径
317+
if [ -z "$win2xcur_path" ];then
318+
win2xcur_path="win2xcur"
319+
elif ! which "$win2xcur_path" > /dev/null 2>&1; then
320+
win2xcur_path="win2xcur"
321+
fi
322+
287323
if [ -z "$inf_file_path" ];then # 未指定inf文件路径
288324
if ! which dialog > /dev/null 2>&1; then
289325
missing_depend_info=1
@@ -330,4 +366,4 @@ elif [ ! "$(dirname "$(echo $0)")" = "." ];then
330366
exit 1
331367
fi
332368

333-
main "$@"
369+
main "$@"

modules/python_cmd.sh renamed to modules/ani_cmd.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ ani_pip()
3333
# 调用系统中存在的pip
3434
"$ani_python_path" -m pip "$@"
3535
fi
36+
}
37+
38+
# win2xcur命令
39+
ani_win2xcur()
40+
{
41+
"$win2xcur_path" "$@"
3642
}

modules/file_browser.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@ file_browser()
4141
elif [[ -f $file_select ]];then # 选择的是文件
4242
case $file_select in
4343
*.$file_format_1) # 选择的文件是指定格式
44-
ani_win2xcur "$(pwd)/$file_select"
44+
ani_win2xcur_start "$(pwd)/$file_select"
4545
dialog --erase-on-exit \
4646
--title "Ani2xcur" \
4747
--backtitle "鼠标指针转换结果" \
4848
--ok-label "确认" \
49-
--msgbox "鼠标指针转换完成, 可在 ${start_path}/output 文件夹中查看" $ani_dialog_height $ani_dialog_width
49+
--msgbox "鼠标指针转换完成, 可在 ${start_path}/output/${exec_time} 文件夹中查看" $ani_dialog_height $ani_dialog_width
5050
;;
5151
*.$file_format_2|*.$file_format_3) # 选择的文件是指定格式
52-
ani_win2xcur "$(pwd)/$(ls -a | grep \.inf$ | awk 'NR==1')"
52+
ani_win2xcur_start "$(pwd)/$(ls -a | grep \.inf$ | awk 'NR==1')"
5353
dialog --erase-on-exit \
5454
--title "Ani2xcur" \
5555
--backtitle "鼠标指针转换结果" \
5656
--ok-label "确认" \
57-
--msgbox "鼠标指针转换完成, 可在 ${start_path}/output 文件夹中查看" $ani_dialog_height $ani_dialog_width
57+
--msgbox "鼠标指针转换完成, 可在 ${start_path}/output/${exec_time} 文件夹中查看" $ani_dialog_height $ani_dialog_width
5858
;;
5959
*.zip|*.7z) # 文件解压缩功能,暂不支持自动检测编码,所以默认使用系统编码,如果压缩包是在windows系统中制作的,有可能会出现乱码
6060
7z x "$file_select"
@@ -99,4 +99,4 @@ file_browser()
9999
break
100100
fi
101101
done
102-
}
102+
}

modules/init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ esac
3636
# 启动
3737
if [ $cli_mode = 0 ];then
3838
ani_echo "启动转换"
39-
ani_win2xcur "$inf_file_path"
39+
ani_win2xcur_start "$inf_file_path"
4040
ani_echo "转换完成"
4141
ani_echo "退出 Ani2xcur"
4242
else

modules/mainmenu.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mainmenu()
1313
--title "Ani2xcur" \
1414
--backtitle "主界面" \
1515
--ok-label "确认" --cancel-label "退出" \
16-
--menu "请选择 Ani2xcur 的功能\n当前 Win2xcur 安装状态: $(which win2xcur > /dev/null 2>&1 && echo "已安装" || echo "未安装")\n当前使用 Python : $([ $use_custom_python_path = 0 ] && echo $ani_python_path || [ ! -z "$VIRTUAL_ENV" ] && echo "虚拟环境" || echo "系统环境")" \
16+
--menu "请选择 Ani2xcur 的功能\n当前 win2xcur 安装状态: $(which "$win2xcur_path" > /dev/null 2>&1 && echo "已安装" || echo "未安装")\n当前使用 Python : $([ $use_custom_python_path = 0 ] && echo $ani_python_path || [ ! -z "$VIRTUAL_ENV" ] && echo "虚拟环境" || echo "系统环境")\n当前 Ani2xcur 版本: $ani2xcur_ver" \
1717
$ani_dialog_height $ani_dialog_width $ani_dialog_menu_height \
1818
"1" "> 更新 Ani2xcur" \
1919
"2" "> 安装 win2xcur 核心" \
@@ -81,7 +81,7 @@ mainmenu()
8181
fi
8282
;;
8383
4)
84-
if which win2xcur > /dev/null 2>&1 ;then
84+
if which "$win2xcur_path" > /dev/null 2>&1 ;then
8585
cd ..
8686
file_browser
8787
else

0 commit comments

Comments
 (0)