34

The Software Center has a section of For Purchase programs —see screenshot below—,
which is annonying me every time I want to install something.

Is there any way to remove or hide these programs from the Software Center?

Links to answers:

For 13.10 and higher
For 13.04
For 12.10
For 12.04
For 11.10 and lower
Please leave a comment or send a mail to [email protected]
if it's not working for you or you're having trouble!

The 'For purchase' section of the Ubuntu Software Center.

2
  • what is 13.10 and higher means? Jan 12, 2014 at 2:05
  • @AvinashRaj That's for the most recent version of Ubuntu like right now 13.10, and soon 14.04 believe the alpha/beta of 14.04 is soon out too.
    – Alvar
    Jan 12, 2014 at 2:12

7 Answers 7

17

For 12.04

Derived from Pavlos G. answer and inspiration from Darmien answer.
Different version? Go to the list.
See the end of the post if you are in trouble and want to revert the changes.


1. Ignore the purchasable apps

Open a terminal (Ctrl + Alt + T) and type:

gksu gedit /usr/share/software-center/softwarecenter/db/update.py

And press Enter. You'll be prompted for your password.
Then an editor will appear. Locate the following lines (hint: Ctrl + F may help):

        doc = make_doc_from_parser(parser, cache)
        if not doc:
            LOG.debug("make_doc_from_parser() returned '%s', ignoring" % doc)
            return
        term_generator.set_document(doc)
        name = doc.get_data()

Immediately after those lines, paste the following (including the spaces!):

        if doc.get_value(XapianValues.PRICE) not in (""): return

Note: if you want to keep stuff that doesn't cost money, but has to be "purchased"
(like trials, magazines and other propietary stuff), replace ("") with ("0.00", "").

Save the file (Ctrl + S), open the Software Center and… voila!
There are no commercial programs!
You can close the editor and the terminal now.

2. Remove the "For purchase" channel (optional)

To also remove that "For purchase" item in the menu, open a terminal and type:

gksu gedit /usr/share/software-center/softwarecenter/backend/channel_impl/aptchannels.py

Locate these lines:

        if get_distro().PURCHASE_APP_URL:
            channels.append(for_purchase_channel)

And disable them by putting a # in front of every line:

        #if get_distro().PURCHASE_APP_URL:
        #    channels.append(for_purchase_channel)

Save and enjoy a software center without ads!

 


Side notes: The. files. are. packaged.

What does this mean, you ask? This means that,
whenever you upgrade your Software Center, the changes
will be reverted and you'll have to do this steps again.

Undo the modifications

If you want to restore the original state of the files,
open a terminal and type:

sudo apt-get install --reinstall software-center && exit

Again, you will be prompted for your password, this time on the terminal.
Type it and press ENTER. Don't worry if nothing appears when you type, it's to hide your password.
The terminal will automatically close when finished.

3
  • 2
    As I have said to others, it is best to make a backup before editing anything critical for a program.
    – nanofarad
    Aug 31, 2012 at 12:14
  • 1
    @ObsessiveFOSS good point. But keep in mind that: 1) The changes are trivial and easy to undo. It is unlikely that people will ever get lost. :D 2) This files are packaged, so if you make a mistake you can just reinstall the package. Aug 31, 2012 at 15:48
  • @ObsessiveFOSS I've added instructions to revert, just in case ;) Sep 1, 2012 at 12:14
12

For 11.10 and earlier

You can edit:

/usr/share/software-center/softwarecenter/backend/channel.py

and comment out (or delete) the following lines:

for_purchase_channel = None

#create a "magic" channel to display items available for purchase                                              `
        for_purchase_query = xapian.Query("AH" + AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME)
        for_purchase_channel = SoftwareChannel(self.icons, 
                                             "For Purchase", None, None, 
                                             channel_icon=None,   # FIXME:  need an icon
                                             channel_query=for_purchase_query,
                                             installed_only=installed_only)

if partner_channel is not None:
        #    channels.append(partner_channel)
        #channels.append(for_purchase_channel)

Of course, you should have in mind that consequent updates to software-center will probably overwrite the script...

Check out this link for more details ;-)

Note: for 12.04 the filename is /usr/share/software-center/softwarecenter/backend/channel_impl/aptchannels.py. The same steps apply.

6
  • 1
    Care to find a solution for 12.04? :) May 9, 2012 at 8:18
  • 1
    If you replace software center with an old version askubuntu.com/questions/95497/… then you can follow these steps.
    – Mateo
    May 9, 2012 at 14:09
  • On 12.04, these steps will hide the "For purchase" channel but not all the commercial entries. To hide them also, something like Darmien's solution would be needed. (But I want to find a way to alter the logic not the GUI). Jul 21, 2012 at 8:41
  • I found it! Hide ALL commertial entries from EVERYWHERE! Jul 21, 2012 at 10:16
  • @medigeek look at my answer. If it doesn't work, tell me. I tested it in three different computers. Jul 21, 2012 at 11:08
6
+50

I found a way to hide commercial results for 12.04:

In /usr/share/software-center/softwarecenter/ui/gtk3/models/appstore2.py:

