I just have created a script, that reads :
~/.local/share/directories ## add names & icons of custom directories here
~/.local/share/applications ## add your .desktop files here
and insert them into Main menu, ( I use Gnome ) .
Here is the code :
Code:
#!/bin/bash
CUSTOM_CATEGORIES=""
ORPHAN_FILES=""
for d in ~/.local/share/desktop-directories/*.directory; do
CATEGORIE=`cat "$d"|grep "^Name=" | cut -d \= -f2`
CUSTOM_CATEGORIES="$CATEGORIE ${CUSTOM_CATEGORIES}"
CFILE="$HOME/.config/menus/applications-merged/user-${CATEGORIE}.menu"
[ -f "$CFILE" ] && rm -f "$CFILE" 2>/dev/null
echo "[+] '$CATEGORIE' (($?)$CFILE)"
## xdg-desktop-menu uninstall --novendor --mode user "$d" "$f"
for f in ~/.local/share/applications/*.desktop; do
F_CATEGORIE=`cat "$f"|grep "^Categories=" |grep "$CATEGORIE" `
[ -z "${F_CATEGORIE}" ] && continue
xdg-desktop-menu install --novendor --mode user "$d" "$f"
echo " [$?] $f"
done
done
echo ""
if [ "x$1" = "x-v" ]; then
echo "[!] (`echo $CUSTOM_CATEGORIES|wc -w`) Categories found :$CUSTOM_CATEGORIES"
echo "[?] Orphan files:"
for f in ~/.local/share/applications/*.desktop; do
F_CATEGORIE=''
for d in $CUSTOM_CATEGORIES; do
[ -z "$F_CATEGORIE" ] && F_CATEGORIE=`cat "$f"|grep "^Categories=" |grep "$d"`;
done
[ -n "${F_CATEGORIE}" ] && continue
echo " [?] `basename "$f" .desktop` (`cat "$f"|grep "^Categories="|cut -d \= -f2`)"
done
fi
xdg-desktop-menu forceupdate --mode user || echo "[!] forceupdate error !"
update-menus || echo "[!] update error !"
exit $?
Take care that :
the 'category' field in your .desktop file,
must be the same, as
the 'Name' field, in your .directory file,
and it'll work ....