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

Make it work under xmonad and Docker #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ See a blog post (along with multiple screenshots) describing the project [here.]
**To start recording**

1. Clone the repository to some folder: `$ git clone https://github.com/karpathy/ulogme.git`
2. If you're on Ubuntu, make sure you have the dependencies: `$ sudo apt-get install xdotool wmctrl`. On Fedora, you may also need `sudo yum install gnome-screensaver`.
3. `cd` inside and run `$ ./ulogme.sh` (note: this will ask you for sudo authentication which is required for `showkey` command). This will launch two scripts. One records the frequency of keystrokes and the other records active window titles. Both write their logs into log files in the `logs/` directory. Every log file is very simply just the unix time stamp followed by data, one per line.
2. If you're on Ubuntu, make sure you have the dependencies: `$ sudo apt-get install xinput xdotool`. On Fedora, you may also need `sudo yum install gnome-screensaver`.
3. `cd` inside and run `$ ./ulogme.sh`. This will launch two scripts. One records the frequency of keystrokes and the other records active window titles. Both write their logs into log files in the `logs/` directory. Every log file is very simply just the unix time stamp followed by data, one per line.
4. For **OSX** only: there might be an additional step where you have to go to System Preferences > Security & Privacy > Accessibility, and make sure that Terminal (or iTerm2, or whatever you use to launch ulogme) is checked. If it wasn't checked previously and you just checked it, you may need to restart ulogme. If you don't do this step, you might find that window logging works but keypress logging doesn't.

**The user interface**
Expand Down
21 changes: 13 additions & 8 deletions keyfreq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@

LANG=en_US.utf8

helperfile="logs/keyfreqraw.txt" # temporary helper file
helperfile="logs/keyfreqraw" # temporary helper file

mkdir -p logs

while true
do
showkey > $helperfile &
PID=$!

# work in windows of 9 seconds
sleep 9
kill $PID
# check each possible keyboard
keyboardIds=$(xinput | grep 'slave keyboard' | grep -o 'id=[0-9]*' | cut -d= -f2)
# and grep only the updated ones
filesToGrep=''
for id in $keyboardIds; do
fileName="$helperfile.$id"
# work in windows of 9 seconds
timeout 9 xinput test $id > $fileName &
filesToGrep+="$fileName "
done
wait

# count number of key release events
num=$(cat $helperfile | grep release | wc -l)
num=$(grep release $filesToGrep | wc -l)

# append unix time stamp and the number into file
logfile="logs/keyfreq_$(python rewind7am.py).txt"
Expand Down
3 changes: 1 addition & 2 deletions logactivewin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ do
if [ $islocked = true ]; then
curtitle="__LOCKEDSCREEN"
else
id=$(xdotool getactivewindow)
curtitle=$(wmctrl -lpG | while read -a a; do w=${a[0]}; if (($((16#${w:2}))==id)) ; then echo "${a[@]:8}"; break; fi; done)
curtitle=$(xdotool getwindowfocus getwindowname)
fi

perform_write=false
Expand Down
3 changes: 1 addition & 2 deletions ulogme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ if [ "$(uname)" == "Darwin" ]; then
./osx/run_ulogme_osx.sh
else
# Assume Linux
sudo echo -n ""
sudo ./keyfreq.sh &
./keyfreq.sh &
./logactivewin.sh
fi