I guess this won't be of use to a lot of people, but maybe to some, or it could be a useful basis for integration into other window managers, so here's how I configured the XFCE4
"Generic Monitor" plugin to list
relevant MG servers on the XFCE panel when they become available. To me,
relevant servers are those which:
- are not run by myself (since I will obviously know I'm running them already)
- have at least one other player on them
- are not full
- are in status "waiting for players"
I started out with a simple shell script which queries the master server and 'parses' its output and lists IP/port combinations, one per line. But it turned out the Generic Monitor plugin supports some pseudo XML format which can be used to do more than just text.
So I now have this script, stored at /home/user1/bin/megaglest-servers-xml (and made executable):
#!/bin/sh
myplayername=tomreyn
mginstallpath=$HOME/megaglest
# add this to the awk script to filter out own ip address: && $5 != "'$(wget -qO- http://whatismyip.org/)'"
for ipport in ` wget -qO- http://master.megaglest.org/showServersForGlest.php | grep -Ev '^$' | awk -F'|' '$14 == 0 && $4 !~ /^(Headless: |'$myplayername')/ { print $5":"$12 }' `
do
ip=`echo $ipport | cut -d: -f1`
port=`echo $ipport | cut -d: -f2`
# Get the second level domain name of the reverse, if any
isp=`dig -x $ip +short | awk -F. '{print $(NF-2)"."$(NF-1) }'`
# Generate output for http://goodies.xfce.org/projects/panel-plugins/xfce4-genmon-plugin
printf '<txt>%s</txt>\n<img>%s/megaglest.ico</img>\n<tool>%s (%s:%s)</tool>\n<click>%s/start_megaglest --connecthost=%s --use-ports=%s,61357</click>\n\n' "$isp" "$mginstallpath" "$isp" "$ip" "$port" "$mginstallpath" "$ip" "$port"
done
if [ "$ipport"x = 'x' ]; then date '+%H:%M:%S'; fi
You will want to adjust
myplayername and
mginstallpath to match your preferences.
And then I have this Generic Monitor plugin configuration:
Command: /home/tomreyn/bin/megaglest-servers-xml
Label: [MG]
Interval: 300
Font: Sans 7
As a result, this thing checks for suitable servers every 5 minutes. If it finds none are currently available, it just notes down the time of the last check on the panel:
If, however, suitable servers are available, then it will draw an MG icon followed by the servers' partial hostname (second level domain name only):
And if you mouse over these, you'll get more information, namely the servers' IP address. And when you click an icon, MegaGlest is launched and automatically connects to the given server.