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.
Start by installing desktop shortcuts
sudo apt-get install --no-install-recommends gnome-panel
gnome-desktop-item-edit --create-new ~/Desktop
Create a basic launcher desktop shortcut.
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
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] Version=1.0 Type=Application Name=Sudo Run Icon=gdm-xnest.png Exec=gnome-terminal Terminal=false Actions=Terminal;TerminalRoot;Files;TextEdit;Update [Desktop Action Terminal] Name=Terminal Exec=gnome-terminal --window-with-profile=StayOpen OnlyShowIn=Unity; [Desktop Action TerminalRoot] Name=Terminal Root Exec=gnome-terminal --window-with-profile=StayOpen -x bash -l -c "sudo su;bash" OnlyShowIn=Unity; [Desktop Action Files] Name=Sudo Files Exec=gnome-terminal --window-with-profile=StayOpen --geometry=40x2+1+1 -x bash -l -c "sudo nautilus;bash" OnlyShowIn=Unity; [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" OnlyShowIn=Unity; [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" OnlyShowIn=Unity;
Once complete move file to applications folder, and can be treated as an application.
move file to
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