kakounedotcom / connect.kak

Connect a program to Kakoune clients

Home Page:https://kakoune.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kak-desktop: Is this the only way to check if we are inside a terminal?

useredsa opened this issue · comments

After I suggested (I apologize for caussing this issue) kak-desktop should open the file passed in the terminal if it is run from there, the following lines where added to kak-desktop:

elif test -t 1; then
  kak "$@"

I wonder if there's a better way to check if kak-desktop is being run inside a terminal than to check the output file descriptor. The reason is, if I spawn dolphin using sxhkd its output is linked to tty1, which also happens to the spawned kak-desktop process when I try to open a file. As a result, the file is not opened in a new terminal emulator. I know this can be fixed starting dolphin as dolphin >/dev/null, but perhaps there's a different way to check whether the process indeed has access to a virtual terminal displayed to the user.

I’m not sure if there is another way. If you find a better handling, I will happily merge.

I’m not sure if there is another way. If you find a better handling, I will happily merge.

I only know that STDIN is not matched to a terminal in my particular case, so checking with test -t 0 would suffice. Instead of replacing a test with the other one, I suggest including both, which, even though it doesn't quite solve the problem, I believe will be more robust. What do you think?