From 1598f97f44f3608de12d0891c18fa469b348a40d Mon Sep 17 00:00:00 2001 From: Csaba Marosi <4bea6c869366227b879ffe4abad50c@gmail.com> Date: Sat, 2 Jan 2016 20:03:20 +0000 Subject: [PATCH] Use only xdotool to determine the active window name. Under xmonad, `xdotool getactivewindow` fails with Your windowmanager claims not to support _NET_ACTIVE_WINDOW, so the attempt to query the active window aborted. xdo_get_active_window reported an error despite claiming to be 'reliable than getwindowfocus'. --- README.md | 2 +- logactivewin.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0863cbd..08e6d44 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ 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`. +2. If you're on Ubuntu, make sure you have the dependencies: `$ sudo apt-get install xdotool`. 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. 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. diff --git a/logactivewin.sh b/logactivewin.sh index 68408b1..ecd74d0 100755 --- a/logactivewin.sh +++ b/logactivewin.sh @@ -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