How to add SSH menu to Unity launcher

I am currently using latest Ubuntu on Dell XPS 13. It works great and using it is a real pleasure. However, after a while I got an idea to add simple SSH menu to Unity launcher for enhanced usability.

Shell script

Create shell script to generate and display list of available SSH servers using zenity utility and ~/.ssh/config user configuration file.

# Create menu for SSH servers using zenity utility

# get SSH servers
ssh_servers=$(awk '/^Host / {print $2}' ~/.ssh/config)

# print SSH menu
server=$(echo "$ssh_servers" | zenity --list --title "Quick SSH menu" --text "Choose SSH server"  --column "Server" 2>/dev/null)

# execute action
gnome-terminal --command "ssh $server"

Store it as ~/bin/ file and set executable bit.

Desktop file

Create desktop entry file to use above-mentioned shell script and define additional quickly accessible menu.

[Desktop Entry]
Name=SSH servers 

[Desktop Action ServerA]
Name=Connect to router at home
Exec=gnome-terminal -e "ssh -l root"

[Desktop Action ServerB]
Name=Connect to knowledge base at home
Exec=gnome-terminal -e "ssh"

[Desktop Action ServerC]
Name=Connect to OSMC at home
Exec=gnome-terminal -e "ssh -l pi"

[Desktop Action ServerD]
Name=Connect to web server
Exec=gnome-terminal -e "ssh"

Store it as ~/.local/share/ssh_menu.desktop file and use desktop-file-validate command to validate its contents.

Do not forget to update path to the shell script.

Unity launcher

The last step is to add created desktop entry file to the Unity launcher. You can do this by hand (drag file to launcher) or just execute following command.

$ gsettings set com.canonical.Unity.Launcher favorites \
  "$(gsettings get com.canonical.Unity.Launcher favorites | \
     sed "s|\]|,'application://ssh_menu.desktop'&|")"


Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland