PrideFetch/packages.py
2022-05-23 22:00:11 +01:00

20 lines
463 B
Python

from subprocess import check_output
commands = [
"pacman -Qq",
"apt list --installed",
"yum list installed",
"dnf list installed",
"qlist -I",
"rpm -qa",
"nix-store -qR /run/current-system/sw"
]
def get_num_packages() -> (int, bool):
for command in commands:
try:
return len(check_output(command.split(" ")).decode("utf-8").split("\n")) - 1
except FileNotFoundError:
pass
return False