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

Full Mac Support? #12

Open
sinewave opened this issue Nov 12, 2020 · 14 comments
Open

Full Mac Support? #12

sinewave opened this issue Nov 12, 2020 · 14 comments
Labels
help wanted Extra attention is needed Mac Related to MAC and MAC integration.

Comments

@sinewave
Copy link

Any chance clickable / OS support could make it into an upcoming release?

Having clickable links / OS support would be HUGE for me and the workflow I currently use!

I'm also having some difficult getting the Keyboard Shortcuts to work or perhaps I don't understand how to use them correctly. If I trigger the shortcut for configurable link 1 it doesn’t seem to copy to clipboard for me?

Lastly, would it be possible to add a shortcut to trigger the cb_thunderlink button action?

Thx

@sinewave sinewave changed the title Mac Support? Full Mac Support? Nov 12, 2020
@CamielBouchier
Copy link
Owner

@sinewave

I regret, but I have no knowledge about Mac, neither do I have access to it.
I can explain what is needed. In a nutshell:

  • Native messaging set-up between thunderbird and an OS process.
  • An executable to be started when clicking on a link.

Both are very OS specific and someone with knowledge about that for Mac will need to jump in ...

Camiel B.

@CamielBouchier CamielBouchier added help wanted Extra attention is needed Mac Related to MAC and MAC integration. labels Nov 14, 2020
@coolharsh55
Copy link

I would support a macOS integration as well. I remember thunderlink had an integration, and I found this: link for instructions which uses an App to handle the links. Worth looking into. I'm going to try and see how this works so we can have cbthunderlink integration as well.

@baerbel2019
Copy link

baerbel2019 commented Nov 22, 2021

Update 2023-08-04:
Also working: cb_thunderlink v1.7.2 on macos 13.5 (Ventura) Intel or ARM CPU with Thunderbird 115.1.0 (Supernova)


cb_thunderlink v0.8.0 works great on macos Catalina and Monterey. Here is how to install it:

  1. Download cb_thunderlink archive

    Using the git repository will allow you to track your changes and to merge with newer versions easily. Be careful where to place this repository. The ScriptEditor app that we are going to create below needs access to that directory. I prefer the home directory ($HOME) as things are not forgotten there.

    cd ~
    git clone https://github.com/CamielBouchier/cb_thunderlink
    cd cb_thunderlink
    CBDIR="$(pwd)"
  2. Set the execution bit on the python script

    cd "${CBDIR}"
    chmod +x cb_thunderlink.py
  3. Update location of the python script in the App JSON file

    Just replace the string cb_thunderlink.exe with the full path of the python script.

    cd "${CBDIR}"
    sed -i '' -e "s#cb_thunderlink.exe#${CBDIR}/cb_thunderlink.py#" cb_thunderlink.json
  4. Register App JSON file

    It took me a while to find the proper directory. After lots of browsing I found the correct location in the source code of openwith. In my case the directory did not exist and had to be created first.

    mkdir -p ~/Library/Mozilla/NativeMessagingHosts
    ( cd ~/Library/Mozilla/NativeMessagingHosts && ln -s "${CBDIR}/cb_thunderlink.json" )
  5. Create User Application Directory

    mkdir -p ~/Applications
  6. Launch ScriptEditor

  7. In ScriptEditor paste the following script (possibly adapt for your CBDIR)

    I never used ScriptEditor before. It's very different from other programming languages. The script here works but this can be improved for sure.

    on open location givenURI
        try
            set prgpath to POSIX path of (path to home folder as string) & "/cb_thunderlink/cb_thunderlink.py"
            set quotedURI to quoted form of givenURI
        on error errMsg
            display dialog "ERROR: " & (name of me) & " failed to build command: " & errMsg
            return
        end try
        try
            do shell script prgpath & " " & quotedURI
        on error errMsg
            display dialog "ERROR: " & (name of me) & " failed to run: " & prgpath & " " & quotedURI & ": " & errMsg
        end try
    end open location
  8. In ScriptEditor press the small grey play button to verify the syntax

  9. In Script Editor save the Script as Application

    • File > Save...
    • Choose name CbThunderlink (extension app will be added automatically)
    • Choose directory ~/Applications
    • Choose File Format Application
  10. Register your new AppleScript App for URI scheme names cbthunderlink and thunderlink

    Use duti or SwiftDefaultApps

    I'm using homebrew to install additional software but you can also install both of these manually I guess. SwiftDefaultApps also has a GUI accessible through System Preferences.

    brew install --cask swiftdefaultappsprefpane
    SWDA="$(/bin/ls -1 $(brew --prefix)/Caskroom/swiftdefaultappsprefpane/*/swda | tail -1)"
    "${SWDA}" setHandler --app "${HOME}/Applications/CbThunderlink.app" --URL cbthunderlink
    "${SWDA}" setHandler --app "${HOME}/Applications/CbThunderlink.app" --URL thunderlink
  11. Download cb_thunderlink.xpi from the latest release of cb_thunderlink

    cd ~/Downloads
    CBLATEST="$(curl -s https://api.github.com/repos/CamielBouchier/cb_thunderlink/releases | grep browser_download_url | cut -d\" -f4 | head -1)"
    curl -o - -L "${CBLATEST}" | bsdtar -xvf - --strip-components 1 "cb_thunderlink/cb_thunderlink.xpi"
  12. Install the xpi file

    Thunderbird > Tools > Addons and Themes > Gear Wheel Button > Install Addon from File...

    It is my understanding that you need the original xpi file as Thunderbird requires Addons to be signed. If you manually compose the xpi file (it's just a zip file) you will only be able to install as temporary addon.

Thank you Camiel for this wonderful addon.

@CamielBouchier
Copy link
Owner

CamielBouchier commented Dec 5, 2021 via email

@coolharsh55
Copy link

Hi. I got the below error on macOS Ventura 13.2 with Thunderbird 102 and Python 3.11. This occurs on calling cb_thunderlink.py with the URL, clicking the thunderlink externally, putting the URL in a browser. I'm not sure whether this is something weird from macOS or there's something out of date in the above steps.

Traceback (most recent call last):
  File "/Users/harsh/apps/cb_thunderlink/./cb_thunderlink", line 211, in <module>
    send_socket.connect(server_address)
ConnectionRefusedError: [Errno 61] Connection refused

For now, I've set the cbthunderlink:// script handler to instead copy the link to clipboard and then I switch to thunderbird and click the cbthunderlink button - which does work. (thanks for the extension and the script - its really handy!)

@CamielBouchier
Copy link
Owner

@coolharsh55 I am really sorry, but this seems macOS specific. I have no access to a mac, neither do I intend to learn it. I can keep myself busy with Linux(es) and Windows.

O wait, if someone would send me a expensive nice mac to investigate and try, I might reconsider this position :)

