You can think of echo or cat as common terminal program. You can call blindly:

echo "hello world"

in bash for example and it will work. You will see the output.

I am looking for something like this for X11, something you can type (again blindly) and assuming user is working in X11 she/he will see visual output (so I am not asking how to detect X11, it works, this is assumption).

It could be even X11 command (like creating bare window with close button) if it is possible to call X11 subsystem from bash. Please note, I am not talking about problem like https://stackoverflow.com/questions/7035/how-to-show-a-message-box-from-a-bash-script-in-linux because tools like "zenity" (no question, it is useful) is not installed by default.

Important note: I need something persistent, something which will stay until power is off or user explicitly closes it.

  • 4
    xeyes, xterm, xclock, ... – Jeff Schaller Apr 18 '16 at 16:09
  • @JeffSchaller, why so shy :-), you gave perfect answer. Please post it as such, I will be happy to accept it. – greenoldman Apr 18 '16 at 16:10
  • 1
    This depends on the target distro, and what they install by default. I have X installed but none of xterm, xeyes, or xclock. Installing X doesn't necessarily install any of these. – muru Apr 18 '16 at 16:12
  • @muru, that's bad (for me). Did you remove any of those? I am thinking especially about xterm. – greenoldman Apr 18 '16 at 16:14
  • 1
    Likewise for Fedora, the default setup doesn't include xterm, xeyes or xclock. – Stephen Kitt Apr 18 '16 at 16:26

There really isn't any such command. Nor can there (within reason) be. The user could be, for example, using a full-screen app, and his/her compositing window manager refuses to put anything on top of it (as it'd disrupt the full-screen experience).

And of course blindly typing doesn't work—a terminal might not be focused. You could wind up typing your totally awesome command into a Stack Exchange answer instead of a terminal, where of course it won't be run.

If you want a command you can run that will probably display something, the basic ones that come with Xorg are a good guess: xlogo, xev, xfd, xmessage, xeyes, among several others. Of those, xmessage is sort of like zenity, but much more primitive (but probably more likely to be installed) and xeyes—will certainly get the user's attention. Remember in a shell script you can detect "not installed" (exit code 127) and try another on the list.

If you want to convey useful information to the user, and the user is using a modern desktop environment, your best bet is to send a desktop notification with notify-send (part of libnotify). That should persist until the user closes it.

  • Thank you for useful answer, just for the record by blindly execution I meant I can execute command without prior checking if the given program is installed (or installing it). Also the part about fullscreen etc. is irrelevant for me, because I know I have a terminal, my script is running and so on, the only question is what is the program (for XWindow) that is present on the system. One again thank you for the answer and a good selection list. – greenoldman Apr 18 '16 at 17:48
  • @greenoldman as you know you have a terminal, you might be able to back that command out and open another terminal. – StrongBad Apr 18 '16 at 23:51

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.