解决Linux上东方花映塚启动时无法正常全屏的方法
在Linux系统中,有时会遇到一些游戏无法正常全屏启动的问题。本文将介绍如何通过编写一个简单的bash脚本来解决这个问题。该脚本会检查游戏窗口的状态,并在需要时将其设置为全屏模式。以下是脚本的详细内容和使用方法。
脚本内容
首先,将以下内容保存为名为th09fullscreen.sh的脚本文件:
#!/bin/bash
if type flatpak-spawn; then
if flatpak-spawn --host bash -c "type wmctrl xprop"; then
wmctrl="flatpak-spawn --host wmctrl"
xprop="flatpak-spawn --host xprop"
fi
else
if ! type wmctrl xprop; then
echo install wmctrl and xprop.
else
wmctrl=wmctrl
xprop=xprop
fi
fi
function get_window_handle_by_name() {
name=$1
$wmctrl -l | grep -i "$name" | head -1 | awk '{print $1}'
}
function get_window_state() {
window_handle=$1
$xprop -id $window_handle _NET_WM_STATE 2>/dev/null
}
if [ -z "$1" ]; then
exit 1
fi
setsid -f $@
while true; do
game_window_handle=$(get_window_handle_by_name "Phantasmagoria of Flower View")
if [ -z $game_window_handle ]; then
echo wait game ready.
true
else
game_window_state=$(get_window_state $game_window_handle)
game_window_have_fullscreen=$(echo $game_window_state | grep "_NET_WM_STATE_FULLSCREEN")
if [ -z "$game_window_have_fullscreen" ]; then
$wmctrl -i -r $game_window_handle -b add,fullscreen
break
else
break
fi
fi
done
使用方法
- 确保已安装
wmctrl和xprop命令。 - 脚本适配了flatpak版本的Steam,但需要授予Steam执行宿主机的任意命令权限(允许Steam访问DBus会话总线的
org.freedesktop.Flatpak)。如果不放心,可以使用方法1。
方法1:使用Steam URL启动游戏。
th09fullscreen.sh xdg-open steam://rungameid/1420810方法2:将脚本添加到游戏的启动参数中。
# 在游戏启动参数中添加脚本路径通过以上方法,您可以解决Linux上东方花映塚游戏启动时无法正常全屏的问题。希望这对您有所帮助!
评论已关闭