Custom context menu actions for Unity on Ubuntu

I have this problem occasionally, (read: multiple times, daily) where I’ll be RDP’d into a server and Remmina decides to lock up. When this happens, it simply won’t respond to anything other than a good old-fashioned kill -9. Assuming it didn’t take Xorg with it when it crashed, which also happens sometimes, I normally open a terminal and issue the standard kill -9, restart remmina, log back into any RDP sessions, and anxiously wait for it to happen again. The remmina icon in Unity has a Quit context option, but that never seems to work when this happens.

Remmina's "Quit" context menu option

Remmina’s “Quit” context menu option

So in the interests of eliminating a step, and some keystrokes, I’ve added my own “quit” context menu option that runs the following command:

pgrep remmina | xargs kill -9

Here’s what it looks like, from the context menu:

My custom "Quit" context menu option

My custom “Quit” context menu option

Adding this option was surprisingly easy. I saw more than a few examples of how to accomplish this, and they all started with Install ubuntu-tweak as the first step, which feels a bit heavy-handed to me. Here’s how I did it:

  1. Find the remmina.desktop launcher file. Normally it is located here: /usr/share/applications/remmina.desktop
  2. Open it in your favorite text editor, find the following line:
    Actions=Profile;Tray;
    

    … and modify it to look like this:

    Actions=Profile;Tray;Kill;
    
  3. Then scroll down to the bottom of the file and insert these lines. The Name line determines how the option is displayed in the context menu. Modify it to your liking; I like it when programs swear at me, so mine looks like this:
    [Desktop Action Kill]
    Name=Kill -9 this muthafucka!
    Exec=sh -c "pgrep remmina | xargs kill -9"
    
  4. Save the file, and if you’ve followed my instructions to the letter, remmina’s context menu will now swear at you too.
  5. Here’s what my complete remmina.desktop file looks like after the modifications:
    [Desktop Entry]
    Version=1.0
    Name=Remmina
    GenericName=Remote Desktop Client
    X-GNOME-FullName=Remmina Remote Desktop Client
    Comment=Connect to remote desktops
    TryExec=remmina
    Exec=remmina
    Icon=remmina
    Terminal=false
    Type=Application
    Categories=GTK;GNOME;X-GNOME-NetworkSettings;Network;
    Actions=Profile;Tray;Kill;
    Keywords=VNC;XDMCP;RDP;
    X-Ubuntu-Gettext-Domain=remmina
    
    [Desktop Action Profile]
    Name=Create a New Connection Profile
    Exec=remmina --new
    
    [Desktop Action Tray]
    Name=Start Remmina Minimized
    Exec=remmina --icon
    
    [Desktop Action Kill]
    Name=Kill -9 this muthafucka!
    Exec=sh -c "pgrep remmina | xargs kill -9"