Adding LXDE start menu entries and desktop shortcuts

Update: this post has been viewed more than 2,000 times, but no-one left a comment. It took me 2 hours to write it and it will only take you 2 minutes to leave a comment… what are you waiting for ?

Note: if you want to instead create a new start menu section or sub-sections (ie: “sub-menus”), check this post.

First, a screenshot to explain what I mean by “desktop shortcut”, “start menu section” and “start menu sub-section” (click on the image if you want to correctly see it):

menu_3

Adding start menu entries and/or desktop shortcuts (launchers) in LXDE is certainly not as easy as under Windows.

I’ve recently installed the cool hardinfo tool which is an application that lists all your computer hardware. Unfortunately, the hardfo installer doesn’t add any menu entry in the LXDE start menu (I’m talking about the one that is displayed when you click on the button located at the bottom left of your desktop).

OK, let’s add a menu entry for hardinfo by ourselves.

1. Adding a new menu entry

All menu entries correspond to a .desktop file, and these .desktop files can be in one of the following locations:

  • /usr/share/applications
  • /usr/local/share/applications
  • ~/.local/share/applications (note that this folder may not exist on a brand new LXDE installation, but you can create it manually)
[laurent@localhost applications]$ ll /usr/share/applications
total 460
-rw-r--r--. 1 root root  9693 Feb 18 20:18 authconfig.desktop
-rw-r--r--. 1 root root   177 Apr 20 05:11 eekboard.desktop
-rw-r--r--. 1 root root  1699 Feb 27 22:31 fedora-abiword.desktop
-rw-r--r--. 1 root root  6001 May 10 15:07 fedora-abrt.desktop

Creating a new menu entry simply means creating a new .desktop file. The format is detailed here or there, but you can choose to use the existing .desktop files that you have as a template.

Since .desktop files can be located in 3 different folders, which one should you use ? I suggest that you create your .desktop file in the ~/.local/share/applications folder. This way, the shortcuts that you create will not impact other users.

LXDE ships with a .desktop file editor called LXShortcut. It’s the application that is launched when you right click on a menu entry and choose the “Properties” option:

However, I think that this tool sucks for creating new menu entries. Here is why:

  • There is no way to create a .desktop file from the LXShortcut GUI: you need to specify the filename on the command line (“-o” option)
  • It uses different command line options to create (-o) and to edit (-i) .desktop files.
  • There is no way to edit the category name (ie: “where the entry is going to be located in the menu”).

For all these reasons, it’s just easier to use a text editor to create your .desktop file.

Here is mine:

[laurent@localhost applications]$ cat ~/.local/share/applications/hardinfo.desktop

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Hardware info
Name[en_US]=Hardware info
Exec=/usr/bin/hardinfo
Comment[en_US]=Hardware info
StartupNotify=true

As you can see, the ‘Exec’ property contains the location of the ‘hardinfo’ application.

Now launch “lxpanelctl restart” so that LXDE picks up your changes:

[laurent@localhost applications]$ lxpanelctl restart

Et voilà:

By default, your new menu entry is part of the ‘Other’ category.

What if you want to put in another category ? That’s where the ‘Categories’ property comes into play: valid values for this property are listed here.

Note that the ‘freedesktop’ categories do not directly map to the LXDE category names, so here is the mapping between LXDE categories and freedesktop categories:

  • Accessories <-> Utility
  • Graphics <-> Graphics
  • Internet <-> Network
  • Office <-> Office
  • Sound & Video <-> AudioVideo
  • System Tools <-> System

So if you want your shortcut to be part of the LXDE ‘Accessories’ category, you need to add the ‘Categories=Utility’ property:

[laurent@localhost applications]$ cat ~/.local/share/applications/hardinfo.desktop

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Hardware info
Name[en_US]=Hardware info
Exec=/usr/bin/hardinfo
Comment[en_US]=Hardware info
StartupNotify=true
Categories=Utility

2. Adding an application shortcut on your desktop

To add a shortcut on your desktop, right click on an existing menu entry and choose the ‘Add to desktop’ option.

In practice, this simply puts a copy of an existing .desktop file in the $HOME/Desktop folder:

[laurent@localhost ~]$ ll $HOME/Desktop
total 4
-rw-------. 1 laurent laurent 165 Jun 28 17:53 hardinfo.desktop

This means that if you want to create a desktop shortcut for an application that is not in your start menu, you just need to create a .desktop file in $HOME/desktop, as explained in the previous chapter.

Alternatively, you can right-click anywhere on your desktop and choose the “Shortcut” option: this will launch the “LXShortcut” tool.

3. Adding a folder shortcut on your desktop

This time, right clicking on your desktop and choosing “Create new > Shortcut” will not work since this can only be used to create application shortcut.

To create a folder shortcut, you need to manually create a .desktop file in the ~/Desktop folder.

For example, a shortcut for the /home/laurent/Documents folder would look like this:


[laurent@localhost Desktop]$ cat ~/Desktop/myOtherShortcut.desktop

[Desktop Entry]
Encoding=UTF-8
Type=Application
Icon=system-file-manager
Name=My Folder Shortcut
Exec=pcmanfm /home/laurent/Documents

Comment[en_US]=

Basically, we are are just asking pcmanfm to open the “/home/laurent/Documents” folder. Also, I’m using the pcmanfm “system-file-manager” icon, but you can choose to use any icon that you want.

3. Changing the shorcut icon

OK, one more LXDE madness: it looks like the icons can either be located in /usr/share/pixmaps or in /usr/share/icons.

I guess I need to study this and create a new post… stay tuned 😉

Laurent KUBASKI

Killing a hanged Windows service

A hanged service looks like this (as you can see, all Start/Stop/Pause/Resume buttons are disabled):

To kill this service, first note the service name. On the screenshot above, it is ‘EntropySoftCFS’ (ie: the first thing displayed in the “General” tab).

Then, open a DOS shell and run the ‘sc queryex’ command to retrieve the service PID, then use the ‘taskkill’ command to… well, kill it !

C:\>sc queryex EntropySoftCFS

SERVICE_NAME: EntropySoftCFS
TYPE               : 10  WIN32_OWN_PROCESS
STATE              : 2  START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN))

WIN32_EXIT_CODE    : 0  (0x0)
SERVICE_EXIT_CODE  : 0  (0x0)
CHECKPOINT         : 0x1
WAIT_HINT          : 0xbb8
PID                : 3756
FLAGS              :

C:\>taskkill /PID 3756 /F
SUCCESS: The process with PID 3756 has been terminated.

Laurent KUBASKI

Solving the mySQL “The security settings could not be applied” error

Yesterday I got this error message during the last step of the MySQL Windows installer: “The security settings could not be applied to the database because the connection has failed with the following error”.

The issue can be solved issue this procedure from the MySQL website.

First, cancel the wizard and make sure that the MySQL service is stopped.

Then, create a text file using a SQL query that will reset the root password.

UPDATE mysql.user SET Password=PASSWORD('admin') WHERE User='root';
FLUSH PRIVILEGES;

Then, launch mySQL using the following command line:

mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server 5.5\my.ini" --init-file="C:\mysql-init.txt" --console

Note: it’s better to use the ”–console” option so that error messages are correctly displayed.

Finally, open a new DOS shell and execute the following command line to shutdown mySQL:

mysqladmin -u root -p shutdown

You can now restart the mySQL installer and choose the “Repair” option:

 

Laurent KUBASKI