Closed alperyilmaz closed 3 years ago
Hi @alperyilmaz!
Thanks for the appreciations, and for your detailed feedback!
It's perfectly normal to see several processes of these xinput test [kbd_id]
, see in the keyfreq.sh
script there is a for loop:
# check each possible keyboard
keyboardIds=$(xinput | grep 'slave keyboard' | grep -o 'id=[0-9]*' | cut -d= -f2)
for kbd_id in $keyboardIds; do
...
As you saw, there is a few keyboards on your device, and keyfreq.sh
is very naive and constantly try them all.
If you look at your pstree
output above, you will see that there is only on mother process of keyfreq.sh
, showing that it was only launched once.
As soon as there is timeout
in the for loop (the one I show just above), pstree
will show different processes being active simultaneously.
So, to conclude, yes everything works as expected! I'm sure the keyfreq.sh
could be improved, for instance by storing somewhere the list of kbd_id
of active keyboards and only scanned these (which for most laptops will be only real keyboard!), but I never tried to optimize this.
One reason is that on my laptops, there is always a background uLogMe process running, and if I change from one office to another one, I use different external keyboards on each office, so I don't want to have to manually relaunch uLogMe!
Thanks for detailed answer. It's good to know that it's normal.
Maybe, the xinput polling for"list of kbd_id
of active keyboards" might be performed every 10 mins or 30 mins, then maybe the list is cleaned up by removing buttons or video bus from list, then listen to all "actual" keyboards.
For instance:
xinput | grep 'slave keyboard' | sed -e's/slave *keyboard//' | grep keyboard | grep -o 'id=[0-9]*' | cut -d= -f2
decreases kbd_id list to 3 only.. Not sure if it will miss any "actual" keyboards though..
somehow, the following line finds keyboard ids as 5 11 and 17
xinput | grep 'slave keyboard' | sed -e's/slave *keyboard//' | grep keyboard | grep -o 'id=[0-9]*' | cut -d= -f2
however the keyfreq.sh was collecting data from 5 and 17 only, missing the actual keyboard 11. So, I used the following line for filter out non-keyboard entries (taken from this post)
xinput --list | cut -d\[ -f1 | grep -i keyboard | egrep -iv 'virtual|video|button|bus' | egrep -o 'id=[0-9]+' | cut -f2 -d=
Hi @alperyilmaz, Thanks for the suggestions. I no longer update uLogMe except for bug fixes, so I won't try these. But if you do try something and want to submit a pull-request, I will gladly look at it and merge it! Thanks in advance :pray:! I wish you a Happy New Year (in advance, or not, depending on your time zone)!
first of all, thanks for this great tool. I was using the karpathy/ulogme which required
sudo
for keyfreq, your version does not need it and it's much appreciated. When I runps -ef f
I see many copies of keyfreq.sh in the output. Is this expected or something is off in my case?Initially, I thought the problem might be too many tty/terminals being open. But when I closed many of them the number of
keyfreq.sh
entries inps
output didn't change.Luckily, there are no duplicate entries in
logs/keyfreq_today.txt
file.Here's process list:
I checked the shared memory folder and saw the following list:
And here's the list of inputs: