1
#!/bin/sh
xfce4-terminal
zenity --info
exit

Expected behavior on my Xfce4 desktop when the script is run (via a keyboard shortcut) is that the Terminal window appears. Only when I close same should the Zenity window then appear.

Normally, this is exactly what happens. However, if I first open an Xfce4 Terminal window on the desktop, then command the subject script (again, via a keyboard shortcut), another terminal window appears (as expected), but, simultaneously, so does the Zenity window. This is undesired behavior.

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

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

2
  • Do you want to open a xfc4-terminal, do stuff maybe into it, and when you manually close it, the zenity to popup?
    – thanasisp
    Commented Nov 9, 2020 at 23:48
  • @thanasisp Yes, that is exactly what I want to do...
    – Digger
    Commented Nov 9, 2020 at 23:59

2 Answers 2

2

This https://bugzilla.xfce.org/show_bug.cgi?id=14544
And this 10 years earlier https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=434863

Suggests: xfce4-terminal --disable-server -e "command args ..."

And seems to work with no adverse effects that I notice.

It also works without the -e option. My own usage and the usage in the old bug reports needed -e so they only talk about "the effect it has on -e", but the OPs usage doesn't involve -e, and the option does also cause a plain new terminal itself to block, not just a command specified by -e.

Apparently what happens (without the flag) is it doesn't directly produce a terminal, it merely acts as a client that submits a request to a server to have the server produce a terminal. It exits instantly because all it does is send a tiny message, and the actual terminal is some other unrelated process that happens elsewhere.

The server and client are the same binary, merely if there is no server running already, then one is started and then used, and lives as long as there are any open terminal windows.

But in all cases, whether the first invocation or not, the initiating process exits immediately.

This is not necessarily a terrible scheme if it didn't break every expectation and interoperability with every other program that wants to use a terminal app.

The older bug report was about an app which expected to be able to create a temp file, launch a text editor in a terminal to edit that temp file, block until the terminal exits, then pick up the temp file and do something with it after the user has edited it. And that worked for everything else in the world but broke with xfce4-terminal, yet the xfce4 dev only said the user was wrong a dozen times.

The --disable-server option seems to resolve it, but even there they seem to try to go out of their way to avoid saying what it actually does in any useful way. The option already existed when that user hit this problem, and the description in no way communicated that it was the way to get their desired behavior.

xfce4-terminal --help merely shows that the option exists, not what it does.
"man xfce4-terminal" only says (still today):

--disable-server
           Do not register with the D-BUS session message bus

What?

1
  • Thank you for the find, this worked for me. This option is so poorly documented xD Commented Feb 27 at 5:12
1

Give a try to this, I tested and looks good.

xfce4-terminal -x bash -c 'trap "zenity --info" EXIT; bash'

When executed, it opens a new xfce4-terminal, and executes the command following. This command is a shell trap. That means when this same process, the new-opened terminal, gets the signal to EXIT, will execute the quoted command. The last bash is to give a prompt, after the trap is set, like in this post. I also tried -H but didn't work as expected.

1
  • If you want to include any other commands into this, to run in the new terminal before you do anything manually, you can add them into there: -c 'trap "zenity --info" EXIT; command1; command2; bash'. Also if you run a GUI program, maybe try also to send it to the background, like jedit &, this will open the program, but also free the terminal for use. Anything else you run outside this command, is not directly relevant to when the zenity popup appears.
    – thanasisp
    Commented Nov 10, 2020 at 0:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .