Thursday, March 10, 2011

Running .desktop files from the command line

After making a few .desktop files with custom commands in them (e.g.RXVT settings), it is useful to be able to run those same commands from the occasional terminal.

When KDE is installed, the kioclient can be used for this purpose:

kioclient exec file:/PATH_TO_DESKTOP_FILE

Custom desktop files are stored in ~/.local/share/applications, so this is easy to wrap in a shell function for inclusion in ~/.bashrc :

xdg-exec () {
    kioclient exec file:${HOME}/.local/share/applications/${1}.desktop
}

Example:

bash$ xdg-exec rxvt-unicode

No comments:

Post a Comment