Add custom apps to Toolbar, aka “Add to Favorites” in Ubuntu 20.04+

Let’s say you have installed an application using an executable file and not the repositories. If you launch such an application and try to add it to favorites in the Ubuntu dock, you won’t find such an option in the context menu:

no Add to Favorites in Ubuntu

I don’t know why you cannot add to dock custom applications by default. And the only way to add it is to create a launcher manually.

For that, you need to create a yourapp.desktop file in /usr/share/applications/:

sudo nano /usr/share/applications/yourapp.desktop

Paste the following content:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/path/to/yourapp
Name=YourApp
Comment=Description of YourApp
Icon=/path/to/yourapp.png

Replace yourapp with your application and save by pressing Ctrl+OEnter and Ctrl+X.

Make this file executable:

sudo chmod +x /usr/share/applications/yourapp.desktop

Log out and log in.

Open the Ubuntu Dash menu and you should be able to find your custom application in the menu. You can launch it from the menu.

custom app in Ubuntu menu

Also, if right-click on it, you should be able to select “Add to Favorites” and pin it to the dock panel:

Add to Favorites for custom app in Ubuntu

Now, when you close this application, a quick launcher will stay in the dock panel.

Tips for developer from Windows to Linux

Switching developing environment from Windows to Mac is painful for me. There’re many picky settings in MacOS. I’ll keep updating the issues I meet, and hope that can help others.

1. firewall

By default, it has a strict policy for firewall, and may block your application, especially some back-end connections. I was confused why the same code can run in Eclipse on Windows, and exist without error message in Mac.

The solution is quite straightforward for me, turn off firewall by following System Preferences -> Security & Privacy -> Firewall -> Turn Off Firewall. Surely you can keep it on, and update the configuration by open Firewall Options.

2. Screen Saver

In Windows, it’s easy to lock screen by Shift+Control+Delete. In Mac, the choice is keychain.

To enable it, first click the search icon in the right-top banner, and enter keychain in the Spotlight Search. Then, go to Keychain Access -> Preferences, and choose Show keychain status in menu bar. Now you could see the keychain icon in right-top banner as well. By clicking Lock Screen, it’s done.

3. Home/PageUp/PageDown/End

There’s no Home/PageUp/PageDown/End icons in Mac’s keyboard. Now you can use fn key and left/right/up/down arrows to map as below:

  • fn+left_arrow -> Home
  • fn+right_arrow -> End
  • fn+up_arrow -> PageUp
  • fn+down_arrow -> PageDown

4. Screen Grab

It’s very easy to grab any part of screen now with Mac, with Shift+Command+4, you can choose any part, and save a PNG file in Desktop automately.

5. open multiple Eclipse

By simply click Eclipse icon with Launchpad, you can only open one Eclipse. To open more than one instance, it’s doable using terminal:

cd /Applications/Eclipse.app/Contents/MacOS
./eclipse &