7

I'm building an application and it's very important to me to know how to get this information. In LXDE, there is /usr/share/lubuntu/openbox/menu.xml that lists all the programs that can be executed from the LXDE menu.

For that reason, I'd like to know if there is some .xml file that is responsible for the organization of the Ubuntu Dash Home like the one in LXDE?

Zignd
  • 10,774
  • 12
  • 36
  • 62
  • 2
    Won't that comprise all `.desktop` files? So these should be in `/usr/share/applications` or in `~/.local/share/applications`? So would you really need a `.xml` file for your purpose? –  Feb 06 '13 at 11:13
  • I think so, because I'd be able to query on it from inside the application. And from the `/usr/share/applications` I can't get the "keywords" used to execute the applications. – Zignd Feb 06 '13 at 11:20
  • I don't know programming but please see if this thread helps! http://ubuntuforums.org/showthread.php?p=12282576#post12282576 –  Feb 06 '13 at 11:23
  • Thanks for the link @vasa1, It was very useful. The file returned by your command has some problems, do they can be fixed with more complex command? – Zignd Feb 06 '13 at 11:39
  • Clarification ... it's not *my* code. MG&TL did the real work. For my purposes, some `.desktop` files have more than one pair of Name+Exec and when that's not in proper order, there's confusion. I mentioned the LibreOffice `.desktop` files in this context. Perhaps someone who is good at this stuff may be able to help you! –  Feb 06 '13 at 11:48
  • @vasa1. Thanks for posting that link. I modified the code to write the output to an xml file. – chaskes Feb 20 '13 at 16:30

1 Answers1

4

I understand from the comments that the OP likes the output from the linked code but would like the information placed into an xml file that can be queried.

Her'es how to modify the script given at Get contents of .desktop files to process the output into an XML file.

filename="MyDesktopFiles.xml"
rm $filename
touch $filename

echo '<?xml version="1.0"?>' >> $filename
echo '<items>' >> $filename

for files in /usr/share/applications/*.desktop; 
do 
  echo '<item>' >> $filename
  echo '   <name>'$(grep -e "^Name=" $files | sed 's/Name=//g')'</name>' >> $filename   
  echo '   <command>'$(grep -e "^Exec=" $files | sed 's/Exec=//g')'</command>' >> $filename
  echo '</item>' >> $filename
done

echo '</items>' >> $filename
echo '</xml>' >> $filename
chaskes
  • 15,146
  • 8
  • 53
  • 65