Camiel B.

@baerbel2019
Copy link

baerbel2019 commented Feb 7, 2023

@coolharsh55:
Your error message means that the cb_thunderlink extension is not answering to requests. This is the case if either Thunderbird is not running or the extension has been disabled. In both cases you will get a popup window with the message you posted. Likely the same error message by cb_thunderlink.py will appear on other architectures.

@CamielBouchier
Copy link
Owner

@coolharsh55: Your error message means that the cb_thunderlink extension is not answering to requests. This is the case if either Thunderbird is not running or the extension has been disabled. In both cases you will get a popup window with the message you posted. Likely the same error message by cb_thunderlink.py will appear on other architectures.

Yes that makes sense of course. I was silently, but probably overly enthusiastically, assuming thunderbird and the extension was running in the first place ...

If the error occurs while this is the case, there might be other processes that seized the port, protection software intervening, etc ...

@coolharsh55
Copy link

Hi. Apologies, I should have clarified - thunderbird is running, cbthunderlink extension is running, and links work inside thunderbird i.e. copying the link to clipboard and clicking the cbthunderlink button inside thunderbird does open the email. So there seems to be a connection disruption from the script to the thunderbird/extension process. I can confirm this is macOS specific - the same setup works okay on Linux. I'll keep tinkering to see if I can figure out a solution as well.

@CamielBouchier
Copy link
Owner

Hi. Apologies, I should have clarified - thunderbird is running, cbthunderlink extension is running, and links work inside thunderbird i.e. copying the link to clipboard and clicking the cbthunderlink button inside thunderbird does open the email. So there seems to be a connection disruption from the script to the thunderbird/extension process. I can confirm this is macOS specific - the same setup works okay on Linux. I'll keep tinkering to see if I can figure out a solution as well.

Interesting. So my enthusiastic assumption was correct ...
Just a few ideas (again, not having access or knowledge about macos makes them pretty random ...):

  • Do you have the issue after a fresh restart? I.e. is it not related to the one or the other process having blocked the socket/port/ ?
  • Any chance some proxy configuration is not playing nice with the socket communication?

@baerbel2019
Copy link

cb_thunderlink works for me on macOS Ventura 13.2 using Thunderbird 102.7. I can paste cbthunderlink://xxx URLs in both Firefox 109.0.1 and Safari 16.3.

Check the output of...

  • /usr/sbin/lsof -i :1302 - shows what process is listening on TCP port 1302 (should be Python)
  • lsof -Pp $(pgrep -f cb_thunderlink) | grep -i listen - shows TCP ports the python script is listening to
  • /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate - shows whether firewall is enabled
  • sudo pfctl -sa - shows firewall rules (and more)

@plur9
Copy link

plur9 commented Mar 29, 2023

I followed the instructions but stumbled on step 10 as the SWDA url was not working for me. Turns out that on my mac (running Venture) it is not /usr/local/... but /opt/homebrew/Caskroom/... Might be helpful for somebody.

cb_thunderlink v0.8.0 works great on macos Catalina and Monterey. Here is how to install it:

...

  1. Register your new AppleScript App for URI scheme names cbthunderlink and thunderlink
    Use duti or SwiftDefaultApps
    I'm using homebrew to install additional software but you can also install both of these manually I guess. SwiftDefaultApps also has a GUI accessible through System Preferences.
    brew install --cask swiftdefaultappsprefpane
    SWDA="$(/bin/ls -1 /usr/local/Caskroom/swiftdefaultappsprefpane/*/swda | tail -1)"
    "${SWDA}" setHandler --app "${HOME}/Applications/CbThunderlink.app" --URL cbthunderlink
    "${SWDA}" setHandler --app "${HOME}/Applications/CbThunderlink.app" --URL thunderlink

@baerbel2019
Copy link

@plur9
Thanks for pointing this out! I modified the bad assignment in point 10 in my above comment to:

SWDA="$(/bin/ls -1 $(brew --prefix)/Caskroom/swiftdefaultappsprefpane/*/swda | tail -1)"

@paradeiser
Copy link

Sorry, this is beyond my horizon.
It would be great if someone with a mac background could make this work for normal users.
Pretty please 🙏🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed Mac Related to MAC and MAC integration.
Projects
None yet
Development

No branches or pull requests

6 participants