karpathy / ulogme

Automatically collect and visualize usage statistics in Ubuntu/OSX environments.
1.02k stars 194 forks source link

Starting ulogme at login #42

Open glung opened 8 years ago

glung commented 8 years ago

Hello,

I am not too sure where to put the instructions or the code for starting ulogme at run time. I think though it would be useful for others. I can contribute but need some guidance.

Cheers

glung commented 8 years ago

on macosx, you need to create the file ulogme-launcher.plist in ~/Library/LaunchAgents/

<plist version="1.0">
 <dict>
   <key>Label</key>
   <string>ulogme-daemon</string>
   <key>RunAtLoad</key>
   <true />
   <key>Program</key>
   <string>/Users/<PATH>/launch_ulogme.sh</string>
  </dict>
</plist>

launch_ulogme.sh contains

#!/bin/sh
(cd <{PATH_TO_ULOGME> && ./ulogme.sh)

Then, run : launchctl load ~/Library/LaunchAgents/ulogme-launcher.plist

eliatlas commented 8 years ago

I tried this, and noticed that the script stopped recording keyfreq. Once I run the script directly, with launch_ulogme.sh, the keys are recorded. Didn't find a solution so far.

sergregory commented 7 years ago

The problem occurs because the keyfreq recording requires root access (at least on linux). For me, I solved this with the following modification of the ulogme.sh script (please note, this code is for Bash under Linux, I have no Mac OS to check it):

# Assume Linux
  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  pushd "${DIR}"
  echo "" > ./ulogme.log
  until [ "$(pgrep -fca 'keyfreq')" -gt 0 ]
  do
      gksudo -D <homedir>/.config/autostart/ulogme.desktop ./keyfreq.sh &
      sleep 10
      echo "trying to start keyfreq" >> ./ulogme.log
      started_count=$(pgrep -fca "keyfreq")
      echo "started_count = ${started_count}"
  done
  until [ "$(pgrep -fca 'logactivewin')" -gt 0 ]
  do
      ./logactivewin.sh &
      echo "trying to start logactivewin" >> ./ulogme.log
      started_count=$(pgrep -fca "logactivewin")
      echo "started_count = ${started_count}"
  done
  until [ "$(pgrep -fca 'ulogme_serve')" -gt 0 ]
  do
      python ./ulogme_serve.py &> /dev/null &
      echo "trying to start ulogme_serve" >> ./ulogme.log
      started_count=$(pgrep -fca "ulogme_serve")
      echo "started_count = ${started_count}"
  done
  echo "all routines started"
  popd