0

I am trying to create a .bat file for Linux that:

  1. Checks for an existing instance of an application, then
  2. Launches an initial instance of the app or calls the existing instance forward.

I currently have a .bat (below) that works on one Linux machine, but it will not work on other machines.

#!/bin/bash

pid=`ps axwww | grep filename | grep java | sed -e 's/^[ \t]*//' | cut -f1 -d " "`

if [ a$pid == "a" ]
then
    java -Djava.net.preferIPv4Stack=true -Dsun.java2d.opengl=true -jar filename.jar /home/user/Desktop/folder/config/FILENAMEConfig.properties
else
    wid=`xdotool search "FILENAME"`
    xdotool windowactivate $wid
fi

My issue is that when I copy this .bat to another machine, it gives me the error:

Defaulting to search window name, class, and classname XGetWindowProperty[_NET_WM_DESKTOP] failed (code=1)

I have tried manually typing a new .bat on the second machine--still fails.

Any help is greatly appreciated.

Håken Lid
  • 22,318
  • 9
  • 52
  • 67
Tim
  • 1
  • 1

1 Answers1

0

Try:

wid=`xdotool search "FILENAME"`
xdotool windowactivate $wid

in:

xdotool search "FILENAME" windowactivate --sync

Anyway there is a bug affecting some distributions, see https://code.google.com/archive/p/semicomplete/issues/66

lamp76
  • 333
  • 1
  • 10
  • Thanks, lamp76. After more tinkering with other machines, it appears to be something with Linux (still have not nailed it down yet). I finally got my original .bat to work on a different machine. Then it quit working after about a dozen launches--gave me the "defaulting search..." error again. After I rebooted the machine it began working again. – Tim Apr 28 '16 at 19:23