This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] Launch .desktop files from command line?

Tags: None
(comma "," separated)
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
Is it possible to launch .desktop files from the command line?

This is probably a pretty silly question. The reason I want to do it has to do with this "issue" - I figured that if I could tell xbindkeys to run a .desktop file, maybe I can get launch feedback for that application.


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
User avatar
ivan
KDE Developer
Posts
918
Karma
14
OS
xdg-open is the name of the command that handles .desktop files (xdg-utils package on debian)


Image
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS
Or "kioclient exec"

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
Haven't tried it yet, but it sounds like the answers I was looking for. Thanks!


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
ivan wrote:xdg-open is the name of the command that handles .desktop files (xdg-utils package on debian)

"$ man xdg-open"
xdg-open opens a file or URL in the user's preferred application.

Is xdg-open supposed to launch the command specified in the *.desktop file or open an editor associated with text files to edit the *.desktop file?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Based on my tests, xdg-open will run the command specified in the *.desktop file - rather than opening the *.desktop file in a text editor. This will automatically occur if it is owned by root, or executable. If it is neither of those two, then the user will be asked to approve the command to run as a security mechanism.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
Ok, looks like it's a bug in kde-open, because `kde-open .local/share/applications/Heroes\ of\ Might\ and\ Magic\ III.desktop` opens a text editor.

Usually, xdg-open invokes some other tool to actually open a file.

https://bugs.launchpad.net/ubuntu/+sour ... bug/378783
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668817

Running Kubuntu 13.10
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Can you check the permissions of "~/.local/share/applications/Heroes\ of\ Might\ and\ Magic\ III.desktop" to see if it is executable?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
bcooksley wrote:Can you check the permissions of "~/.local/share/applications/Heroes\ of\ Might\ and\ Magic\ III.desktop" to see if it is executable?

I am not at home right now, but afair it's not executable. All the desktop files created manually via "Edit applications..." are not executable. Even those installed automatically:
Code: Select all
 vic@vic ~ $ ls -l ~/.local/share/applications
total 32
-rw------- 1 vic vic 395 мая   28  2013 AptanaStudio3.desktop
-rw------- 1 vic vic 339 нояб. 29 15:23 chrome-fhbjgbiflinjbdggehcddcbncdddomop-Default.desktop
-rw------- 1 vic vic 361 июля   4 12:51 eclipse.desktop
-rw------- 1 vic vic 269 окт.  21 13:45 jetbrains-pycharm.desktop
-rw-rw-r-- 1 vic vic 906 нояб. 22 18:38 mimeapps.list
-rw------- 1 vic vic 345 нояб. 11 16:10 skype.desktop
-rw------- 1 vic vic 266 нояб. 18 16:23 SoapUI.desktop
-rw------- 1 vic vic 404 мая   29  2013 sqlworkbench.sh.desktop

And running `kde-open ~/.local/share/applications/sqlworkbench.sh.desktop` opens a text editor.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
If you were to change the permissions of those *.desktop files to make them executable, I suspect the behaviour of kde-open would change to executing the desktop file instead.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
bcooksley wrote:If you were to change the permissions of those *.desktop files to make them executable, I suspect the behaviour of kde-open would change to executing the desktop file instead.

Nope:
Code: Select all
vic@vic ~ $ kde-open ~/.local/share/applications/sqlworkbench.sh.desktop
vic@vic ~ $ chmod +x  ~/.local/share/applications/sqlworkbench.sh.desktop
vic@vic ~ $ kde-open ~/.local/share/applications/sqlworkbench.sh.desktop
vic@vic ~ $ ls -l  ~/.local/share/applications/sqlworkbench.sh.desktop
-rwx--x--x 1 vic vic 404 мая   29  2013 /home/vic/.local/share/applications/sqlworkbench.sh.desktop
vic@vic ~ $

In both cases it just opens an editor.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I'm out of ideas then - there must have been a behaviour change at some point between our respective KDE versions.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot]