Ubuntu – Add unity quicklist launcher with a zenity command

launcherunityunity-dashzenity

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

Best Answer

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 !!

Related Question