Forum › Forums › New users › New Users and General Questions › [SOLVED] I want to get a list of what programs I run
- This topic has 13 replies, 5 voices, and was last updated May 29-8:30 pm by BobC.
-
AuthorPosts
-
May 23, 2021 at 4:41 pm #59940Moderator
BobC
What I am trying to figure out is what programs I run most often, and use that info to generate a maximum efficiency single click program launching desktop setup.
I was looking at the Linux Process Accounting, sa program, but it didn’t grab any programs run from the menu, or maybe I just wasn’t looking correctly. I went and ran a program from the menu, then ran sa, but the program didn’t appear on the list. I do see that it shows a program run from that shell, and possibly programs run from cron, but those aren’t the programs I’m trying to monitor.
1. I want to take a list of programs I ran with the number of times run on a date.
2. Then I want to filter that down to the ones that are running from the menu or toolbar. Maybe desktop, too.
3. Then I would like to use an algorithm that gives more weight to recent history, and less weight to older history, to assign a numerical value that I can then use to rank the programs from most often used to least often used.
4. I might want to designate certain programs as fixed, where I want it on the list, regardless of it’s ranking. This might cause another program to be bumped off the end of the list if my fixed program did not warrant being on the list, numerically.
5. I will give a number for maximum items to display, and net of my fixed programs, the system should try to suggest what programs belong on the list.
6. Maybe the system will organize the list by menu grouping then alpha, or maybe fixed then alpha, or fixed then numeric by ranking, I’m not sure yet.
7. At this point the system could generate a menu or toolbar definition of my most frequently used programs. The logic might be useful for a toolbar, or even a desktop icons arrangement, the end result desired being maximum efficiency single click program launching (perhaps recalculated periodically on a trigger, schedule or on demand). In my case I am looking for an IceWM toolbar file.
Does anything like this already exist? Any comments, ideas or suggestions getting there?
- This topic was modified 1 year, 11 months ago by BobC.
May 23, 2021 at 4:59 pm #59944Member
Xecure
::For statistics only, if you don’t mind being spied on, anything zeitgeist related.
$ apt show activity-log-manager Package: activity-log-manager Version: 0.8.0-1.2 Priority: optional Section: utils Maintainer: Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com> Installed-Size: 76.8 kB Depends: python, zeitgeist-core (>= 0.7~) | zeitgeist (>= 0.7~), python-gtk2, python-cairo, python-zeitgeist Homepage: https://launchpad.net/history-manager Tag: role::program, use::configuring Download-Size: 15.0 kB APT-Sources: http://debian.redimadrid.es/debian buster/main amd64 Packages Description: blacklist configuration user interface for Zeitgeist Zeitgeist is a service which logs the user's activities and events (files opened, websites visited, conversations held with other people, etc.) and makes the relevant information available to other applications. . It serves as a comprehensive activity log and also makes it possible to determine relationships between items based on usage patterns. . This package contains Activity Log Manager, a graphical user interface which lets you control what gets logged by Zeitgeist. It supports setting up blacklists according to several criteria (such as application or file types), temporarily stopping all logging as well as deleting recent events.$ apt show zeitgeist-explorer Package: zeitgeist-explorer Version: 0.2-1.2 Priority: optional Section: devel Maintainer: Manish Sinha <manishsinha@ubuntu.com> Installed-Size: 85.0 kB Depends: python (<< 2.8), python (>= 2.7), python2.7:any, python:any (>= 2.6.6-7~), gir1.2-gtk-3.0, python-gi, python-zeitgeist, zeitgeist (>= 0.9.0) Homepage: https://launchpad.net/zeitgeist-explorer/ Download-Size: 17.0 kB APT-Sources: http://debian.redimadrid.es/debian buster/main amd64 Packages Description: GUI application for monitoring and debugging zeitgeist Zeitgeist explorer is a tool which can be used to monitor and explore the events logged by zeitgeist. In the monitor mode is can show the events logged in real-time just like wireshark.Building a program using this data to launch and pin applications would be up to you. The other alternative is using a desktop environment. I think KDE tracks most used applications and favorites, but I am not sure.
antiX Live system enthusiast.
General Live Boot Parameters for antiX.May 23, 2021 at 5:11 pm #59948MemberPPC
::I thought about how to add that feature the the antiX menu several times, always without sucess… The best I could find was how to display the more recently installed apps, with this one liner:
cat /var/log/dpkg.log |awk '/ install / {printf "%s\n",$4}'I’m glad you are trying to tacle this problem too, Bob!
P.
May 23, 2021 at 8:58 pm #59979ModeratorBobC
::I tried zeitgeist-explorer, and it looks to be running but doesn’t notice menu options like Galculator being run.
May 25, 2021 at 2:17 am #60087Anonymous
::Does anything like this already exist?
Yes. “Frecency” (weighted frequency+recency) algorithm.
I have encountered C++ and python variants, probably also available for other programming languages.
https://frecency.readthedocs.io/en/latest/I am looking for an IceWM toolbar file
asking for clarification:
You are hoping to end up with a text entrybox embedded into the window manager’s toolbar?FWIW (zero), as a user, I would resent the loss of taskbutton real estate, so would prefer on-demand visibility via Alt+F2 or whatever. Also FWIW (priceless) kupfer, rofi, and others are available to provide entrybox with search-as-you-type drilldown (code which you might find desirable to use, or to fork).
Any comments, ideas or suggestions getting there?
“I want to get a list of what programs I run”
I’ll type a followup post explaining (multiple alternatives) howto achieve your “bulletpoint #1”.Accomplishing #2 would probably necessitate use of duplicate(d) “launchers” (wrapper scripts, custom .desktop files) in order to track/know “Did I launch galculator via the menu, or via toolbar tray icon, or via desktop icon?” I’d urge you to reconsider whether this “statistic” is even worth chasing, or just stands as a distraction which will deter your pursuit of the remaining bulletpoints.
May 25, 2021 at 12:46 pm #60101ModeratorBobC
::Skidoo, Thanks for replying.
Ok, my basic premise is that if I could have the “right” icons on my toolbar, I might be able to just move the mouse to the toolbar area and make 1 click to run the program I want 99% of the time. Maybe it turns out its only 97% of the time if I use too many different programs often, ie more than my toolbar will hold. Ok, I’ll admit, if I had a multi-row toolbar it could be a launcher system, but I’m not looking to add overhead or replace IceWM, I’m just trying to make better use of the features it does have.
I was thinking… There are icons on my toolbar that I put there when I set it up, but maybe only used once or twice in the past year, but other programs that I might use once a week on average, that aren’t on the toolbar. The thing is, that I don’t know which were called or how often.
Being extremely lazy, my proposed solution is for an easy/quick “toolbar reset” script that would run on demand that would identify the other programs that I use more often than existing toolbar icons and display a list of them mixed with the existing toolbar icon list in sequence by Frozen icons that I want on the toolbar regardless of ranking, and the rest ranked descending by usage frequency rating (based on the exponentially smoothed average of number of times used per day), and all I’d need to do is add Toolbar or Freeze check marks to the ones I wanted on the toolbar that weren’t already there, click apply, and the program would regenerate my toolbar, and a “Popular programs” submenu with the rest of the top 50 that would be accessible in a couple clicks.
I don’t want to mess with wrappers or changing the programs that are run, I just want to have the ones I use readily available.
I asked over at IceWM after searching open and clsed issues, and they suggested that the acct system would work but would only show a program being called after it was closed. I tried it again with that in mind, and it did record spacefm being run from the toolbar, but did not record aisleriot (a solitaire card game), so maybe I need to come up with another way.
May 25, 2021 at 3:06 pm #60104Forum Admin
Dave
::Maybe?
#!/bin/bash loop=1 while : do ps -U user2 -o command |sort -u >> $HOME/Documents/programs/programs-$loop.list sleep 300 loop=$((loop+1)) donethen review the logged output.
Of course you could get more fancy by listing the names with a count in a separate file. Maybe automatically using a trap exit function. You could also add “pid” to the output of ps, then you are not counting the same program twice when it is only run once.Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown
May 26, 2021 at 6:42 am #60149Anonymous
::alternative A:
sudo apt install forkstatand, at a command prompt, type: sudo forkstat
The output of this tiny (18kb) utility looks like this:
Time Event PID Info Duration Process 02:33:36 clone 2590579 parent /usr/lib/firefox-esr/firefox-esr 02:33:36 clone 1956199 thread /usr/lib/firefox-esr/firefox-esr 02:33:59 fork 81788 parent roxterm 02:33:59 fork 1956200 child roxterm 02:33:59 exec 1956200 /bin/bash 02:33:59 fork 1956200 parent /bin/bash 02:33:59 fork 1956201 child /bin/bash 02:33:59 exec 1956201 <unknown> 02:33:59 exit 1956201 0 0.005s /bin/bash 02:33:59 fork 1956200 parent /bin/bash 02:33:59 fork 1956202 child /bin/bash 02:33:59 fork 1956200 parent /bin/bash 02:33:59 fork 1956203 child /bin/bash 02:33:59 exit 1956202 0 0.002s /bin/bash 02:33:59 exec 1956203 grep -Eq (^|:)/sbin(:|) 02:33:59 exit 1956203 256 0.007s grep -Eq (^|:)/sbin(:|) 02:33:59 fork 1956200 parent /bin/bash 02:33:59 fork 1956205 child /bin/bash 02:33:59 exit 1956204 0 unknown <unknown> 02:33:59 exec 1956205 grep -Eq (^|:)/usr/sbin(:|) 02:33:59 exit 1956205 256 0.003s grep -Eq (^|:)/usr/sbin(:|) 02:34:02 exit 1956200 1 2.647s /bin/bash 02:34:06 exit 1956199 0 30.003s /usr/lib/firefox-esr/firefox-esrman forkstat
explains commandline options you can use to tailor the output.If using this tool, you will probably need to configure a large scrollback buffer for the terminal emulator you’re running it in… and selectall / copy / paste the output into a file for further processing (or, untested, play with using the “tee” command to capture a logfile).
Not perfectly suited to your bulletpoint #1, but its output provides a VERY enlightening peek under the hood of the running system.
The sample output I pasted here is “underwhelming”.
forkstat does, fairly effectively, display the name of each newly started process.
If you tinker with it, I’m curious to hear any blind spots (missed programs, or launch mechanisms) that you discover.May 26, 2021 at 7:03 am #60150Anonymous
::alternative B:
sudo apt install straceAt your leisure, you can peruse the considerable strace manpage.
The following, either from within a shell script, or as a series of consecutive commands
will get ya off-n-running toward using strace for your bulletpoint #1### get the proccessid of the running desktop-session WHEEEE=$(ps -ax | grep desktop-session |grep -v grep |cut -f 1 -d' ') echo $WHEEEE ### attach strace to the desktop-session process, ### using it to moniitor execve+vfork+fork events ### (and to also follow//monitor child processes) ### and to generate a logfile sudo strace -e trace=execve,vfork,fork -o /tmp/allmykids.txt -f -p $WHEEEENOTE: strace can/will bog your system. Directing the output to tmpfs will ease the disk I/O, but programs will run noticably slower. I would “think twice” before loosing it, session-wide, on a low-spec system.
its output (quite messy ~~ prepare to “brushup on awk and sed skillz, eh) looks like this:
https://pastebin.com/raw/Y8WfScfa
and, really, for your bulletpoint… we might/could omit the fork and vfork events.May 26, 2021 at 8:31 am #60151Anonymous
::alternative C:
snoopski logger provides a shared library (a libc execve() wrapper), as well as 2 utility scripts which enable/disable LD_PRELOAD injection of libsnoopski.
Configurable choice of logged details can be specified within /etc/snoopski.ini, useful toward performing light/heavy system monitoring, and toward gaining a good sense of what’s going on in the system (for example apache running many, and short-lived, cgi scripts).cd /tmp && wget https://gitlab.com/skidoo/snoopski/snoopski_2.4.14_amd64.deb sudo apt install /tmp/snoopski_2.4.14_amd64.deb sudo snoopski-enablefollowup:
1) logout + login (or, change to a fresh desktop session via desktopMenu } Other Desktops }2) after launching several programs… view /tmp/snoopski.log
3) whenever you wish to deactivate snoopski, use the command “slimski-disable”
4) toward reducing logspam/noise (and toward further lean-n-meaning the system)
visit https://pastebin.com/raw/08nHqVRP and read about suggested optimizations to .conkyrc5) At your leisure, skim/read file:///usr/share/doc/snoopski/snoopski_usage_guide.html
its output, per the as-shipped default configuration, looks like this:
https://pastebin.com/raw/bWMNyJDf
(that log snippet represents “what happens behind the scenes upon clicking desktopMenu } OtherDesktops”)Again, if you tinker with this, of course I’m curious to hear any blind spots (missed programs, or missed launch mechanisms) that you discover.
May 26, 2021 at 5:52 pm #60179ModeratorBobC
::Thanks Dave and Skidoo. Looks like I have some ideas I can try here.
To work it the way I was thinking, I will need to link it somehow to the menu and toolbar files, and a file to manage my overrides.
I did try looking at the ls -ltu last used or active date, but that is way off. I’m also considering resetting that nightly for all menu and toolbar programs, then I could look before resetting it tomorrow to see if it had been used.
I suppose I need to start at the beginning by seeing if I can get it to tell me what I ran.
May 26, 2021 at 6:14 pm #60184Anonymous
::last used or active date, but that is way off
yep, due to the lazyatime|noatime mount options typically applied… the filesystem timestamps are forensically useless. You might consider temporarily remounting, and/or editing fstab, in order to accommodate your testing.
May 26, 2021 at 10:00 pm #60210Forum Admin
Dave
::With / to expand upon skidoo’s alternative “B”. The pid of the starting / running desktop-session for your user is stored in ~/.desktop-session/ppid.x-display-number (generally the x-display-number is 0)
Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown
May 29, 2021 at 8:30 pm #60481ModeratorBobC
::I appreciate all the suggestions and effort, but I came to the conclusion that unless the window manager keeps a log of what was run from the menu or toolbar that I can just analyze simply, its just too tricky to figure out which menu options are being called most often. The part with the analysis and building the toolbar file is something I could do, but without a simple log I think it’s just a bridge too far.
So I did the following. I commented out all of the toolbar icons that I haven’t used recently. Then I went through the menu-applications file and looked for all the ones I can recall using this year that weren’t on the toolbar, I added them.
I haven’t had to use the menu for anything since then, yet.
It’s said that the Americans invented some kind of special pens to be able to write without gravity in space. The Russians just used pencils. Sometimes simple is good enough 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.