-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use xinput
to not depend on access to /dev/console
(root only).
#36
base: master
Are you sure you want to change the base?
Conversation
Please merge #32 first. I will rebase this PR then. |
Closes karpathy#34 Additional improvements and fixes: * Why use `cat`, `grep` and `wc` combined when `grep` can do all of this at once? Fixed. [shellcheck](https://www.shellcheck.net/) can make you aware of such things. * Never storge highly sensitive information like keystrokes (which potentially can contain passwords) on persistent storage. * Terminate background processes when the main process gets killed. * Suppress `bash` warning when background process dies. * Updated and fixed README.md accordingly. * Removed trailing whitespace.
5600b3d
to
832037a
Compare
keyfreq.sh
Outdated
PID=$! | ||
|
||
# work in windows of 9 seconds | ||
xinput test 11 > $helperfile & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK when you have 2 keyboards (==laptop w. external one), you capture at most one with this.
For security purposes, I would rather pipe it to | tr -d '[0-9]'
or so instead of /dev/shm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For security purposes, I would rather pipe it to | tr -d '[0-9]' or so instead of /dev/shm
Prefect! Thanks very much 👍 Updated my PR. I think /dev/shm
should be fine or is there something against using it?
AFAIK when you have 2 keyboards (==laptop w. external one), you capture at most one with this.
You are right. Thats when I saw your PR and intended it to be merged first so that I could rebase on it and steal that peace from you. I am to lazy to check that out right now but that is a todo.
f6a0bb6
to
2d0655c
Compare
2d0655c
to
9f820d7
Compare
FYI, I've done a merge of @ypid and @csmarosi xinput code. On my laptop, the keyboard does not come through as device 11 -- so I needed @csmarosi code that dynamically pulls all input devices. However I also wanted @ypid code that moved the temp file to shm and stripped out scan codes. Also, personally I'd like to include mouse clicks as well. One problem I have is that web browser activity is sometimes underrepresented at times I'm primarily using the mouse to interact rather than the keyboard. It's pretty easy to extend @csmarosi's code to include the mouse. |
Sounds good :)
You might want to checkout selfspy for that as it already does this. Maybe it would be worth using the logging backend of selfspy as it also supports other platforms and just looks more mature to me. |
I completely agree that using selfspy for data collection would be a good idea. Much more sophisticated data collection and handling. But ulogme has the best front end - I especially love the bar codes; I can't live without them anymore. (Got hooked through Manictime on windows.) ulogme is great code! In the meantime though, until it uses selfspy, I would vote for merging the xinput patches. I'm running the merged version that's in my GitHub repo now - seems like a good update so far. You guys wrote good patches. :) |
keyfreq.sh
Outdated
PID=$! | ||
|
||
# work in windows of 9 seconds | ||
xinput test 11 | tr -d '0-9' > $helperfile & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My device ID was 10
... this should be configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, done. There might be other ways to configure this for example by including a config file. I just went with environment variables for now.
# in logs/keyfreqX.txt every 9 seconds, where X is unix timestamp of 7am of the | ||
# recording day. | ||
|
||
LANG=en_US.utf8 | ||
|
||
helperfile="logs/keyfreqraw.txt" # temporary helper file | ||
helperfile='/dev/shm/keyfreqraw.txt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not /tmp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/dev/shm
is almost always a tmpfs
which is important for:
Never store highly sensitive information like keystrokes (which potentially can contain passwords) on persistent storage.
Ref: https://superuser.com/questions/45342/when-should-i-use-dev-shm-and-when-should-i-use-tmp
@ypid I just found that the Maybe using the approach used by @csmarosi in csmarosi@738196e#diff-1c19f299da97be2f85d90e241a93212bR17 is the way to do it? |
@dcousens Looks more appropriate indeed. I have not tested ulogme recently so I am missing some experiance running it. |
@ypid I went with using Python instead, as succint, no root. |
Closes #34
Additional improvements and fixes:
cat
,grep
andwc
combined whengrep
can do all of thisat once? Fixed. shellcheck can make you
aware of such things.
potentially can contain passwords) on persistent storage.
bash
warning when background process dies.