From f5d1fec3494028fa71be3a188437b472d66271dd Mon Sep 17 00:00:00 2001 From: Jonas Harer Date: Wed, 25 Feb 2026 15:02:50 +0000 Subject: [PATCH] Added more commands to the command-not-found handler This adds some more package-managers to the command-not-found handler and adds a way to detect if two or more missing commands belong to the same program. --- .../usr/lib/command-not-found-handler.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mkosi.extra/usr/lib/command-not-found-handler.py b/mkosi.extra/usr/lib/command-not-found-handler.py index e5769ad..033ec9c 100755 --- a/mkosi.extra/usr/lib/command-not-found-handler.py +++ b/mkosi.extra/usr/lib/command-not-found-handler.py @@ -22,19 +22,20 @@ known_alternatives = { "netstat" : "ss", "nslookup" : "resolvectl query", "route" : "ip route", - "service" :"systemctl", + "service" : "systemctl", "traceroute" : "tracepath" } unsupported_package_managers = [ "apt", - "apt-get", "dnf", "dpkg", + "npm", "pacman", "pamac", "portage", "rpm", + "yay", "yum", "zypper" ] @@ -44,8 +45,21 @@ available_package_managers = { "nix" : "https://kde.org/linux/docs/more-software/#nix" } +related_commands = { + "nix-env" : "nix", + "nix-shell" : "nix", + "nix-store" : "nix", + "apt-cache" : "apt", + "apt-config" : "apt", + "apt-get" : "apt", + "apt-mark" : "apt" +} + command = sys.argv[1] +if command in related_commands: + command = related_commands[command] + if command in known_alternatives: print("\nKDE Linux does not include the ā€œ%sā€ tool.\n\nInstead, try using ā€œ%sā€.\n" % (command, known_alternatives[command])) exit(127)