CamielBouchier / cb_thunderlink

thunderlink replacement: Clickable, durable links to specific messages inside Thunderbird.
Mozilla Public License 2.0
70 stars 14 forks source link

Full Mac Support? #12

Open sinewave opened 3 years ago

sinewave commented 3 years ago

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

CamielBouchier commented 3 years ago

@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:

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

Camiel B.

coolharsh55 commented 3 years ago

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 commented 2 years ago

Reviewed and Working Setups:

Here is how to install cb_thunderlink manually on macos:

  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 cbthunderlink.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 Apple 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
    XPI_URL="$(curl -s https://api.github.com/repos/CamielBouchier/cb_thunderlink/releases | grep browser_download_url | cut -d\" -f4 | head -1)"
    XPI_VERSION="$(echo "${XPI_URL}" | sed -e 's#.*/Release_##' -e 's#/.*##' )"
    curl -o "cb_thunderlink_${XPI_VERSION}.xpi" -L "${XPI_URL}"
  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 commented 2 years ago

Thanks a lot! I referred to this description in the documentation.

Camiel B


From: baerbel2019 @.** Sent: Monday, November 22, 2021, 11:00 AM To: CamielBouchier/cb_thunderlink Cc: Camiel B; Comment Subject:* [CamielBouchier/cb_thunderlink] Full Mac Support? (#12)

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 clonehttps://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
<https://github.com/darktrojan/openwith/blob/master/webextension/native/open_with_mac.py#L48>.
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 folderas  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 name |cbthunderlink|

Use duti <https://github.com/moretension/duti> or SwiftDefaultApps
<https://github.com/Lord-Kamina/SwiftDefaultApps>

/I'm using homebrew <https://brew.sh/> 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

11.

Download |cb_thunderlink.xpi| from the latest release of
cb_thunderlink
<https://github.com/CamielBouchier/cb_thunderlink/releases>

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

12.

Install the xpi file
<https://support.mozilla.org/en-US/kb/installing-addon-thunderbird>

|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
<https://blog.mozilla.org/addons/2016/01/22/add-on-signing-update/>.
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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/CamielBouchier/cb_thunderlink/issues/12#issuecomment-975351286, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARG7X2OMDZK63FCHVTRFSULUNIIFNANCNFSM4TTW67AQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

coolharsh55 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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 ...):

baerbel2019 commented 1 year ago

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...

plur9 commented 1 year ago

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 commented 1 year ago

@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 commented 7 months ago

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 🙏🙏