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

Autostart MacOS and aw-watcher-window #323

Closed
repercussion opened this issue Dec 17, 2019 · 7 comments
Closed

Autostart MacOS and aw-watcher-window #323

repercussion opened this issue Dec 17, 2019 · 7 comments

Comments

@repercussion
Copy link

repercussion commented Dec 17, 2019

starting aw-qt from the terminal works fine for me, but when I try to create an automator app to launch aw on boot, I run into an issue with the aw-watcher-window.

In this image, you can see my attempts to launch aw from the automator application and terminal.

Screen Shot 2019-12-17 at 14 10 24

I have the automator app set up to run this:

/usr/bin/nohup /usr/local/bin/aw-qt >/dev/null 2>&1 &

When I start it with the Automator app, aw-watcher-window isn't able to request access to control “System Events.app“. Even if I run the same in Terminal and grant it access, launching from the Automator app still won't let aw-watcher-window get the access it needs.

The first time I run the app, osascript requests and is granted access to control “System Events.app“. Terminal and iTerm have also been granted such access.

Has anybody got aw running at boot on MacOS?

@ErikBjare
Copy link
Member

I know @exoji2e has got it working in the past.

I think you might need to somehow give Automator such access manually through the system settings?

@xylix
Copy link
Contributor

xylix commented Dec 27, 2019

Any progress on this?

For me this works fine:
nohup /Users/xylix/activitywatch/aw-qt >/dev/null 2>&1 &

I'm running MacOS Mojave. It seems I have somehow given Automator control access in Security -> Privacy -> Accessibility. However I can't seem to remember if I managed to give it automatically through running aw-qt or did I add it manually. I recommend trying to add manual Automator permissions though.

@willvieira
Copy link

willvieira commented Dec 29, 2019

My workaround to run aw at boot on MacOS is to use launchctl.

You have basically two files: one simple bash to run aw called here ~/runActivitiyWatch.sh:

#!/bin/sh

cd /Applications/activitywatch
./aw-qt

And the system launchctl file to be saved in ~/Library/LaunchAgents called com.activitywatch.plist:

<?xml version='1.0' encoding='UTF-8'?>
  <!DOCTYPE plist PUBLIC ''-//Apple Computer//DTD PLIST 1.0//EN' 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'>
  <plist version='1.0'>
  <dict>
   <key>Label</key>
   <string>com.activitywatch</string>
   <key>ProgramArguments</key>
   <array><string>/Users/wvieira/launchActivitywatch.sh</string></array>
   <key>RunAtLoad</key>
   <true/>
  </dict>
</plist>

Edit line 8 with the location of your bash file, and make sure to specify the full path to the file (do not use ~).

Finally you have to load the launchctl file and it should work correctly:

launchctl load ~/Library/LaunchAgents/com.activitywatch.plist

@ErikBjare
Copy link
Member

@willvieira That looks neat, thanks for sharing! But what about the Accessibility permission in that case?

@willvieira
Copy link

@ErikBjare Good point I forgot to mention, I had to give accessibility permission to sh. So before launchctl load the agent, I manually loaded the app by sh ~/runActivitiyWatch.sh on terminal.

@xylix xylix added this to the v0.9 milestone Mar 11, 2020
@ErikBjare
Copy link
Member

This should be a lot easier with the upcoming .app bundle that will be available in v0.9, which should just be possible to add to the normal autostart applications in settings.

@xylix
Copy link
Contributor

xylix commented Mar 18, 2020

Fixed in v0.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants