-
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?
Changes from 1 commit
832037a
9f820d7
a137701
358df36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,42 @@ | ||
#!/bin/bash | ||
|
||
|
||
# logs the key press frequency over 9 second window. Logs are written | ||
# logs the key press frequency over 9 second window. Logs are written | ||
# 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' | ||
## FIXME: Still potential security risk even when not logged to persistent storage. | ||
## Maybe rewrite script in Python and count STDOUT directly and send SIGINT | ||
## after 9 seconds. | ||
|
||
mkdir -p logs | ||
|
||
trap 'kill $(jobs -p)' EXIT | ||
|
||
while true | ||
do | ||
showkey > $helperfile & | ||
PID=$! | ||
|
||
# work in windows of 9 seconds | ||
xinput test 11 > $helperfile & | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prefect! Thanks very much 👍 Updated my PR. I think
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. |
||
|
||
## In case you can not get `xinput` to work. Note that you will need to run `showkey` as root. | ||
# showkey > $helperfile & | ||
|
||
# Work in windows of 9 seconds | ||
sleep 9 | ||
kill $PID | ||
|
||
# count number of key release events | ||
num=$(cat $helperfile | grep release | wc -l) | ||
|
||
# append unix time stamp and the number into file | ||
|
||
# shellcheck disable=SC2046 | ||
kill $(jobs -rp) | ||
# shellcheck disable=SC2046 | ||
wait $(jobs -rp) 2>/dev/null | ||
|
||
# Count number of key release events | ||
num="$(grep --count release "$helperfile")" | ||
|
||
# Append unix time stamp and the number into file | ||
logfile="logs/keyfreq_$(python rewind7am.py).txt" | ||
echo "$(date +%s) $num" >> $logfile | ||
echo "$(date +%s) $num" >> "$logfile" | ||
echo "logged key frequency: $(date) $num release events detected into $logfile" | ||
|
||
done | ||
|
||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
#!/bin/bash | ||
|
||
trap 'kill $(jobs -p)' EXIT | ||
|
||
if [ "$(uname)" == "Darwin" ]; then | ||
# This is a Mac | ||
./osx/run_ulogme_osx.sh | ||
else | ||
# Assume Linux | ||
sudo echo -n "" | ||
sudo ./keyfreq.sh & | ||
./keyfreq.sh & | ||
./logactivewin.sh | ||
fi |
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 atmpfs
which is important for:Ref: https://superuser.com/questions/45342/when-should-i-use-dev-shm-and-when-should-i-use-tmp