Author Topic: Listing MG servers with XFCE 4 Generic Monitor plugin  (Read 1491 times)

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
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):
Code: [Select]
#!/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:
Code: [Select]
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.
« Last Edit: 6 October 2013, 01:51:35 by tomreyn »
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

atze

  • Technician
  • ****
  • Posts: 119
    • View Profile
Re: Listing MG servers with XFCE 4 Generic Monitor plugin
« Reply #1 on: 29 May 2012, 13:10:33 »
It works, :thumbup:  thank you tomreyn.  :)
this signature is not available in your country

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Listing MG servers with XFCE 4 Generic Monitor plugin
« Reply #2 on: 6 August 2012, 00:32:11 »
Unfortunately it turns out it only displays a maximum of one server, which is due to a limitation of the GenMon plugin. :-/
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Listing MG servers with XFCE 4 Generic Monitor plugin
« Reply #3 on: 15 November 2012, 15:33:42 »
Headless servers are displayed slightly different starting 3.7.0 so I've just modified the above script to reflect this. Without this modification, headless servers would always be listed.
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·