How to escape spaces in .desktop files Exec line

Posted by nh2 on Ask Ubuntu See other posts from Ask Ubuntu or by nh2
Published on 2012-09-17T16:03:25Z Indexed on 2013/11/12 4:18 UTC
Read the original article Hit count: 408

Filed under:
|
|
|

I want to make a .desktop file like described here.

[Desktop Entry]
Name=Sublime Text 2
GenericName=Sublime Text 2
Comment=Edit text files
Exec=/home/user/opt/sublime/Sublime Text 2/sublime_text %U

However, running that from Nautilus's context menu using Open with this gives me

Could not find '/home/user/opt/sublime/Sublime'

So I tried

Exec="/home/user/opt/sublime/Sublime Text 2/sublime_text" %U

and got

Text ended before matching quote was found for ". (The text was '"/home/user/opt/sublime/Sublime')

What is the correct way to escape spaces in the Exec line of .desktop files?

© Ask Ubuntu or respective owner

Related posts about gnome

Related posts about nautilus