0

So I just got my butt kicked at several games of Battle.Net ( specifically StarCraft ) because it hates synergy. The reasons why are obvious since it's a really mouse intense game that takes control of everything when you fire it up. I have aliases for starting and stopping synergy but the issue is that I keep forgetting to use them before I start the game and after that I'm already committed. It's REALLY getting on my nerves.

The game is installed using PlayOnLinux. What script do I edit to insert something that will kill synergy? Does PlayOnLinux have a standard location to put user scripts or is there some standardized means for doing this sort of thing?

New info - Found this:

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

Is this suitable or is there a better place?

1 Answer 1

0

Rather than edit somebody else's script, I've written a wrapper. This script handles pulseaudio and synergy quite well but the playonlinux command itself is an issue because it returns and I have to come up with a way to make my script wait... or maybe I don't. I could write it to poll for the game to see if it is running.

...OK, I've rewritten it to include a polling loop. I have one last concern and that is if it doesn't run from the shortcut.

...OK there was an issue with running from the shortcut but adding a '&' at the end of the playonlinux command seems to have addressed it.

#!/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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .