You are not logged in.
bl-multimedia-pipemenu seems to run two checks to determine if a program is install. The first place is to look for a /var/lib/dpkg/info/{package}.list file. I think the second check is to look for the the same file in /etc (clarification on the grep -Evq line would be appreciated). If either condition is satisfied, then the script "thinks" the package is installed.
You've almost got it. The basic test is to look for a /var/lib/dpkg/info/{package}.list file. This file is created whenever dpkg installs a package, and lists all the files installed on the system by that package. The complication is that after a package is removed - but not purged - then some conffiles are kept. As long as the conffiles remain, then so will the *.list file, even after the package is uninstalled. Luckily, except in a few rare cases, all the conffiles are under /etc. So the allInstalled() function does this:
1) If the file "/var/lib/dpkg/info/${package}.list" does not exist: The package is not installed.
2) If the file exists, but all the files in its list are under /etc: The package is not installed.
3) Otherwise: The package is installed.
(Rare false positives are given if the package has conffiles under /usr...)
(Please see 'man grep' for explanation of the options.)
The reliable way of testing if a package is installed is to ask dpkg directly with a test like this:
[[ $(dpkg-query --show --showformat='${db:Status-Abbrev;2}' "$package" 2>/dev/null) = ii ]] && echo "$package is installed."But this is much slower. The pipemenu has to run that test on every item in the menu, and using the dpkg call makes it distinctly sluggish.
Anyway:
...a better way of detecting whether a package is installed or not: look for its command in $PATH.
The new pipemenus should get round that, and make the /var/lib/dpkg/info/${package}.list hack unnecessary. ![]()
---
If you try to place "firefox" in the menus...
Of course, you would be expected to use the name of a package that actually exists!
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Online