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()