Em vez de editar o script de outra pessoa, escrevi um wrapper. Este script lida muito bem com pulseaudio e synergy, mas o comando playonlinux em si é um problema porque ele retorna e eu tenho que criar uma maneira de fazer meu script esperar ... ou talvez eu não saiba. Eu poderia escrevê-lo para pesquisar o jogo para ver se ele está sendo executado.
... OK, eu o reescrevi para incluir um loop de pesquisa. Eu tenho uma última preocupação e isso é, se não for executado a partir do atalho.
... OK, houve um problema com a execução do atalho, mas adicionando um '& amp;' no final do comando playonlinux parece ter resolvido isso.
#!/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