Skip to content

Commit 4ff3211

Browse files
committed
Add some features and error handling
1 parent 36f876d commit 4ff3211

File tree

2 files changed

+99
-22
lines changed

2 files changed

+99
-22
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ sudo mv shin /usr/local/bin
1414
```
1515

1616
### Arguments
17-
When you are using the `run` command, you can use the provided arguments to tune the game to your liking (e.g run on discrete GPU)
17+
When you are using the `run` command, you can use the provided arguments to tune the game to your liking (e.g run on discrete GPU). Run `$ shin help for details`,
1818

19-
- `--nv-prime-offload` Run the game on discrete GPU instead of built-in CPU graphics (for NVIDIA user with proprietary driver only)
20-
- `--prime-offload` Same as above but this is for open source drivers
21-
- `--game-mode` Enable Feral Interactive Game Mode, result may vary
19+
### Configuration
20+
You can configure your game manually by editing the file located at `~/.local/share/shin/mess.vars`.
2221

2322
#### Why does this exist
2423
I have been using a specific game launcher and evertime i try to setup my games, it usually doesnt end up well. Some game have a weird GLX error and some game doesnt have DXVK installed even though i have turned on the option. This project wouldnt exist if its not because of my frustration.

shin

Lines changed: 96 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,59 @@
11
#!/bin/sh
22

33
prefix_addition=""
4+
with_dxvk="yes"
45

56
configure_dxvk() {
6-
local version download_dir
7+
local version download_dir check_recent_ver sys32_path sys64_path
8+
9+
printf "Vulkan device found. Configuring DXVK...\n"
10+
11+
# New drivers should support Vulkan 1.3
12+
check_recent_ver=$(vulkaninfo | grep -o "1\.3")
13+
if [ "$check_recent_ver" ]; then
14+
printf "Vulkan 1.3 device detected, using the latest DXVK version...\n"
15+
version="2.2"
16+
17+
else
18+
printf "No Vulkan 1.3 device detected. Using the latest legacy DXVK version (1.10.3)\n"
19+
version="1.10.3"
20+
21+
fi
722

8-
echo "Vulkan device found. Configuring DXVK..."
9-
version="1.10.3"
1023
download_dir="~/.local/share/shin/tools"
11-
wget -P "$download_dir" "https://github.com/doitsujin/dxvk/releases/download/v${version}/dxvk-${version}.tar.gz"
24+
wget -P -q "$download_dir" "https://github.com/doitsujin/dxvk/releases/download/v${version}/dxvk-${version}.tar.gz"
1225
tar -xf "$download_dir/dxvk-${version}.tar.gz" -C "$download_dir"
13-
WINEPREFIX="$1" "$download_dir/dxvk-$version/setup-dxvk.sh install" > /dev/null 2>&1
26+
27+
cd "$download_dir/dxvk-${version}"
28+
29+
# Someone please shorten this
30+
# Install 32-bit libraries
31+
sys32_path="$1/drive_c/windows/system32"
32+
mv "$sys32_path/d3d10_1.dll" "$sys32_path/d3d10_1.dll.old"
33+
mv "$sys32_path/d3d10core.dll" "$sys32_path/d3d10core.dll.old"
34+
mv "$sys32_path/d3d10.dll" "$sys32_path/d3d10.dll.old"
35+
mv "$sys32_path/d3d9.dll" "$sys32_path/d3d9.dll.old"
36+
mv "$sys32_path/d3d11.dll" "$sys32_path/d3d11.dll.old"
37+
mv "$sys32_path/dxgi.dll" "$sys32_path/dxgi.dll.old"
38+
cp "x32/*.dll" "$sys32_path"
39+
40+
# Install 64-bit libraries
41+
sys64_path="$1/drive_c/windows/syswow64"
42+
mv "$sys64_path/d3d10_1.dll" "$sys64_path/d3d10_1.dll.old"
43+
mv "$sys64_path/d3d10core.dll" "$sys64_path/d3d10core.dll.old"
44+
mv "$sys64_path/d3d10.dll" "$sys64_path/d3d10.dll.old"
45+
mv "$sys64_path/d3d9.dll" "$sys64_path/d3d9.dll.old"
46+
mv "$sys64_path/d3d11.dll" "$sys64_path/d3d11.dll.old"
47+
mv "$sys64_path/dxgi.dll" "$sys64_path/dxgi.dll.old"
48+
cp "x64/*.dll" "$sys64_path"
49+
50+
export WINEPREFIX="$1"
51+
wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v d3d10_1 /d native /f >/dev/null 2>&1
52+
wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v d3d10 /d native /f >/dev/null 2>&1
53+
wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v d3d10core /d native /f >/dev/null 2>&1
54+
wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v d3d9 /d native /f >/dev/null 2>&1
55+
wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v d3d11 /d native /f >/dev/null 2>&1
56+
wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v dxgi /d native /f >/dev/null 2>&1
1457

1558
}
1659

@@ -22,15 +65,35 @@ vulkan_is_there() {
2265
[ $vk_devices -gt 0 ] && return 0 || return 1
2366
}
2467

25-
parse_opt() {
68+
parse_add_opt() {
69+
70+
shift; shift
71+
72+
while [ $# -gt 0 ]; do
73+
printf "Arguments: $1\n"
74+
75+
case "$1" in
76+
--without-dxvk) with_dxvk="no";;
77+
78+
esac
79+
80+
shift
81+
82+
done
83+
84+
}
85+
86+
parse_run_opt() {
2687

2788
shift; shift
2889

2990
while [ $# -gt 0 ]; do
3091
printf "Arguments: $1\n"
3192

3293
case "$1" in
33-
--nv-prime-offload) prefix_addition="${prefix_addition} __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia";;
94+
--nv-glx-offload) prefix_addition="${prefix_addition} __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia";;
95+
--nv-vk-offload) prefix_addition="${prefix_addition} __NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only";;
96+
--use-zink) prefix_addition="${prefix_addition} __GLX_VENDOR_LIBRARY_NAME=mesa MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink";;
3497
--prime-offload) prefix_addition="${prefix_addition} DRI_PRIME=1";;
3598
--game-mode) prefix_addition="${prefix_addition} gamemoderun";;
3699

@@ -45,7 +108,10 @@ parse_opt() {
45108
operation_run() {
46109
local game_inf game_name game_runner game_dir game_exe game_cmd_prefix previous_dir
47110

48-
game_inf=$(grep "$1" ~/.local/share/shin/mess.vars)
111+
game_inf=$(grep "${1}_" ~/.local/share/shin/mess.vars)
112+
113+
[ -z "$(echo $game_inf)" ] && printf "No games found using the specified ID\n" && exit
114+
49115
game_name=$(echo "$game_inf" | grep -o "${2}_NAME='[^']*" | sed "s/${2}_NAME='//")
50116
game_runner=$(echo "$game_inf" | grep -o "${2}_RUNNER='[^']*" | sed "s/${2}_RUNNER='//")
51117
game_dir=$(echo "$game_inf" | grep -o "${2}_DIR='[^']*" | sed "s/${2}_DIR='//")
@@ -82,14 +148,19 @@ operation_add() {
82148
runner="native"
83149

84150
else
151+
wine_prefix="$HOME/.local/share/shin/wineprefixes/$1"
85152
printf "Configuring wine prefix...\n"
86-
! [ -d "$HOME/.local/share/shin/wineprefixes/$1" ] && mkdir -p "$HOME/.local/share/shin/wineprefixes/$1"
87-
WINEPREFIX="$HOME/.local/share/shin/wineprefixes/$1" wineboot -u > /dev/null 2>&1
88-
is_vulkan_there=$(vulkan_is_there)
153+
! [ -d "$wine_prefix" ] && mkdir -p "$wine_prefix"
154+
WINEPREFIX="$wine_prefix" wineboot -u > /dev/null 2>&1
155+
156+
if [ "$with_dxvk" = "yes" ]; then
157+
is_vulkan_there=$(vulkan_is_there)
158+
[ $is_vulkan_there = 0 ] && configure_dxvk "$wine_prefix" || printf "No Vulkan device found. Falling back to WINED3D"
159+
160+
fi
89161

90-
[ $is_vulkan_there = 0 ] && configure_dxvk "$HOME/.local/share/shin/wineprefixes/$1" || printf "No Vulkan device found. Falling back to WINED3D"
91162
runner="wine"
92-
cmd_prefix="WINEFSYNC=1 WINEESYNC=1 WINEPREFIX=$HOME/.local/share/shin/wineprefixes/$1"
163+
cmd_prefix="WINEFSYNC=1 WINEESYNC=1 WINEPREFIX=$wine_prefix"
93164

94165
fi
95166

@@ -102,9 +173,8 @@ operation_add() {
102173

103174
## MAIN ##
104175

105-
parse_opt "$@"
106-
107176
if [ "$1" = add ]; then
177+
parse_add_opt "$@"
108178
printf "Please enter the game ID This will be used to identify your game when using the 'run' operation\n>> "
109179
read -r game_id
110180

@@ -114,6 +184,7 @@ if [ "$1" = add ]; then
114184
operation_add "$game_id" "$game_name" "$2"
115185

116186
elif [ "$1" = "run" ]; then
187+
parse_run_opt "$@"
117188
operation_run "$2"
118189

119190
elif [ "$1" = "list" ]; then
@@ -122,18 +193,25 @@ elif [ "$1" = "list" ]; then
122193

123194
elif [ "$1" = "help" ]; then
124195
cat << EOF
125-
Usage: shin <command> <command arg> [ARGUMENTS]...
196+
Usage: shin <command> <command arg> [OPTIONS]...
126197
127198
Example: shin add <game path>
128199
shin run <game id> --game-mode --nv-prime-offload
129200
130-
Options:
201+
\`run\` Options:
131202
132-
--nv-prime-offload Run the game on NVIDIA GPU using PRIME render offload
203+
--nv-glx-offload Run OpenGL game on NVIDIA GPU
204+
--nv-vk-offload Run Vulkan game on NVIDIA GPU
205+
--use-zink Translate OpenGL to Vulkan using Mesa Zink driver, might improve
206+
OpenGL games performance
133207
--prime-offload Run the game on discrete GPU using PRIME render offload
134208
(only for open-source drivers)
135209
--game-mode Run the game with Feral Interactive Game Mode to
136210
optimize gaming performance
211+
212+
\`add\` Options:
213+
214+
--without-dxvk Configure wine prefix without DXVK
137215
EOF
138216

139217
fi

0 commit comments

Comments
 (0)