I am trying to write a status bar module for dwm in python. I want the status bar to change to a specific string when pacman / apt or dnf is running. Is there a distribution independent way to check if some package manager is currently running and is it possible to extract information from it for example the download progress so it can be displayed in the status bar.
Asked
Active
Viewed 857 times
2
-
pip can show which libs are installed – Torxed Jun 12 '20 at 20:03
-
`pip freeze` will list all installed packages under the environment(default base) – Pygirl Jun 12 '20 at 20:03
-
@Torxed, Pygirl what does that have to do with the question about checking whether a package manager is running? – chash Jun 12 '20 at 20:15
-
@p4p1 [This question](https://stackoverflow.com/questions/7787120/python-check-if-a-process-is-running-or-not/7788702) is relevant for checking if a process is running. Extracting information about progress is likely a much harder problem with no general solution. – chash Jun 12 '20 at 20:27
-
@hmm I read the title "if a package is currently being installed" and perhaps assumed to much. – Torxed Jun 12 '20 at 21:08
2 Answers
1
After some research and messing around the /var/lib/pacman/ folder I discovered that pacman and other package managers all create a file named db.lck file when running and I just checked if the files existed and it did the trick. I currently still can't find a way to access the output of the commands but it's better than nothing.

p4p1
- 31
- 5
0
Just a thought - pacman seems to be fairly verbose in its logging to /var/log/pacman.log, so tailing that file when the lock is active will at least tell you what's going on at the moment.

Taqras
- 173
- 1
- 10