AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 902651
Accepted
user447607
user447607
Asked: 2017-04-09 11:42:45 +0800 CST2017-04-09 11:42:45 +0800 CST 2017-04-09 11:42:45 +0800 CST

如果我的游戏正在加载,我如何检测并消除协同作用?

  • 772

所以我刚玩了几场战网游戏(特别是星际争霸),因为它讨厌协同作用。原因很明显,因为它是一款真正的鼠标密集型游戏,当你启动它时会控制一切。我有启动和停止协同的别名,但问题是我一直忘记在开始游戏之前使用它们,之后我已经投入使用。这真的让我很紧张。

该游戏是使用 PlayOnLinux 安装的。我要编辑什么脚本来插入会杀死协同作用的东西?PlayOnLinux 是否有一个标准的位置来放置用户脚本,或者是否有一些标准化的方法来做这种事情?

新信息 - 发现这个:

/usr/share/playonlinux/playonlinux --run "Battle.Net" %F

这是合适的还是有更好的地方?

scripts
  • 1 1 个回答
  • 93 Views

1 个回答

  • Voted
  1. Best Answer
    user447607
    2017-04-09T14:34:43+08:002017-04-09T14:34:43+08:00

    我没有编辑别人的脚本,而是编写了一个包装器。这个脚本很好地处理了pulseaudio和synergy,但是playonlinux命令本身就是一个问题,因为它会返回,我必须想出一种方法让我的脚本等待......或者我可能没有。我可以写它来轮询游戏,看看它是否正在运行。

    ...好的,我已经重写了它以包含一个轮询循环。我还有最后一个问题,那就是它是否不是从快捷方式运行的。

    ...好的,从快捷方式运行时出现问题,但在 playonlinux 命令末尾添加“&”似乎已经解决了这个问题。

    #!/bin/bash
    
    #The idea is to use this script to replace the command in the shortcut.
    #
    # Architectural & contextual notes: This is a desktop ( my wargamer's box called
    # Warmachine ) which has a synergy server running on it and also a laptop that
    # runs a synergy client. Synergy & pulseaudio must die in order for the game to
    # play correctly. Synergy must die on both machines but pulseaudio is an issue
    # local to the desktop. The Synergy client running remotely must die because it
    # freaks out when it can't find the server. The most annoying effect of this is
    # a shrieking laptop fan while you are trying to conentrate when it isn't even
    # supposed to be doing anything. I have aliases for all these functions and I'm
    # really just putting them into a wrapper script form because I keep forgetting
    # to use them.
    #
    # In order for the sudo commands to work in a non-interactive fashion
    # i.e., without a password, you need the following entry in your sudoers file:
    # [username goes here] ALL=(root) NOPASSWD: /usr/sbin/service avahi-daemon restart, /usr/bin/killall synergys
    # ...and this one on the laptop:
    # [username goes here] ALL=(root) NOPASSWD: /usr/bin/killall synergyc, /home/jim/scripts/restartSynergy.sh
    # I use a special script to restart synergy on the laptop as it includes a
    # screen resizing background process that fixes the synergy screen size
    # when it swtches from the laptops display to the 42" TV I use for a regular
    # game display.
    
    #kpa - Kill Pulse Audio alias
    #We are killing pulseaudio because WINE hates it.
    
    echo "autospawn = no" > ~/.config/pulse/client.conf &
    pulseaudio --kill
    
    #Now we need to kill our synergy server and also stop the client in my laptop.
    
    ssh -t -t bl sudo /usr/bin/killall synergyc &
    sudo /usr/bin/killall synergys
    
    sleep 1
    
    # This is the command to start the game. This is what the script is wrapping.
    # Unfortunately this command returns as soon as it is called regardless, so I
    # need to come up with something to deal with that. Perhaps a polling system?
    # The apparently extraneous '&' below fixes an issue.
    /usr/share/playonlinux/playonlinux --run "Battle.Net" %F &
    
    sleep 1
    
    #This is our polling loop.
    EXIT=0
    while [ ${EXIT} -eq 0 ]; do
      sleep 5
    
      ps aux | grep -v grep | grep Battle\.Net
      EXIT=$?
      if [[ ${EXIT} != 0 ]]; then
    
        #spa - Start Pulse Audio alias
        rm -f ~/.config/pulse/client.conf
        pulseaudio --start
    
        # Reload the audio devices in the GUI
        sudo /usr/sbin/service avahi-daemon restart &
    
        /usr/bin/synergys -a 127.0.0.1 -c /etc/synergy.conf
        sleep 1
        #Restart synergy client on laptop.
        ssh -t -t bl /home/jim/scripts/restartSynergy.sh
    
      fi
    
    done
    
    • 0

相关问题

  • 如何在 Nautilus 中管理保存的完整网页及其目录(例如 n.html 和 n_files)

  • 如何每 5 秒运行一次脚本?

  • 如何将必须从其自己的目录中运行的程序添加到面板或主菜单?

  • 如何编写 shell 脚本来安装应用程序列表?

  • Mac OS X Automator 的替代品?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve