How to trigger system shutdown in Ubuntu from Unity launcher

While shutting down (or other similar operations like restarting and logging-out) aren't difficult to launch in Ubuntu (you can find them in the Gear system menu on top-right corner of your desktop), some users - for whatever reason - may want to have a Unity Launcher icon for them.

In this tutorial, we will explain how you can quickly add a shutdown/restart/log-off icon to Unity launcher in Ubuntu. Please note that all the instructions mentioned here have been tested on Ubuntu 16.04LTS.

Add system shutdown icon in Unity launcher

For this, the first step is to create a file named shutdown.desktop in your Ubuntu system's ~/.local/share/applications directory. Once that is done, add following lines to the newly-created file:

[Desktop Entry]
Categories=Application;System;
Comment=To shutdown the computer
Encoding=UTF-8
Exec=gnome-session-quit --power-off
Icon=system-shutdown
Name=Shutdown-Button
NoDisplay=false
StartupNotify=false
Terminal=false
Type=Application

Now, in your file browser, open the directory which contains the shutdown.desktop file. Here, right click on the file icon, then click Properties option, and then in the Permissions tab, enable the 'Allow executing file as program.'

shutdown-button-launcher-create

After this, just drag and drop the file icon on to the launcher bar, and you'll see the icon gets placed there.

shutdown-icon-in-launcher

That's it. Now, whenever you'll click this icon, shutdown as well as related options will appear on your screen.

shutdown-icon-in-launcher-working

Via