KDE Desktop file : Detecting if "run in terminal" is check during execution of the running script

Hello.
I have some kind of script that are started from a desktop file.
Is it possible to determine in the script during runtime if the checkbox ‘Run in terminal’ in the advance option is checked or not.
If the checkbox is not check i have to skip some interactive messages.

Any help is welcome.

You are probably asking the wrong question.

What likely matters, is whether the command (or script, or whatever) is running on a terminal. How it got to be running on the terminal (whether the box is checked or it was manually started at a command line) is unlikely to be important.

In a shell script you can test:


if -t 1 ; then
    stuff for terminal
  else
    stuff for non-terminal
fi

This is testing file descriptor 1, usually stdout. You can instead use 0 (for stdin) or 2 (for stderr) depending on what you are wanting to test.

Thank you very much

After test,

if -t 1 ; then

is not useful as one don’t know the tty in use.

Searching on internet I have found this :

TTY_DEVICE="/dev/$(ps -p $$ -o tty=)"
if  "$TTY_DEVICE" == "/dev/?"  ] ; thenstuff for non terminal

elsestuff for terminal

fi

Did you agree ?

Happy Christmas to everybody

It seems unnecessarily complex. But I don’t know how you are using this. If it works for you, that’s fine.

Is it possible to determine in the script during runtime if the checkbox ‘Run in terminal’ in the advance option is checked or not.
If the checkbox is not check i have to skip some interactive messages.

**If the checkbox is not check i have to skip some interactive messages.
**
Any other tips or tricks are welcome.