I tend to find myself opening terminal sessions to run Sudo commands and was wanting to make something more useful as an application.

Using some information from various online sources https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles I came up with my little desktop application.

app right click

Start by installing desktop shortcuts

sudo apt-get install --no-install-recommends gnome-panel 

then run

gnome-desktop-item-edit --create-new ~/Desktop

Create a basic launcher desktop shortcut.

Basic Launcher

Now create a new Terminal Profile called StayOpen

Open Terminal, Select FILE - New Profile, Create New call the new Profile "StayOpen". Then Under Properties Select the tab for Title and Command. At the bottom of this tab select when command exits - Hold the terminal open

Hold Terminal Open

Once your default Desktop file is created you will want to edit it. Example Below:

gedit <Your File name>


My below desktop file script is named "Sudo Run". If you are copy/pasting the script below, you will want to account for that with my file below or it will not run properly.

[Desktop Entry]
Name=Sudo Run

[Desktop Action Terminal]
Exec=gnome-terminal --window-with-profile=StayOpen

[Desktop Action TerminalRoot]
Name=Terminal Root
Exec=gnome-terminal --window-with-profile=StayOpen -x bash -l -c "sudo su;bash"

[Desktop Action Files]
Name=Sudo Files
Exec=gnome-terminal --window-with-profile=StayOpen --geometry=40x2+1+1 -x bash -l -c "sudo nautilus;bash"

[Desktop Action TextEdit]
Name=Sudo Text Edit
Exec=gnome-terminal --window-with-profile=StayOpen --geometry=40x2+1+1 -x bash -l -c "sudo gedit;bash"

[Desktop Action Update]
Name=Sudo Apt-Get Update
Exec=gnome-terminal --window-with-profile=StayOpen -x bash -l -c "sudo apt-get update && sudo apt-get upgrade;bash"

Once complete move file to applications folder, and can be treated as an application.

sudo nautilus

move file to usr/share/applications

Then drag drop to unity launcher if desired. Here is where the bash script becomes useful.

Once the desktop link is on the unity launcher you will have several right click options as listed below in Actions. Note the corresponding actions at the bottom of the file. Several of the bash scripts open a small terminal window just large enough to type in your sudo password. Modify the "geometry=" to your preference or remove if desired. Once the password is typed in you get your application running, etc.

You can change the Actions to sort in your preference and set the default "Exec=" to your left click preference as well

One of the great features of this as a shortcut on your unity launcher is the Right Click "Quit" function which will close all open windows.

-mb: edited to improve readability

  • After recreating your script, I find that the icon changes with the script icon. I'm using 13.04 – SimplySimon Jun 4 '13 at 4:57
  • added a new picture for the first image, but the second image has an invalid url! – SimplySimon Jun 4 '13 at 10:57
  • Note that rather than opening a terminal for sudo, you can use either gksudo or pkexec to show a password dialog if necessary and then start a program as root, eg gksudo nautilus. – chronitis Jun 4 '13 at 12:44
  • 2
    This is NOT a question. If you want to share your learnings, then please ask a question and answer it yourself. – don.joey Jun 4 '13 at 13:05
  • 2
    Hi MB-. Thank you for sharing this piece of info. However, our format works slightly different from a blog post. Can you phrase your question like you are in jeopardy and then move the question content to the answer section? That would be clearer for everyone who are accustomed with our site. Thank you very much. – jokerdino Jun 4 '13 at 18:25

You can change the icon using the Icon option. I guess you knew that already but I'm noticing that you have declared it only on the first entry. Also it is declared twice there which might be conflicting. Remove one of them and see if it works.

Also your icons are given as relative path. I don't know in what folder unity is looking for icons but you have to copy the file there or use an absolute path (e.g. Icon=/home/myuser/myicon.png).

  • " Also it is declared twice there which might be conflicting. Remove one of them and see if it works." ---PERFECT. Thanks for the tip. I removed the line Icon=gnome-panel-launcher – MB- Jun 4 '13 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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