如何在玩全屏游戏后自动恢复显示设置?

如何在玩全屏游戏后自动恢复显示设置?

当我在 Ubuntu 上玩全屏游戏时(Gnome、Kde、XFCE 都行),游戏会决定显示器的设置,然后当游戏结束时,我就只能使用这些设置了。是否有操作系统功能可以自动恢复显示器设置(就像在 Windows 中一样),如果没有,我可以编写一个脚本来保存我的设置,以便轻松恢复吗?(比如按一下按钮或使用热键)

第一个显示器 DVI-0 以 1440x900 运行,其右侧的 VGA-0 以 1600x900 运行。

好的,我发现这样xrandr --output DVI-0 --auto --rotate normal --pos 0x0 --output VGA-0 --auto --left-of DVI-0可以正确设置我的显示器,但是我仍然不知道如何在使用全屏应用程序后出现“显示器错误”时轻松实现这一点。

答案1

Ctrl按+ Alt+进入终端T并输入以下命令:

mkdir bin

在用户的主目录中创建一个二进制目录,该目录将自动添加到路径中。

cd bin
cat > SC

切换到该目录并开始创建该文件。

现在复制粘贴以下代码:

#!/bin/bash
# This script starts StarCraft as an example for automatically restoring the video
# resolution as per question https://askubuntu.com/questions/594283/

# Copyright (c) Fabby 2015

# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. See the GNU General Public License for more details.
# You DID NOT receive a copy of the GNU General Public License along with this program as the license is bigger then this program.
# Therefore, see http://www.gnu.org/licenses/ for more details.
# The following line needs to be changed per game.  Example is for StarCraft
/usr/share/playonlinux/playonlinux --run "StarCraft" $1
# The following line needs to be changed per machine's individual resolution settings:
xrandr --output DVI-0 --auto --rotate normal --pos 0x0 --output VGA-0 --auto --left-of DVI-0 

并点击:Ctrl+D然后输入:

chmod +x SC

现在,“程序”SC已准备好使用 1 个参数执行。关闭终端并再次打开它并输入:

cd /path/to/SaveGames
SC szFirstCoupleOflattersOfSaveGame[Tab]

/path/to/SaveGames和分别是szFirstCoupleOflattersOfSaveGame您保存游戏存档的目录和游戏存档名称的前几个字母,后跟用于Tab自动完成整个游戏存档名称的键。(如果您只是输入,SC它只会启动星际争霸而不加载任何游戏存档......)

然后结束Enter并微笑!

上述示例应该足以满足您拥有的任何其他游戏的需求。如果您始终将全部大写字母用于自己的游戏,并将“程序”的名称保持简短,那么您将变成真正的终端成瘾者。;-)

如果你不喜欢终端命令,这个网站上已经有答案可以将它们变成桌面或仪表盘上的图标(比如这个

相关内容