Skip to content

Commit 91f2aeb

Browse files
committed
mintinstall: add command line option "show"
Add command line option `mintinstall show <pkg name>` to open mintinstall on the details page of a specific package. This can be used e.g. in a menu applet to show information about a particular app.
1 parent 445fde2 commit 91f2aeb

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

usr/bin/mintinstall

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import subprocess
44
import os
5+
import sys
56

67
# Remove any obsolete configuration file
78
obsolete_path = os.path.expanduser("~/.config/autostart/mintinstall-update-flatpak.desktop")
@@ -11,4 +12,4 @@ if os.path.exists(obsolete_path):
1112
except:
1213
pass
1314

14-
subprocess.call("/usr/lib/linuxmint/mintinstall/mintinstall.py")
15+
subprocess.call(["/usr/lib/linuxmint/mintinstall/mintinstall.py"] + sys.argv[1:])

usr/lib/linuxmint/mintinstall/mintinstall.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ def __init__(self):
647647
self.recursion_buster = False
648648

649649
self.install_on_startup_file = None
650+
self.show_on_startup_pkg = None
650651

651652
self.review_cache = None
652653
self.current_pkginfo = None
@@ -701,6 +702,22 @@ def do_command_line(self, command_line, data=None):
701702
sys.exit(self.export_listing(flatpak_only=False))
702703
elif num > 1 and args[1] == "list-flatpak":
703704
sys.exit(self.export_listing(flatpak_only=True))
705+
elif num == 3 and args[1] == "show":
706+
target_pkg = args[2]
707+
if self.gui_ready:
708+
pkginfo = self.installer.find_pkginfo(target_pkg, installer.PKG_TYPE_APT)
709+
if not pkginfo:
710+
pkginfo = self.installer.find_pkginfo(target_pkg, installer.PKG_TYPE_FLATPAK)
711+
if pkginfo:
712+
self.show_package(pkginfo, self.PAGE_LANDING)
713+
self.main_window.present()
714+
else:
715+
print(f"MintInstall: Package {target_pkg} not found.")
716+
else:
717+
self.show_on_startup_pkg = target_pkg
718+
719+
self.activate()
720+
return 0
704721
elif num == 3 and args[1] == "install":
705722
for try_method in (Gio.File.new_for_path, Gio.File.new_for_uri):
706723
file = try_method(args[2])
@@ -2176,6 +2193,16 @@ def finished_loading_packages(self):
21762193
self.gui_ready = True
21772194
self.update_conditional_widgets()
21782195

2196+
if self.show_on_startup_pkg is not None:
2197+
pkginfo = self.installer.find_pkginfo(self.show_on_startup_pkg, installer.PKG_TYPE_APT)
2198+
if not pkginfo:
2199+
pkginfo = self.installer.find_pkginfo(self.show_on_startup_pkg, installer.PKG_TYPE_FLATPAK)
2200+
if pkginfo:
2201+
self.show_package(pkginfo, self.PAGE_LANDING)
2202+
else:
2203+
print(f"MintInstall: Package {self.show_on_startup_pkg} not found.")
2204+
self.show_on_startup_pkg = None
2205+
21792206
if self.install_on_startup_file is not None:
21802207
self.handle_command_line_install(self.install_on_startup_file)
21812208

0 commit comments

Comments
 (0)