Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ypid
Copy link
Contributor

@ypid ypid commented May 7, 2016

Closes #34

Additional improvements and fixes:

  • Why use cat, grep and wc combined when grep can do all of this
    at once? Fixed. shellcheck can make you
    aware of such things.
  • Never store 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.

@ypid
Copy link
Contributor Author

ypid commented May 7, 2016

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.
keyfreq.sh Outdated
PID=$!

# work in windows of 9 seconds
xinput test 11 > $helperfile &
Copy link

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

Copy link
Contributor Author

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.

@ardentperf
Copy link

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.

@ypid
Copy link
Contributor Author

ypid commented May 14, 2016

FYI, I've done a merge of @ypid and @csmarosi xinput code.

Sounds good :)

Also, personally I'd like to include mouse clicks as well.

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.

@ardentperf
Copy link

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 &
Copy link

@dcousens dcousens May 31, 2017

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

Copy link
Contributor Author

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'
Copy link

@dcousens dcousens May 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not /tmp?

Copy link
Contributor Author

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

@dcousens
Copy link

dcousens commented Jun 3, 2017

@ypid I just found that the ULOGME_KEYBOARD_ID can change, without warning.
That is, suddenly my keyboard was 9, not 10 - without a restart.

Maybe using the approach used by @csmarosi in csmarosi@738196e#diff-1c19f299da97be2f85d90e241a93212bR17 is the way to do it?

@ypid
Copy link
Contributor Author

ypid commented Jun 3, 2017

@dcousens Looks more appropriate indeed. I have not tested ulogme recently so I am missing some experiance running it.

@dcousens
Copy link

dcousens commented Jun 5, 2017

@ypid I went with using Python instead, as succint, no root.
No process spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use of xinput under linux could remove sudo requirement
4 participants