Shutdown button for Ubuntu dock

I decided to install Ubuntu 19 freshly, as it is inevitable, but also that GNOME has promise. However, some things from unity should be inherited without question. One of those things is that you could simply open dash, search the shutdown button, and place that in the dock which is amazing in case of a touchy laptop.

And now years later, a newer system doesn't provide this. You can find the shutdown function in the app menu, but cannot add it as a favorite. Does someone know how to achieve what I want? There are no extensions to be found either.


Well, you can create a launcher by hand and add to the dock as a workaround. To do that, follow the steps below.

  1. Create a .desktop file (say shutdown-for-dock.desktop) in ~/.local/share/applications/ directory. You can do that by running the following command in Terminal:

    touch ~/.local/share/applications/shutdown-for-dock.desktop
    
  2. Open the file with a text editor, for example by running

    gedit ~/.local/share/applications/shutdown-for-dock.desktop
    

    Then add the following lines to the file:

    [Desktop Entry]
    Name=Shutdown for Dock
    Exec=gnome-session-quit --power-off
    Comment=Shutdown button for Ubuntu dock
    Terminal=false
    Type=Application
    Icon=system-shutdown
    
  3. Save the file.
  4. Click "Activities" or "Show Applications" and search for "Shutdown for Dock". It should appear.

  5. Right click and add to favourites.