After the lines:

def set_from_matches(self, matches):
    """ set the content of the liststore based on a list of
        xapian.MSetItems
    """
    LOG.debug("set_from_matches len(matches)='%s'" % len(matches))

Add the following line:

    matches[:] = [m for m in matches if (m.document.get_value(XapianValues.PRICE) in _FREE_AS_IN_BEER)]

It should only change what is displayed, but I did not test it much yet, so use at your own risks. And enjoy an ad-free software center.

2
  • Great! Can't wait to test it. :) May 15, 2012 at 12:29
  • Haven't tested it, but will do. Thank you for trying! May 16, 2012 at 7:16
6

For completeness, here is the solution that worked for me in 13.10:

sudo aptitude install gksu
gksu gedit /usr/share/software-center/softwarecenter/db/update.py

Find this:

def make_doc(self, cache):
    """Build a Xapian document from the desktop info."""
    doc = xapian.Document()

And add this (make sure you have the right indentation of TABS (python requires this):

if self.has_option_desktop("X-AppInstall-Price"):
    if self.get_desktop("X-AppInstall-Price") > 0: return

BTW this was my first python evar :-)

2
  • +1 Can't verify right now, but added to the TOC as well. Thanks! Jan 12, 2014 at 1:59
  • Works for 14.04, but it would be better if it could be turned on/off from UI. This solution is rather permanent. Never see apps for purchase again.
    – VlatkoB
    Jul 8, 2014 at 20:02
3

I tried this it it worked for me: only FREE (price not more than 0) items are displayed.

gksu gedit /usr/share/software-center/softwarecenter/db/update.py

Find this:

def make_doc_from_parser(parser, cache):
    # XXX 2012-01-19 michaeln I'm just pulling this code out from
    # index_app_info_from_parser, but it'd be great to further
    # refactor it - it looks quite scary :-)
    doc = xapian.Document()
    # app name is the data

Then add the following code:

if parser.has_option_desktop("X-AppInstall-Price"):
    if parser.get_desktop("X-AppInstall-Price") > 0: return
0
2

For 12.10 and later

Derived from jmendeth answer.
Different version? Go to the list.
See the end of the post if you are in trouble and want to revert the changes.

Close the Software Center if it's open.
Now open a terminal (Ctrl + Alt + T) and type:

gksu gedit /usr/share/software-center/softwarecenter/db/update.py

And press Enter. You'll be prompted for your password.
Then an editor will appear. Locate the following lines (hint: Ctrl + F may help):

        doc = self.make_doc(cache)
        if not doc:
            LOG.debug("%r.index_app_info: returned invalid doc %r, ignoring.",
                      self.__class__.__name__, doc)
            return
        name = doc.get_data()

Immediately after those lines, paste the following (including the spaces!):

        if doc.get_value(XapianValues.PRICE) not in (""): return

Save the file (Ctrl + S) and close the editor, but not the terminal.
Now type in the terminal:

gksu gedit /usr/share/software-center/softwarecenter/backend/channel_impl/aptchannels.py

Press ENTER. An editor will appear again. Locate these lines:

        if get_distro().PURCHASE_APP_URL:
            channels.append(for_purchase_channel)

And disable them by putting a # in front of every line:

        #if get_distro().PURCHASE_APP_URL:
        #    channels.append(for_purchase_channel)

Save the file, close the editor but not the terminal.
In the terminal, type:

gksu echo; sudo update-software-center && exit

Wait a bit, the terminal will automatically close when finished...
Then open the Software Center and… voila!
There are no commercial programs!

Side notes: The. files. are. packaged.

What does this mean, you ask? This means that,
whenever you upgrade your Software Center, the changes
will be reverted and you'll have to do this steps again.

Undo the modifications

If you want to restore the original state of the files,
open a terminal and type:

gksu echo; sudo apt-get install --reinstall software-center && exit

Again, you will be prompted for your password.
The terminal will automatically close when finished.

10
  • +1 Thanks for contributing! Well, this is getting pretty extense, so I think I'm gonna make a Python script that makes the appropiate fix depending on the version. Jan 10, 2013 at 16:43
  • Gonna test on my 12.10, if everything's ready I'll link your answer at the top and make any other modification. Jan 10, 2013 at 16:43
  • Just did it on my fresh install of Ubuntu 12.10
    – blvdeer
    Jan 10, 2013 at 18:20
  • @jmendeth I will love to assist you write that script
    – blvdeer
    Jan 15, 2013 at 8:26
  • Sorry about the delay. Unfortunately, it doesn't work on my 64-bit Ubuntu 12.10. I'll see if I can make something... Jan 17, 2013 at 16:47
-2

You can do this more simply by selecting View -> Canonical Maintained Software instead of All Software. This has the benefit of not being overwritten by software updates.

This may hide some additional items but at least it gets rid of the annoying magazines and for sale software in my experience.

1
  • 2
    Then you're hiding a 90% of all the software, showing only the software (commercial or not) that Canonical supports. What I want to do is remove the propietary software only. Aug 20, 2013 at 14:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .