- Open up a new file /usr/share/applications/screenlock.desktop. Obviously, you can name this whatever you want, and you will probably want to name it appropriately for whatever application you are adding to your menu, although it must end in .desktop.
- In this new .desktop file, add the following:
[Desktop Entry] Name=ScreenLock Comment=Lock your screen Icon=system-lock-screen Exec=gnome-screensaver-command --lock NoDisplay=false Type=Application Categories=Settings;DesktopSettings
- Obviously, change the name, comment, and icon for whatever you want to add. Most importantly, make sure to update Exec to whatever command it is you actually want to execute. You can change the categories, too, although I have not explored them much and don't really know what categories exist.
- Now you should have a new menu item. If you have a GNOME menu accessible, you should be able go to Menu -> Preferences and see the new ScreenLock entry. However, what I want is to add it to my panel. I'll describe this for lxpanel, but I believe it should be quite similar for the GNOME 3 panel. Start by right clicking on your panel and going to "Panel Settings."
- Click on Panel Applets -> Add and select Application Launch Bar.
- From here, you can select the menu item to execute. In this case, I selected Preferences -> ScreenLock and then clicked Add.
That's about it; you should have a screen lock button in your panel now.