26

Is there a utility I can use to add an icon to the Cinnamon menu which runs a user-specified command, and as a bonus, displays a user-specified icon?

specifically I'm trying to add a command to open a virtual machine directly, without having to keep the terminal open.

VirtualBox --startvm <myMachineName> --seamless

works fine with alt-F2, but I'd rather have a short-cut so I don't have to type it out.

Raja G
  • 100,643
  • 105
  • 254
  • 328
ataulm
  • 385
  • 1
  • 3
  • 8

4 Answers4

51

or you could just use the

cinnamon-menu-editor

(Also available by right clicking the start button, selecting configure and Open the menu editor.)


Tip: When adding a custom icon, be careful to locate the icon image somewhere you won't be likely to change in the future.

Elliptical view
  • 1,522
  • 17
  • 17
mockfrog
  • 511
  • 1
  • 4
  • 2
25

You can create a .desktop file to add your command to the Cinnamon menu.

First, create a little script eg: In your home directory

  • Open your terminal and type:

    gedit /home/user/myvm.sh
    
  • Type the following:

enter image description here

  • Save the file in your home directory and change the permissions with:

    chmod 775 /home/user/myvm.sh
    
  • Then you can create a desktop file, in the terminal type:

    cd /usr/share/applications
    sudo -H gedit myvm.desktop
    
  • Add the following information:

enter image description here

  • Save the changes and make sure the .desktop has the right permissions, in the terminal type:

    sudo chmod 644 /usr/share/applications/myvm.desktop
    

You can change the information according to your needs, in this case in the field "Icon" put your path to your custom icon, and this should be visible under the Cinnamon menu in the category "System Tools" with the name "My VM".

enter image description here

If you want, you can add it to your cinnamon panel with right click in the icon "My VM" in the Menu, and then choose "add to panel"

enter image description here

Zanna
  • 69,223
  • 56
  • 216
  • 327
Roman Raguet
  • 9,473
  • 2
  • 40
  • 40
  • 2
    beautiful instructions, the screenshots were not needed but very appreciated :) – ataulm Dec 23 '12 at 16:36
  • 7
    As mentioned by [childno͡.de's answer](https://askubuntu.com/a/897698/373707), using `~/.local/share/applications` won't need root privileges if you don't need to add shortcuts for all users. – jamesdlin Jun 15 '18 at 17:33
  • Though I was aware of the entire process (I always use the `~/.local/share/applications` pointed out by James), for one app it didn't seem to work. The important step there was the `chmod`: the `.desktop` file in my case had `744` and didn't show up in the menu until I changed it to `644` as you described. That did the trick! Funnily, `755` works fine as well, seems it just does not like `744`… – Izzy Apr 24 '20 at 06:55
4

Simply create a gnome desktop link and place it in .local/share/applications/ for personal menu links.

Sigh: some installers install their desktop links into .gnome/apps/ so you might want to link them: $ ln -s .gnome/apps/*.desktop .local/share/applications/


As pointed out by @roman-raguet https://askubuntu.com/a/232083/37280 place it into /usr/share/applications for all users

As pointed out by @mockfrog https://askubuntu.com/a/800605/37280 you might create this personal entry by cinnamon-menu-editor graphical tool. Run it with sudo for all-users

childno͡.de
  • 141
  • 2
1

For anyone else looking for a simpler solution, then the following offers a GUI interface for adding custom launchers to your panel:

cd /usr/share/cinnamon/applets/panel-launchers@cinnamon.org/
./cinnamon-add-panel-launcher.py
Chris Knight
  • 111
  • 3