0
#!/bin/sh
jedit file.txt
zenity --info
...several more more commands...
exit

Expected behavior: I command the script (in this case, via a keyboard shortcut). A jEdit window then opens on my Xfce4 desktop, displaying the contents of file.txt. I perform some text manipulation within same and then manually close said jEdit window. Next, the commanded Zenity window appears, as expected. I close same manually and the next step of the script executes...and I experience joy and contentment.

However, if, for some reason I've already got an unrelated jEdit window open on the desktop when I command the script (again, via a keyboard shortcut), here's what now happens: After said script is so commanded, the expected jEdit window (the one displaying the contents of file.txt) opens, along with the Zenity window (note that, in this case, said Zenity window opens before the jEdit window is manually closed by me). This is undesired behavior...and I experience rage and despair.

I have tried many things, including the wait command and appending the terminal line with &&. I've also attempted trapping. Nothing is working for me.

What is causing this to happen and how can I remedy it?

1

Use jedit -noserver. From the manpage:

-background
      Run jEdit in background mode. In background mode, the  edit  server  will  continue
      listening  for  client  connections  even after all views are closed. Has no effect
      when connecting to another instance via the edit server.
-nobackground
      Disable background mode. This is the default. Has  no  effect  when  connecting  to
      another instance via the edit server.
...
-server
      Store  the  server  port  info  in  the  file  named  "server"  inside the settings
      directory. This is the default.
...
-noserver
      Do not attempt to connect to a running edit server, and does not start one either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.