1

I would like xdg-open to open a new terminal when I run it on a file from the terminal and it opens, for example, nvim.

My default text editor for text/plain is set to nvim.desktop. When I open a text/plain file from dolphin, it correctly opens nvim in a new terminal. But when I run xdg-open on that same file from a terminal, it opens nvim in the current terminal instead of starting a new one. How can I force xdg-open to open programs with a Terminal=true flag in their .desktop file in a new terminal when I run xdg-open from a terminal?

I already tried { cat | xdg-open ~/file.txt 2>&1 >>/dev/null ; } & disown (file.txt is present in the home directory) but nothing happens, nvim is not even running if I type pgrep nvim after...

My terminal is konsole, I am using Hyprland as window manager.

Edit: I found out gio open does this correctly, so for now I will just use that. (I'll consider making it the answer, but I'll just wait a couple of days to see if I get an answer for xdg-open.)

1 Answer 1

0

You can try replacing the executable command with konsole -e "nvim %F" (basically, the value after = in the line Exec=... should be replaced with the above

In essence, you will now be executing the nvim command not directly, but rather calling konsole to open a new window and run nvim (with the given filename) in it.

1
  • Yea, that would only work for this specific application, I would like it to apply to all applications that use a terminal... Commented Jun 4, 2024 at 7:17

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.