Open waldyrious opened 4 years ago
NB: I don't have a mac and have never used it on a Mac. Y’all mac users are on your own. I am happy to accept PRs agains the code or docs to help you.
I understand. I'm happy to help out with whatever I can (e.g. debugging, testing fixes, etc.). Thanks for the fast response!
I can verify that @waldyrious identified the cause correctly. I happened to get iTerm2 into that list and when I run arbtt from iTerm2, it just works.
@oguzhanogreden Thanks for the hint! May I ask how you managed to add iTerm2 to the list? I couldn't find a way to manually add a new entry, and didn't find a configuration key to use with defaults
(the closest I managed to find was a way to disable the prompt, but that felt like the wrong approach). I ended up triggering a screenshot from iTerm2 by running screencapture /tmp/foo.png
, which did bring up the prompt, but I wonder if you had a less roundabout way of doing that.
In any case, this solution didn't seem to work for me, since I don't run arbtt
manually from iTerm2; I set it up using launchd
, as described in the installation instructions. Are you using a different method for automatically starting the program?
I believe I had the iTerm2 added by a similar route a while ago. It was pure coincidence that it was helpful here.
I surveyed some StackOverflow links, including the one you posted, and came up with a Swift script that helps get the prompt. Unfortunately, it gets the prompt for the application from which it is called.
I'm not familiar with the mechanics of launchd
. Perhaps worth if you give it a shot and see if you can get the prompt for that process. Once you have the prompt, you may also ditch the script and call arbtt-capture
executable directly, as far as I understand. If you get to establish a reasonable workflow, I'd love to hear.
I've found two similar questions, on Stack Overflow and Apple developer forums, but neither had an answer 😞.
Update: I've managed to get a permission prompt for "sh", after attempting one of the workarounds suggested by the second link. First I created a test script:
echo -e '#!/bin/sh\n/usr/sbin/screencapture /tmp/foobar.png' > ~/screenshot.sh
chmod +x ~/screenshot.sh
Then I made the following change in ~/Library/LaunchAgents/de.nomeata.arbtt.plist
:
- <string>/Users/waldyrious/.cabal/bin/arbtt-capture</string>
+ <string>/Users/waldyrious/screenshot.sh</string>
Then I logged out and logged in again, and the permission prompt showed up. I have now restored the .plist
file to point to arbtt-capture
, let's see if it starts working now! 🤞
Turns out it wasn't enough to simply reset the original .plist
contents and have arbtt
work again. So what I did was edit the screenshot.sh
script:
#!/bin/sh
-/usr/sbin/screencapture /tmp/foobar.png
+$HOME/.cabal/bin/arbtt-capture
And let .plist
file continue to invoke the screenshot.sh
script instead of calling arbtt
directly. That seems to work (yay! 🎉), but it's clearly a dirty hack. I'll update if I find any better way of doing this.
Thanks @waldyrious. I finally got arbtt working on MacOS Catalina because of you :)
For people in the future, here's what I had to do to get arbtt working:
Run vim ~/Library/LaunchAgents/com.username.arbtt.plist
and paste the text in this file, replacing "liamhinzman" with whatever your username is
Run this command echo -e '#!/bin/sh\n/usr/sbin/screencapture /tmp/foobar.png' > ~/screenshot.sh
Run this command chmod +x ~/screenshot.sh
Log out, and then back in. MacOS will prompt you to grant sh permission to record your screen. Enable this.
Run vim ~/screenshot.sh
and replace this line /usr/sbin/screencapture /tmp/foobar.png
with this $HOME/.cabal/bin/arbtt-capture
Log out, and log back in
After waiting one minute, run arbtt-dump
, and you should see that everything is working.
Note: You can use any command line text editor instead of vim
. E.g. nano
Glad that helped @LiamHz. Just to be sure, your steps are exactly what I did, but presented as an easy to follow list, right?
In that case, I'm afraid we should wait for a more adequate solution to pop up (that we could add to the documentation and therefore close this issue), since this is a very hacky way to get it to work. Agreed?
It seems that screencapture
is doing something to request the necessary permission. Maybe someone can figure out what that is and let arbtt-capture
just do that?
Glad that helped @LiamHz. Just to be sure, your steps are exactly what I did, but presented as an easy to follow list, right?
Yep, just an easy to follow version of what you said to do.
In that case, I'm afraid we should wait for a more adequate solution to pop up (that we could add to the documentation and therefore close this issue), since this is a very hacky way to get it to work. Agreed?
Agreed, it's still hacky. There's a 30% chance I'll do a pull request to fix this in the next month.
@waldyrious you can give it a try to allow screen recording permissions using command line.
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT or REPLACE INTO access VALUES('kTCCServiceScreenCapture','your binary path',1,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1547635615)"
however .sh
solution shared above also works but if you're changing binary then you might need to do the whole process again.
You can now manually add to the Settings > Privacy & Security > Screen & System Audio Recording. There's a plus button, and you can navigate to ~/.cabal/bin and add .arbtt-capture. Seems to work great :-)
I am not longer forced to use a macbook for my work, so I don't have a way to try this out anymore. @oguzhanogreden, @LiamHz, @rjmk — do you think we could close this issue by adding @rjmk's instructions to the documentation?
Ever since I upgraded to the latest macOS Catalina, arbtt ceased to be able to capture the window titles. The problem looks exactly like what I described a while ago in #3:
However, I'm opening a new issue because the problem seems to be slightly different this time.
arbtt-capture
is running and continues to be loaded automatically on startup:It clearly happened when I upgraded to Catalina:
Indeed, macOS Catalina introduced new permissions for capturing information from the screen (e.g. for video calls) and that is likely affecting arbtt. In System Preferences, we can navigate to Security and Privacy > Privacy > Screen Recording, and will see something like this:
I suppose Arbtt needs to be granted permissions here in order to function properly. @vrasneur do you have any suggestions about how we can make an Arbtt entry appear on this screen?