Cinnamon-remove-application does not work

I currently installed cinnamon-remove-application addon. There is now a context menu entry on each application to uninstall it, but clicking it does nothing. No message and password query, and the application is still installed. The Python script cinnamon-remove-application is installed in usr/bin as it should be, regarding to the documentation. Is this script outdated, can it be fixed?

What application are you trying to remove? It will only work with packages installed from the repos as it uses Pacman to remove them.

Just installed the addon and rebooted. Tried right clicking an application from the menu/launcher and it uninstalled fine

I tried to uninstall Pix and Firefox. Both I could’nt uninstall using the context menu in the application menu. So I used pamac GUI instead.

The original Cinnamon is Linux Mint and based on Ubuntu - so it is quite possible that you can install the application but it won’t work due package manager differences.

Yes, I switched from Mint / Cinnamon a half year ago and missed a bit the possibility to uninstall an application from launcher menu. So I was happy when I recently discovered the addon. It’s nothing else than a Python script which calls pacman instead of apt, but I am not familiar enough with Python to see what is wrong. The call itself looks correct, it runs pkexec pacman -Rc --noconfirm --noprogressbar . It seems that the initialization fails, because a confirmation dialog should appear first, which does not.

OK, at least I copied the script from Mint and adopted it to Arch / Manjaro. Was not very complicated, so my slight Python knowledge was sufficient. The original script seems to be totally outdated and is still based on Python2. I’m not aware of how to publish it, so I do it here. Hope that someone find it useful. I uninstalled the addon and created the script /usr/bin/cinnamon-remove-application with following content. Flatpak support won’t work, I do not use it. You can create a script /usr/bin/mintinstall-remove-app which gets the desktop file name as parameter to uninstall flatpaks.

#!/usr/bin/python3
'''
Arch port of cinnamon-remove-application

Created on 17.04.2021

@author: stephan
'''

import gettext
import os
import subprocess
import sys
import threading

import gi
gi.require_version('Gtk', '3.0')

from gi.repository import Gtk
from subprocess import Popen

# To see translation, copy mint-common.mo from /usr/share/linuxmint/locale/<lang>/LC_MESSAGES on Mint to /usr/share/locale/<lang>/LC_MESSAGES on Arch
# i18n
gettext.install("mint-common", "/usr/share/locale")

class RemoveExecuter(threading.Thread):

    def __init__(self, package):
        threading.Thread.__init__(self)
        self.package = package

    def run(self):
        cmd = ["pkexec", "/usr/bin/pacman", "-Rc", "--noconfirm", "--noprogressbar", self.package]
        comnd = Popen(cmd)
        sys.exit(comnd.wait())

class MintRemoveWindow:

    def __init__(self, desktopFile):
        self.desktopFile = desktopFile
        process = subprocess.run(["pacman", "-Qoq", self.desktopFile], stdout=subprocess.PIPE)
        output = process.stdout.decode("utf-8")
        package = output[:output.find(":")].split(",")[0]
        if process.returncode != 0:
            if not self.try_remove_flatpak(desktopFile):
                warnDlg = Gtk.MessageDialog(parent=None, flags=0, message_type=Gtk.MessageType.WARNING, buttons=Gtk.ButtonsType.YES_NO, text=_("This menu item is not associated to any package. Do you want to remove it from the menu anyway?"))
                warnDlg.set_keep_above(True)

                warnDlg.get_widget_for_response(Gtk.ResponseType.YES).grab_focus()
                warnDlg.vbox.set_spacing(10)
                response = warnDlg.run()
                if response == Gtk.ResponseType.YES:
                    print ("removing '%s'" % self.desktopFile)
                    subprocess.run(["rm", "-f", self.desktopFile])
                    subprocess.run(["rm", "-f", "%s.desktop" % self.desktopFile])
                warnDlg.destroy()

            sys.exit(0)

        warnDlg = Gtk.MessageDialog(parent=None, flags=0, message_type=Gtk.MessageType.WARNING, buttons=Gtk.ButtonsType.OK_CANCEL, text=_("The following packages will be removed:"))
        warnDlg.set_keep_above(True)

        warnDlg.get_widget_for_response(Gtk.ResponseType.OK).grab_focus()
        warnDlg.vbox.set_spacing(10)

        treeview = Gtk.TreeView()
        column1 = Gtk.TreeViewColumn(_("Packages to be removed"))
        renderer = Gtk.CellRendererText()
        column1.pack_start(renderer, False)
        column1.add_attribute(renderer, "text", 0)
        treeview.append_column(column1)

        packages = []
        model = Gtk.ListStore(str)
        dependenciesString = subprocess.getoutput("pacman -Rpc " + package)
        dependencies = dependenciesString.split("\n")
        for dependency in dependencies:
            model.append([dependency])
            packages.append(dependency.split()[0])
        treeview.set_model(model)
        treeview.show()

        scrolledwindow = Gtk.ScrolledWindow()
        scrolledwindow.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        scrolledwindow.set_size_request(150, 150)
        scrolledwindow.add(treeview)
        scrolledwindow.show()

        warnDlg.get_content_area().add(scrolledwindow)

        response = warnDlg.run()
        if response == Gtk.ResponseType.OK:
            executer = RemoveExecuter(package)
            executer.start()
            executer.join()
        elif response == Gtk.ResponseType.CANCEL:
            sys.exit(0)

        warnDlg.destroy()

    def try_remove_flatpak(self, desktopFile):
        if not "flatpak" in desktopFile:
            return False

        if not os.path.exists('/usr/bin/mintinstall-remove-app'):
            return False

        flatpak_remover = subprocess.Popen(['/usr/bin/mintinstall-remove-app', desktopFile])
        retcode = flatpak_remover.wait()

        return retcode == 0

    def on_finished(self, transaction=None, exit_state=None):
        sys.exit(0)

if __name__ == "__main__":

    # Exit if the given path does not exist
    if len(sys.argv) < 2 or not os.path.exists(sys.argv[1]):
        sys.exit(1)

    mainwin = MintRemoveWindow(sys.argv[1])
    Gtk.main()

@stoffel

Thanks for the good work - it’s available with version 1.0-1 at unstable.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.