Simplified down, I want to write a shell function which runs a program in a new window. For applications like … emacs, firefox, gitk that can look like this:
myopen() {
$@
}
But I want to open applications which run in the terminal in a new terminal, e.g. for alsamixer, vim, bash, zsh it should look like
myopen() {
urxvt -e "$@"
}
I have seen that .desktop files contain the information if they should run in a terminal (for vim / gvim)
[Desktop Entry]
Name=Vim
GenericName=Text Editor
TryExec=vim
Exec=vim %F
Terminal=true
or
[Desktop Entry]
Name=GVim
GenericName=Text Editor
TryExec=gvim
Exec=gvim -f %F
Terminal=false
is there an existing interface to query the Terminal
filed (i.e. without using locate
and grep
to find the .desktop
file and parsing them)?
So in quasi code I want to fill the gap in
myopen() {
TERMINALFIELD=$(xdg-app-uses-terminal $1) # this line is made up
if [[ TERMINALFIELD == true ]]; then
urxvt -e "$@"
else
$@
fi
return $?
}
alias
of those commands so they are run in a new terminal program? What terminal program are you using?xdg-open
is the place to look.vim_newwin='urxvt -e vim'
,gvim_newwin=gvim
- such that any_newwin
command would open in a new window. but i'd like something that provides the new window behaviour for any "new" command automatically, without the need for me to manually create the alias and check if i should launch the terminal or not. ("new" as in: unused by me before). and i thought about using a function to avoid piling up tons of aliases. I useurxvt
.xdg-open
for this. afaikxdg-open
can be used to open a file with the right application. likexdg-open some.pdf
launches a pdf reader, butxdg-open vim
doesn't launch vim in a new terminal - i merely get a popup message "/home/pseyfert/vim: file or directory not found". And I don't see any hint for other usages in the man page.