Run at login OSX #47

Closed
chuenjin opened this Issue Jan 11, 2013 · 23 comments

Projects

None yet

6 participants

@chuenjin

How would I run selfspy at login on a mac? Adding it to launchd appears to work, but nothing actually gets logged.

Contributor
ljos commented Jan 11, 2013

Do you feed it the password with -p?

Contributor
ljos commented Jan 11, 2013

I just saw that I also added the full path to selfspy to make it run. Maybe that is the problem?

Contributor
ljos commented Jan 11, 2013

This is the plist I use

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.github.selfspy</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/share/python/selfspy</string>
        <string>-p</string>
        <string>PASSWORD</string>
    </array>
    <key>KeepAlive</key>
    <true/>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
Owner
gurgeh commented Jan 11, 2013

Under Linux, a Tk dialog pops up when you don't supply the password. Does this not work on OSX?

Contributor
ljos commented Jan 11, 2013

Look at that. It actually does. I think he was just missing the path.

Owner
gurgeh commented Jan 11, 2013

That's how I run it. I feel dirty leaving passwords in plaintext ;)

Contributor
ljos commented Jan 11, 2013

There probably is a way to make it hook into the os x keychain to make things better. I might look into this later.

I'm running it without the -p. With or without the path, I get the python icon in the dock, the tk password prompt comes up, and it appears to accept my password. But selfstats --back 30 m --showtext once it's been running for a bit show no entries.

It works fine when I run selfspy from the command line.

Contributor
ljos commented Jan 11, 2013

Could you pull the latest and try again? The pytohn icon in the doc should be removed with that.

There's a typo on line 26 of init.py in the latest version. Missing i in "import". :)

But even once thats corrected I still have the same issue.

Contributor
ljos commented Jan 11, 2013

OKOK. I can confirm that I have the same error now. I don't understand why though. It worked earlier on my machine .. . Need to figure out what is different from before.

I actually had the same problem using your fork a few months ago, before your changes were merged.

Contributor
ljos commented Jan 11, 2013

Yeah. I don't think it is the code. It works. It has something to do with the configuration of launchd. It did work for me earlier today.

Contributor
ljos commented Feb 1, 2013

Sorry for taking long, but some things came up and I havnt had time too look as much into this. I did start to zero inn but had to do other things. It might be some time before I can work on this again though.

chuenjin commented Feb 6, 2013

No worries. I'm just running as a .command startup item at the moment anyway, and hiding the resulting iTerm window.

Contributor
mgilbir commented Feb 24, 2013

@ljos I just made a pull request that provides keychain integration. Maybe that helps with the launching without having to write the password anywhere visible.

Contributor
ljos commented Feb 25, 2013

Cool! The problem here though is not writing the password anywhere. It is that something strange is happening when the program is started by the launchd deamon.

Yes, same problem here, when selfspy is started with launchd looks like it works 2 o 3 minutes and then stops

Contributor
ljos commented Feb 25, 2013

You actually get it to work after entering your password?

Btw. One of the reasons this is difficult to debug is that the systemlog has a max amount of errors it will print to the logs pr sec and what happens is that selfspy will create way to many errors and I can't see what is happening.

I will be trying to fix this again this week as I just finished a deadline and I can do other things now.

lepht commented Mar 12, 2013

I was having the same issue, and found that specifying the full path to my python bin resolved the issue:

$ launchctl list com.lepht.selfspy                                                                                   ⏎
  {
    "Label" = "com.lepht.selfspy";
    "LimitLoadToSessionType" = "Background";
    "OnDemand" = true;
    "LastExitStatus" = 15;
    "PID" = 57911;
    "TimeOut" = 30;
    "ProgramArguments" = (
      "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python";
      "/usr/bin/selfspy";
    );
    "MachServices" = {
    };
    "PerJobMachServices" = {
      "com.apple.CFPasteboardClient" = mach-port-object;
      "com.apple.tsm.portname" = mach-port-object;
      "com.apple.axserver" = mach-port-object;
  };
Contributor
ljos commented Mar 13, 2013

this also seems to work for me:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.github.gurgeh.selfspy</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/python</string>
        <string>/usr/local/share/python/selfspy</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Though, I am having some other strange problem where it will no longer register NSKeyDown/Up events, just MouseMove and FlagChanged. I just did a fresh reinstall and might have botched pyobjc though.

Contributor
ljos commented Mar 15, 2013

I figured out why it does not listen to keypresses. I had forgotten to enable access for assitive devices in the system preferences. Now it works perfectly on my machine.

Contributor
ljos commented Mar 15, 2013

@gurgeh, don't close this just yet. I want to document this somewhere first.

@gurgeh gurgeh closed this Mar 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment