You are not logged in.

#1 2011-02-02 13:43:09

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

How to get default command to open a terminal window? (Bash or Python)

Desktop entry files (.desktop files) may indicate that an application requires a terminal window to run ("Terminal=true"), e.g. vim & maxima.

How does a .desktop launcher determine which terminal to use? E.g. when opening a file associated with vim, what points it to 'urxvtc -e %s' or 'gnome-terminal...' or whatever?

Is there a standard environment variable with the terminal command? $TERM only contains an identifying name but I don't see how to programmatically deduce the command from it. Grepping through the output of "set" doesn't show me anything useful either.


My search-fu has failed me. Does anyone have any ideas?


EDIT: Clarified subject and post.

Last edited by Xyne (2011-02-02 14:00:14)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#2 2011-02-02 14:05:30

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: How to get default command to open a terminal window? (Bash or Python)

Maybe my search-fu can be of help here:

For KDE:

terminal=$(kreadconfig --file kdeglobals --group General \
        --key TerminalApplication --default konsole)

For GNOME:

TERM_EXEC_KEY="/desktop/gnome/applications/terminal/exec"
TERM_EXEC_ARG_KEY="/desktop/gnome/applications/termina/exec_arg"

TERM_EXEC=$( gconftool-2 --get ${TERM_EXEC_KEY})          # e.g. 
"gnome-terminal"
TERM_EXEC_ARG=$( gconftool-2 --get ${TERM_EXEC_ARG_KEY} ) # e.g. "-x"

terminal="$TERM_EXEC $TERM_EXEC_ARG"

For XFCE:

Xfce has a directory called "share/xfce4/helpers/" which contains desktop entry files for commonly used terminals, browsers and email apps. These entries contain extra keys like X-XFCE-Category=WebBrowser or X-XFCE-Category=TerminalEmulator .

Then there is a file called ".config/xfce4/helpers.rc" which in my case looks like:

        WebBrowser=firefox
        MailReader=thunderbird

From: http://www.mail-archive.com/xdg@lists.f … 01661.html

edit: there is also xdg-settings (in xdg-utils) which can store default-app information, but i'm not sure if all DE's make use of this..

Last edited by litemotiv (2011-02-02 14:08:27)


ᶘ ᵒᴥᵒᶅ

Offline

#3 2011-02-02 14:31:45

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: How to get default command to open a terminal window? (Bash or Python)

@litemotiv
Sorry, I should have stated that I'm looking for a reliable way to this on different systems. Detecting the DE would just replace the current problem of detecting the terminal. xdg-settings is promising as I believe it's intended to become a universal standard, but as you mentioned, it's still got a long way to go.

Thanks nevertheless.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB