Script to get the (short) installed app list similar to Ubuntu Software Center?

Solution 1:

In Python, you can get the list of installed packages this way:

import apt
packages = apt.Cache()
packages.open()
installed_packages = [i.name for i in packages if i.is_installed]

If you want to know additional info about the packages, the process is a bit more involved. See the documentation for Python's apt module for all the information that's available. Additionally, you can look through the Software Center's source to find out what they do.

You won't get this info merely by looking at some file somewhere or running a simple command. You're going to need to do some scripting.

EDIT: I believe that Software Center gets its list of packages to show from those packages that ship .desktop files. It might be more complicated than that, but you can easily filter the list to those packages that are installed and have a .desktop file. This example continues my previous code:

import os
desktop_files = ['.'.join(i.split('.')[:-1]) for i in os.listdir('/usr/share/applications')]
installed_in_software_center = [i for i in installed_packages if i in desktop_files]

Solution 2:

May still not be what you're looking for...

dpkg --get-selections

If not (I can't comment yet), run the following and let me know the number (just counts number of lines.

dpkg --get-selections | wc -l