Tritonio

How to customize lxde menu?

Mar 15th, 2021 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.18 KB | None | 0 0
  1. Hello,
  2.  
  3. I would like to know how could I add a custom category in lxde menu.
  4. I already know how to add or modify applications changing .desktop entries under /usr/share/applications.
  5.  
  6. What I would like to do is to add a complete new category on the menu and choose its position, for example "My Staff" after "Office" or "My Apps" before "Accessories" and then populating it by changing .desktop entries under /usr/share/applications.
  7.  
  8. I tried to undesrtand something changing things under /etc/xdg/menus but I came to no point.
  9.  
  10. I also discovered a useful tool to edit menu called lxmed
  11. http://lxmed.sourceforge.net/
  12. and using it I discovered I had hidden categories on my menu,
  13. for example there's a category called "Other" which is not shown on my menu.
  14.  
  15. So: how can I (also) make visible hidden categories? Or viceversa how can I hide visible categories?
  16.  
  17. Last thing: is it possible to add sub-categories?
  18. I mean category: Internet > subcategory: Browsers > applications: Chrome, Firefox, Opera
  19.  
  20. and so on.
  21.  
  22. Thanks for any help!
  23.  
  24.  
  25.  
  26.  
  27. It's probably easier to just change the menu in leafpad. You can add a menu to the layout by inserting something into the layout like:
  28.  
  29. Code:
  30.  
  31. <Menuname>Faves</Menuname>
  32.  
  33. Then define the menu like this:
  34.  
  35. Code:
  36.  
  37. <Menu>
  38. <Name>Faves</Name>
  39. <AppDir>dir</AppDir>
  40. <Include>
  41. <All></All>
  42. </Include>
  43. </Menu>
  44.  
  45. Then, any .desktop file you copy into the "dir" subfolder (of the folder where you store this .menu file) will appear in your submenu.
  46.  
  47. Help yourself: Ubuntu Docs - Ubuntu Packages
  48.  
  49.  
  50. Thanks for your tip.
  51.  
  52. Yes: that's was my idea too, but I haven't understood which is the menu file to change.
  53.  
  54. Could you point me to the right file?
  55. Thanks
  56.  
  57.  
  58. If there isn't already a file in ~/.config/menus you should create that folder and copy one of the menus from /etc/xdg/menus into it first. Then edit the copy.
  59.  
  60.  
  61. Ok, many thanks for having pointed me to the right direction.
  62.  
  63. I' ve found a working way to solve it, it's a little bit tricky, so not so easy, but it works.
  64.  
  65. First of all I noticed it requires to have installed alacarte, I don't know what change this does but that's it.
  66. Maybe someone could explain me that, it would be great to know.
  67.  
  68. So, for future reference, here's my howto to have a new main category with its sub-category on the menu:
  69.  
  70. 1.
  71. As said install alacarte
  72. Code:
  73.  
  74. sudo apt-get install alacarte
  75.  
  76. 2.
  77. create a new file lxde-applications.menu under ~/.config/menus
  78. Code:
  79.  
  80. touch ~/.config/menus/lxde-applications.menu
  81.  
  82. edit it and add the follow:
  83. Code:
  84.  
  85. leafpad ~/.config/menus/lxde-applications.menu
  86.  
  87. HTML Code:
  88.  
  89. <!DOCTYPE Menu
  90. PUBLIC '-//freedesktop//DTD Menu 1.0//EN'
  91. 'http://standards.freedesktop.org/menu-spec/menu-1.0.dtd'>
  92.  
  93. <Menu>
  94. <Name>Applications</Name>
  95. <MergeFile type="parent">/etc/xdg/menus/lxde-applications.menu</MergeFile>
  96. <Directory>lxde-menu-applications.directory</Directory>
  97. <!-- Read standard .directory and .desktop file locations -->
  98. <DefaultAppDirs/>
  99. <DefaultDirectoryDirs/>
  100. <!-- Read in overrides and child menus from applications-merged/ -->
  101. <DefaultMergeDirs/>
  102. </Menu>
  103.  
  104. 3
  105. create a new file scripts.menu under ~/.config/menus/applications-merged/
  106. Code:
  107.  
  108. touch ~/.config/menus/applications-merged/scripts.menu
  109.  
  110. edit it and add the follow:
  111. Code:
  112.  
  113. leafpad ~/.config/menus/scripts.menu
  114.  
  115. HTML Code:
  116.  
  117. <!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
  118. "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
  119.  
  120. <Menu>
  121. <Name>Applications</Name>
  122. <Menu>
  123. <Name>MY Scripts</Name>
  124. <Directory>scripts.directory</Directory>
  125. <Include>
  126. <Filename>scripts-app1.desktop</Filename>
  127. </Include>
  128. <Menu>
  129. <Name>Scripts Folder</Name>
  130. <Directory>scripts-folder.directory</Directory>
  131. <Include>
  132. <Filename>scripts-app2.desktop</Filename>
  133. </Include>
  134. </Menu>
  135. </Menu>
  136. </Menu>
  137.  
  138. 4
  139. create a new file scripts.directory under ~/.local/share/desktop-directories/
  140. Code:
  141.  
  142. touch ~/.local/share/desktop-directories/scripts.directory
  143.  
  144. edit it and add the follow:
  145. Code:
  146.  
  147. leafpad ~/.local/share/desktop-directories/scripts.directory
  148.  
  149. HTML Code:
  150.  
  151. [Desktop Entry]
  152. Encoding=UTF-8
  153. Icon=utilities-terminal
  154. Type=Directory
  155. Name=Scripts
  156.  
  157. 5
  158. create a new png icon under
  159. ~/.local/share/icons/
  160. and call it scripts-app1.png
  161.  
  162. 6
  163. create a new file scripts-app1.desktop under ~/.local/share/applications/
  164. Code:
  165.  
  166. touch ~/.local/share/applications/scripts-app1.desktop
  167.  
  168. edit it and add the follow:
  169. Code:
  170.  
  171. leafpad ~/.local/share/applications/scripts-app1.desktop
  172.  
  173. HTML Code:
  174.  
  175. [Desktop Entry]
  176. Type=Application
  177. Name=Scripts First Application
  178. Comment=Here your comment
  179. Exec=lxterminal %u
  180. Icon=scripts-app1
  181. Categories=PackageManager;GTK;
  182.  
  183. 7
  184. create a new file scripts-folder.directory under ~/.local/share/desktop-directories/scripts-folder.directory
  185. Code:
  186.  
  187. touch ~/.local/share/desktop-directories/scripts-folder.directory
  188.  
  189. edit it and add the follow:
  190. Code:
  191.  
  192. leafpad ~/.local/share/desktop-directories/scripts-folder.directory
  193.  
  194. HTML Code:
  195.  
  196. [Desktop Entry]
  197. Type=Directory
  198. Name=Scripts Folder
  199. Icon=folder
  200.  
  201. 8
  202. create a new png icon under
  203. ~/.local/share/icons/
  204. and call it scripts-app2.png
  205.  
  206. 9
  207. create a new file scripts-app2.desktop under ~/.local/share/applications/
  208. Code:
  209.  
  210. touch ~/.local/share/applications/scripts-app2.desktop
  211.  
  212. edit it and add the follow:
  213. Code:
  214.  
  215. leafpad ~/.local/share/applications/scripts-app2.desktop
  216.  
  217. HTML Code:
  218.  
  219. [Desktop Entry]
  220. Type=Application
  221. Name=Scripts Second Application
  222. Comment=Here your comment
  223. Exec=lxterminal %u
  224. Icon=scripts-app2
  225. Categories=PackageManager;GTK;
  226.  
  227.  
  228. Then you have to refresh you lxpanel by loggin out and in again or by killing it and restarting it.
  229. Code:
  230.  
  231. killall lxpanel
  232. lxpanel
  233.  
  234. To complete you can use alacarte to hide/show your categories/sub-categories/elements
  235.  
  236. I still haven't worked on this to know how it does it,
  237. maybe in the future I will investigate on it or maybe someone can help me in that.
  238.  
  239. For now this works for me!
  240. Hope this may help.
  241.  
  242. Cheers
  243.  
  244.  
  245. That looks like a lot of trouble just to avoid understanding how the Layout or Include tags work. But if it works, it works. Good job.
Add Comment
Please, Sign In to add comment