要承认windows的生态的强大。所以必要时做一些妥协,可以让事情更加顺利。比如使用wine运行一些软件,如果软件在wine上能运行的良好,既能避免vm的高资源消耗,又能免去不少多系统维护的精力。
版本
玩过才知道,wine不同的版本,功能差别非常大。一个软件在不同版本的wine上可能稳定运行,可能崩溃,可能闪退。
1、最容易想到的就是使用操作系统官方源和安装命令安装:
1
2
| # ubuntu
apt-get install wine
|
这种方式的优点就是安装快速,适合功能试水。缺点就是不能选择安装版本,且版本较老。
2、通过wine官方源安装
官方安装文档连接:https://wiki.winehq.org/Download
比如Ubuntu,添加安装源,按照指定命令安装即可。这种方式一般安装的是最新版,或者较新版。
1
2
3
4
5
6
7
8
9
10
11
12
| sudo dpkg --add-architecture i386
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
#20.04
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources
#22.04
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources
#install
sudo apt install --install-recommends winehq-stable
|
3、源码自编译安装
选择对应源码:https://www.winehq.org/news/
下载后编译安装,这种方式灵活性较大,可以根据要运行的windows软件,尝试不同的版本,直到能够稳定运行。但是有个缺点就是如果尝试多个版本,则编译时间长,编译占用大量磁盘和时间。
1
2
3
4
5
6
7
8
9
10
11
12
| # 安装依赖
apt-get install libx11-dev:i386
apt-get install libfreetype6-dev:i386 libfreetype6-dev
apt-get install libxrender-dev:i386 libgnults-dev:i386
#编译64位
./configure --enable-win64
make
#编译32位,配置时指定64位编译目录
./configure --with-wine64=../wine-8.9_64
make
|
4、一种更快速的方式
已经有人构建了多个版本,可以按需下载运行:
https://github.com/Kron4ek/Wine-Builds
运行
指定 .wine生成的目录,实现多版本运行:
1
2
3
4
5
6
7
8
9
| #!/bin/bash
# 取得此bash脚本所在路径
script=$(readlink -f "$0")
scriptpath=$(dirname "$script")
# 这里设置好WINEPREFIX
export WINEPREFIX="$scriptpath"
./bin/wine x.exe
|
配置
开启字体抗锯齿化, 启用平滑字体:
https://wiki.archlinuxcn.org/wiki/Wine?rdfrom=https%3A%2F%2Fwiki.archlinux.org%2Findex.php%3Ftitle%3DWine_%28%25E7%25AE%2580%25E4%25BD%2593%25E4%25B8%25AD%25E6%2596%2587%29%26redirect%3Dno#%E5%AD%97%E4%BD%93
保存后执行,选择第三项。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
| #!/bin/sh
# Quick and dirty script for configuring wine font smoothing
#
# Author: Igor Tarasov <tarasov.igor@gmail.com>
WINE=${WINE:-wine}
WINEPREFIX=${WINEPREFIX:-$HOME/.wine}
DIALOG=whiptail
if [ ! -x "`which "$WINE"`" ]
then
echo "Wine was not found. Is it really installed? ($WINE)"
exit 1
fi
if [ ! -x "`which "$DIALOG"`" ]
then
DIALOG=dialog
fi
TMPFILE=`mktemp` || exit 1
$DIALOG --menu \
"Please select font smoothing mode for wine programs:" 13 51\
4\
1 "Smoothing disabled"\
2 "Grayscale smoothing"\
3 "Subpixel smoothing (ClearType) RGB"\
4 "Subpixel smoothing (ClearType) BGR" 2> $TMPFILE
STATUS=$?
ANSWER=`cat $TMPFILE`
if [ $STATUS != 0 ]
then
rm -f $TMPFILE
exit 1
fi
MODE=0 # 0 = disabled; 2 = enabled
TYPE=0 # 1 = regular; 2 = subpixel
ORIENTATION=1 # 0 = BGR; 1 = RGB
case $ANSWER in
1) # disable
;;
2) # enable
MODE=2
TYPE=1
;;
3) # enable cleartype rgb
MODE=2
TYPE=2
;;
4) # enable cleartype bgr
MODE=2
TYPE=2
ORIENTATION=0
;;
*)
rm -f $TMPFILE
echo Unexpected option: $ANSWER
exit 1
;;
esac
echo "REGEDIT4
[HKEY_CURRENT_USER\Control Panel\Desktop]
\"FontSmoothing\"=\"$MODE\"
\"FontSmoothingOrientation\"=dword:0000000$ORIENTATION
\"FontSmoothingType\"=dword:0000000$TYPE
\"FontSmoothingGamma\"=dword:00000578" > $TMPFILE
echo -n "Updating configuration... "
$WINE regedit $TMPFILE 2> /dev/null
rm -f $TMPFILE
echo ok
|
winecfg
配置挂载目录等一些功能
安装Python
wineconsole
然后定位Python程序目录,执行:python-3.10.0-amd64.exe
字体
可以到windows系统拷贝字体到 ~/.wine/drive_c/windows/Fonts
1
2
| ls ~/.wine/drive_c/windows/Fonts
consolab.ttf consolai.ttf consola.ttf consolaz.ttf lucon.ttf msyhbd.ttc msyhl.ttc msyh.ttc
|
主题
下载地址:http://www.gratos.be/wincustomize/msstyle.htm
解压,然后winecfg,更换主题