Articles Hierarchy

Articles Home » RPI » RPI_GUI desktop menu

RPI_GUI desktop menu

RPI_GUI development
subject: desktop menu
link from RPI to learn GUI programming
8: RPI Desktop,Menu system
9: easy autostart example with GUI
10: update menu entry


8: RPI Desktop,Menu system
desktop intro:
the basics are
menu / menu directory / program : can right click and ADD TO DESKTOP
or
on header line background, right click, add / remove panel items
in window Panel Preferences / Tab: Panel Applets / Entry: Application Launch Bar: double click
in window Application Launch Bar
can select at right every program from menu directories and with ADD
show it in the Lauch Bar ( windows call it TaskBar )
that's where you can start a program with ONE CLICK only.


-8a- my_raspi_config_remember icon
in RPI forum was the beginner question how to start something by a desktop icon.
in one case it was the "sudo raspi-config" for easy setup. ( argumentation was: i might forget the terminal command after some time" well, for me this is valid, the experts think differently )
to make it short: if you want a icon on the destop:
sudo nano /home/pi/Desktop/raspi_config.desktop
to make it in the Menu/Accessories
sudo nano /usr/share/raspi-ui-overrides/applications/raspi_config.desktop
[Desktop Entry]
Type=Application
Comment=Raspi-Configuration Tool
Name=Raspi-Config
Exec=lxterminal -e 'sudo /usr/bin/raspi-config'
Icon=obconf.xpm
Terminal=false
Categories=Utility
StartupNotify=true

you will find this example also in the /home/pi/GUI_test/KLL/ directory.

a other example, what breaks all rules, would be to copy the lxterminal.desktop to your Desktop and edit it to
Exec=sudo lxterminal --geometry=80x30
and again adjust some preferences



what i do miss from the reduced RPI LXDE menu is the
"all programs (list)"
first i go with filemanager to /usr/share/applications
select "File Manager PCManFM"(.desktop) / open/edit with leafpad, / save as
/home/pi/Desktop/apps.desktop change:
Name=APPS
Name[en_GB]=APPS
Categories=System;
Exec=pcmanfm /usr/share/applications/

and now you can test it from desktop. and with
sudo cp /home/pi/Desktop/apps.desktop /usr/share/applications/apps.desktop
copy it back and go menu/System Tools/ and find your new APPS icon



-8b- above was the open point how to enlist your own new GUI program into the Menu?
Until now i used only /home/pi/Desktop/ and made a new directory KLL/ and in there i hold my xxx.desktop files.

what is actually one click more as when they are on the Desktop, but when you click the KLL subdir,
you get much more as just the icons, you are operating the filemanager PCManFM.

in the new RPI system there is only the "wastebasket" icon, and the MENU button in headerline links to a Category list you can find in /usr/share/desktop-directories/ ; example there is a icon called Accessories ! but it is the file: lxde-utility.directory
and in /usr/share/applications/ are the program icons, like the FILEMANAGER:
icon File Manager PCManFM, but filename is pcmanfm.desktop : content: Type=Application, Exec=pcmanfm %U, Categories=...Utility;...
so when you make your own MENU entry you must do
cd /usr/share/applications/
sudo nano myapplication.desktop with ... Categories=Utility;
( in terminal window of desktop ) lxpanelctl restart ( with PUTTY ) sudo reboot and you will find it under [Menu][Accessories]
Now, where is the linking Accessories to Utility, that's tricky but if i want make my own Category i need to learn: in
/etc/xdg/menus/lxde-pi-applications.menu is that link.

now, we do not want to fiddle with that, because at any update/upgrade it might be overwritten.
besides, when i install a program like Arduino IDE, how does that work regarding menu?
i found lots of connected files, can not know if that's all, but did not find the icon for the "electronics" menu directory?
in above file is no ref. to electronics, so how that menu directory and item is included?
sudo nano /usr/share/extra-xdg-menus/kll.menu makes include category KLL
sudo nano /usr/share/applications/myapplication.desktop change to new category KLL
still no change! now i go
cd /etc/xdg/menus/applications-merged/ here make a symlink to the new menu.
sudo ln -s /usr/share/extra-xdg-menus/kll.menu kll.menu
lxpanelctl restart
But when i tried to make my own menu.directory ( by copy, rename, NAME change, icon change )
sudo nano /usr/share/desktop-directories/kll-tools.directory with
Name=KLL tools ( the text i want in the MENU group (directory) line )
Icon=preferences-system-network ( also used by Internet and network directory, until i have my own icon )
Type=Directory
RPI not take it, text was good, Category link good ( i see my applications already )
icon was wrong ( some default? )and the MENU properties show strange things, NO FILE, NO LOCATION,but 7GB??


possibly one step missing, what i do here looks more and more like a HACK and not ADMIN work.
so better ask the PROS at the forum
ok, already found it: i make: sudo nano /usr/share/menu/kll-tools without much content

now have full MENU control.
When i downloaded a myicon.ico and configured it at the kll-tools.directory it did not work,
arduino use Electronics.directory with icon=applications-electronics, and now i also found these:
like /usr/share/icons/hicolor/32*32/categories/apllications-electronics.png
while /usr/share/icons/hicolor/32*32/apps/arduino.png is the application icon.
but also under /usr/share/pixmaps/arduino.xpm
i check both as test icon for my directory and they worked, so looks like its just the .ico type what does not work.
on PC i start GIMP ( what is a python program!! ) made background ( not usual for that icons )
and 3 characters K L L and export as KLLicon.png and copy to RPI: /usr/share/pixmaps/ and change
/usr/share/desktop-directories/kll-tools.directory to icon=KLLicon.png ( no path required)

long way but all works now!
i had to work over all the ".desktop" files regarding icon and category
and deleted / replaced redundant files by symlinks.

oh, i found a other directory what might be the one what makes the new RPI menu entries:
ls /usr/share/raspi_ui_overrides/applications/
but seems to be no problem i have my symlinks to my desktop files under /usr/share/applications/


update on menu: 07/2015
in the forum was that question again and i had to check on how i did it above.
the OP got it running by editing the
/etc/xdg/menus/lxde-pi-applications.menu
i worry it would got overwrite by a system update.
also i see it from the viewpoint of a software developer who has to deliver a install script to do that without damaging any system settings.
but the only program, what is doing a add main menu item, i know of, is arduino, so i look how its done there.
between above test and now i learned about the
/usr/share/raspi-ui-overrides/applications/ RPI specific LXDE DEBIAN adaptions.
but when i wanted to use that instead of the
/usr/share/applications/MYPROGRAM.desktop it did not work!
in this code text you find lines what show the file ( like 'ls myfile' )
lines what show what to do 'sudo mkdir ...' 'sudo nano ...'
and a 'cat myfile' ( so you can easy copy paste to putty all commands and code! and not need to type anything ).
pls find it here and it looks like
( the python example is not included )



update 18.8.2015 see here a LXDE Menu edit tool and download here but it does not reflect the changes made for RPI ( /etc/xdg/menus/lxde-pi-applications.menu, /usr/share/raspi-ui-overrides/applications/ )
so not useful.


##
9: easy autostart example with GUI
i made a kind of framework
in /home/pi/service_GUI/ have a empty
service.py ( inside need your job )
now pls do not get confused by the title here, this service (.py) program ( you want to make )
is / must be a background program, can not have GUI operation.
you want that background program to start / run ( continuously ) at boot.
for autostart of this service.py need file
service ( must go /etc/init.d/ ), easy can do by execute
./service_make_autostart.sh
but you also want be able to stop and start and check it, for that is the GUI / a bash zenity tool /
service.sh ( for start zenity service operation / much better version now!)
service.desktop ( for start service.sh tool by mouse click )
i zip with
cd /home/pi/
tar cvf service.tar service_GUI
xz -zv service.tar
you can load it to RPI with

wget http://kll.engineering-news.org/kllfusion01/downloads/service.tar.xz

for unzip use
cd /home/pi/
tar xvf service.tar.xz

revision V2 also install and remove of service by zenity tool



10: update menu entry
UPDATE 08.08.2017
looking for the way to:
ONE CLICK start python program from 4um
!! the first line in a python program
#!/usr/bin/python3
and the make it executable
chmod +x hallo_world.py
only work together

and find a new way to make your own menu entry
nano ~/.local/share/applications/my-hallo_world.desktop[Desktop Entry]
Encoding=UTF-8
Comment=python from menu
Name=hallo_world
Type=Application
Terminal=true
Icon=web-browser.png
Categories=KLL_tools;
Exec=/home/pi/Desktop/hallo_world.py

nano ~/.local/share/desktop-directories/my-KLL_tools.directory[Desktop Entry]
Encoding=UTF-8
Comment=my tools
Type=Directory
Name=KLL_tools
Icon=gksu

xdg-desktop-menu install ~/.local/share/desktop-directories/my-KLL_tools.directory ~/.local/share/applications/my-hallo_world.desktop

for a update a
lxpanelctl restart
more easy as a reboot


the "_" from
Name=hallo_world
Name=KLL_tools
are not shown in desktop menu, but the linking
Categories=KLL_tools;
Name=KLL_tools
works!