Just because you (or any other user) may benefit from having a "quick and dirty" way to add the applications you want to the start of the Fluxbox menu, and because I don't want to waste the work that went into patching together that script, here goes the code to "add_quicklauncher_to_menu.sh"...
Before running it, please back up your "~/.fluxbox/menu-mx" file.
This is the fastest way ( scroll down the list, if needed, then a double click) that I thought of for adding a quick launcher, easy to access, to the start of the menu, without digging around for the application you want.
The menu entry name is extracted from the .desktop file name (not parsed from the .desktop file contents), so, if you want, manually edit the menu-mx file to edit the entry's name...
Depending on your resolution you can add as many "pinned" apps to the top of Fluxbox as you like. In my case I have j4-dmenu, Firefox, File Manager, Terminal, Writer, Recent Files, All Categories, and then it's basically the stock menu, with a few alterations...
Note: If you want to delete/change the order of any menu entries, do so manually (it's pretty intuitive, editing the text file) or using the "FluxBox menu editor" I previously mentioned. that allows non "geek" users to add and remove applications to the MX-Fluxbox menu without having to know how to edit a single line of the configuration files...
Example: if you use Libre Office Writer a lot and want a quick way to access it without manually editing the menu: run this script, scroll down until you find "libreoffice-writer" and double left click it (or click once and then the "ok" button). A entry that launches writer, called "libreoffice-writer" is added to the start of the menu.
Now to start LibreOfice Writer just open the menu and click the very first entry... If you are using the keyboard to summon the FluxBox menu it's insanely fast: summon the menu - down key - enter. If using the mouse, it's not as fast as clicking a quick launch icon on the toolbar (yeah, I also have those on my personalized Fluxbox toolbar- see how to do that in my older posts): summon the menu (a rootmenu icon on the toolbar is useful) and then click the name of your application.
EDIT: @Buck- you can have the same functionality as having quick launch icons on the toolbar, using idesk icons- create the icon you want,using a icon the size of your toolbar or smaller (see one of my previous posts about creating idesk "icons", if needed). Use a toolbar that is not 100% size (the stock is not) and drag the icon(s) of your app(s) just near enough to the bar so it looks almost part of it (see post viewtopic.php?f=143&t=54848&start=180#p551009 ). That way you can always click the apps icon to start it even if running a maximized application.
Code: Select all
#! /bin/bash
#Application to pin and unpin applications to the top of Fluxbox menu
# requeriments: yad and exo-open (both are included out of the box in MX-Linux 19)
# By PPC - 15/01/2020 - GPL licence- do what you want with this script, please keep this comments about the author and date
# TO DO: a option reorder the "pinned" applications
# -- idea1- present the list of pinned applications, like in the "unpin" funtion. When user clicks on, use sed or whatever, to get the selections line number, a new yad window pops up, presenting the line number, allowing to user to increase or decrease the number. Delete current entry, create one at the chosen line number - This will take more work than the pin and unpined functions combined!
#idea2- simply create a button that executes flux menu editor, the user can then move the pinned applications using drag and drop!
#
#Declare Functions
pin()
{
# creates a list of all installed .dekstop files, saved in .apps.txt
cd /usr/share/applications/
find *.desktop > ~/.apps.txt
# Use a Yad window to select file to be added to the menu
EXEC=$(yad --title="Select Application to pin to Menu" --width=470 --height=400 --center --separator=" " --list --column= < ~/.apps.txt)
#generate menu entry
foo="[exec] ("
foo="${foo}"${EXEC//.desktop}""")"" {exo-open /usr/share/applications/${EXEC}}"
# insert this generated new line at line 2, but first check, and only add a entry if something was selected"
if test -z "$EXEC"
then
echo "nothing was seleted"
else
sed -i "2 i\\$foo" ~/.fluxbox/menu-mx
fi
}
################################################
unpin()
{
# generate a list of all pinned aplications (searchs for the string #.desktop ", created by the pinning script
grep -E '.desktop ' ~/.fluxbox/menu-mx > ~/current_apps_pinned_to_menu.txt
### make choices easier to read- show just app.desktop:
# show only everything betwenn brakets
cat ~/current_apps_pinned_to_menu.txt | cut -d "{" -f2 | cut -d "}" -f1 > ~/temp0
# remove the first 33 characters from each line, the "exo-open /path" part
sed -i 's/\(.\{33\}\)//' ~/temp0
# Use a Yad window to select file to be added to the menu
EXEC=$(yad --title="Select Application to unpin from the Menu" --width=470 --height=400 --center --separator=" " --list --column= < ~/temp0)
# delete selected pinned application from the menu, but first check, and only add a entry if something was selected
if test -z "$EXEC"
then
echo "nothing was seleted"
else
#remove selected pinned application
cat ~/.fluxbox/menu-mx | grep -v $EXEC > ~/filename.1
mv ~/filename.1 ~/.fluxbox/menu-mx
fi
}
##########################################################
# Main part of the script
# makes the previous created funtions available
export -f pin unpin
# menu to select options:
yad \
--title "Pin and unpin apps to MX-Fluxbox menu" \
--center --text=" This is a quick way to add or remove Applications to the top of the menu, \n for faster access, using the application's .desktop files, and, according to the MX-Fluxbox \n visual style,no icon is used.\n \n The 'Pin' button shows a list of the applications .desktop files installed on your system.\n Scroll down until you see the app you want to pin, double left click it.\n \n The 'Unpin' button shows a list of the applications .desktop files pinned to the menu. \n This does remove any 'normal' menu entries, only the ones related to .desktop files. \n \n IMPORTANT: Always have a back up copy of your ~/menu-mx file!" \
--button="Pin":"bash -c pin" \
--button="Unpin":"bash -c unpin" \
--button="Exit":0
echo $?
#####
P.