Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I try to add a quicklist launcher for gedit that allowed me to open a new doc in gedit directly from unity dash

so I tried to add this command to my OpenDoc Shortcut Group

[OpenDoc Shortcut Group]
Name=Open file...
Exec=gedit $(zenity --file-selection)
TargetEnvironment=unity

But nothing happens when I click on the quicklist launcher...

Maybe someone know who to do it ?

Best Regards

share|improve this question
    
For now, I find a solution, but it's not a beautiful one. I create a file with the command : 'gedit $(zenity --file-selection)' I save it under '~/.local/share/applications/scripts/gedit/geditzenity' and I allow the file been executed. Then I modify gedit.desktop with this quicklist shortcut : '[OpenDoc Shortcut Group] Name=Open file... Exec=~/.local/share/applications/scripts/gedit/geditzenity TargetEnvironment=unity' and it works. But little bit babarian don't you think ? Maybe someone have a better idea. BR, –  Winael May 3 '11 at 15:31
1  
You should post that as an answer, so that we can vote on it and it doesn't get buried in the comments. –  Jorge Castro May 4 '11 at 0:05

2 Answers 2

up vote 2 down vote accepted

Ok, so finaly I find a great solution for this case.

As I said before in a comments, the better solution is to use a script called with the Ayatana shortcut. This is an exemple of Quicklist launcher for gedit. With it you can open a file in gedit or open a file as root in gedit

The part I add in the gedit.desktop file :

X-Ayatana-Desktop-Shortcuts=OpenDoc;OpenDocRoot;

[OpenDoc Shortcut Group]
Name=Open file...
Exec=/path/to/the/script normal-mode
TargetEnvironment=Unity

[OpenDocRoot Shortcut Group]
Name=Open file as root...
Exec=/path/to/the/script root-mode
TargetEnvironment=Unity

Using a script fine is more easier for testing what we want and do some complex things with the quicklist shortcut.

Now this is the code for the script /path/to/the/script (personally I create a script folder in ~/.local/applications/ folder and create the script geditshortcut in it)

#!/bash/bin

case $1 in
normal-mode) gedit $(zenity --title='Open file...' --file-selection);;
root-mode) gksudo -u root -m "Running Gedit as user root allow you to modify some essential files of your system" "bash -c 'gedit \$(zenity --title=\'Open file as user root...\' --file-selection)'";;
esac

Now Drag & Drop the gedit.desktop file to the launcher bar or Unity and enjoy it ;)

That's all folks !!

share|improve this answer
    
Don't forget double quotes around the command substitution, "$(zenity ...)", otherwise it won't work with filenames containing whitespace among other things. –  geirha Jul 8 '11 at 14:28

Based on your solution in the comments, you could write a more generic script:

#!/bin/bash
$1 $($2)

It would call the first argument with the output of the other, so you could Exec=path/to/my/script gedit "zenity --file-selection" Still a workaround, but easier to reuse in other cases.

share|improve this answer
    
Thx @Egil, In fact, I thank about that this morning. With args option for the script (with a case command in it), I can easly set up lots of quicklist in launcher as, for exemple : #!/bin/bash case $1 in normal-mode) gedit $(zenity --file-selection) su-mode) gksu gedit $(zenity --file-selection) esac and then in launcher I think I can use : [OpenDoc Shortcut Group] Name=Open file... Exec=~/.local/share/applications/scripts/gedit/geditzenity normal-mode TargetEnvironment=unity ==> –  Winael May 4 '11 at 9:16
    
[OpenDoc Shortcut Group] Name=Open file... Exec=~/.local/share/applications/scripts/gedit/geditzenity su-mode TargetEnvironment=unity I'll try it and let you know BR, –  Winael May 4 '11 at 9:18
    
Ok, I test my little workaround and it seems to work fine. That's so great and more easly as I expected :). I'll finish the script and post-it as an Answer to this question. Thx –  Winael May 4 '11 at 14:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.