ssborbis / ContextSearch-web-ext

Search engine manager for modern browsers
349 stars 37 forks source link

Works well on Windows, but doesn't work on Mac? #498

Closed runningcheese closed 2 years ago

runningcheese commented 2 years ago

thanks for your extension, you did a good job.

but when i try to lanugh a browser, it works well in windows, but doesn't work in mac?

did i miss out something?

iShot2022-06-26 14 16 18 iShot2022-06-26 14 17 48 iShot2022-06-26 14 18 22 iShot2022-06-26 14 18 39
runningcheese commented 2 years ago

Anyway, i have made a big promotion in my soical network, to introduce your great extension to my following fans!

ssborbis commented 2 years ago

Hmm.. to be honest, I've never tested on mac. I assumed, based on the reference material from MDN, that it would work similar to linux. I can see on your screenshots, the messenger app is connected ( v2.14 ) . You might need to be setting the working directory to the folder those app binaries are located in. I don't have a mac OS handy to test. I'll see about setting up a virtual machine.

runningcheese commented 2 years ago

@ssborbis

could you please take a screenshot from your linux, to show how you make the settings?

and i have try "working directory", it's still not happening, but it works on Windows.

anyway,

i used to use this addon: https://addons.mozilla.org/zh-CN/firefox/addon/open-with, and it works on windows and mac.

Thanks for your reply!

iShot2022-06-29 00 25 02
ssborbis commented 2 years ago

I am in the process of installing a MacOS virtual machine. I will update you when I have the app launcher feature up and working.

runningcheese commented 2 years ago

I am in the process of installing a MacOS virtual machine. I will update you when I have the app launcher feature up and working.

thanks for your great work!

ssborbis commented 2 years ago

It looks like /Applications/Firefox.app is actually a directory. You need to point to the binary within.

/Applications/Firefox.app/Contents/MacOS/firefox-bin "{searchTerms}"

I assume the same is true of other .app listings found under /Applications/

runningcheese commented 2 years ago

@ssborbis

Thanks for your Testing.

It works fine now!!

But when i lanugh "Downie 4" which is a video download tool, it will start the application, but will not start download the url.

That makes me confused.

iShot2022-06-29 16 40 46

And one more thing!

is it possible to lanugh "Photoshop" and open the image in Photoshop? (both windows and mac)

Thanks in advance.

ssborbis commented 2 years ago

is it possible to lanugh "Photoshop" and open the image in Photoshop

Probably. I assume photoshop can open an url directly, but if not, use a script to download the url & open in photoshop instead.

This is how I open an url in GIMP

"C:\\Program Files\\GIMP 2\\bin\\gimp-2.10.exe" -n -a "{searchTerms}"

I'm sure PS has a similar option. I don't have PS, so you'll need to look through the command line options.

when i lanugh "Downie 4" which is a video download tool, it will start the application, but will not start download the url

It may not accept URLs from the command line.

ssborbis commented 2 years ago

Here we go. This is a better way to launch apps on Mac

open -a 'Downie 4' "{searchTerms}" open -a 'Firefox' "{searchTerms}"

etc

runningcheese commented 2 years ago

Here we go. This is a better way to launch apps on Mac

open -a 'Downie 4' "{searchTerms}" open -a 'Firefox' "{searchTerms}"

etc

Love you!

Everything works fine now!!!

But Photoshop still can't open an image directly, either windows or mac.

But it's fine for me.

Maybe because of the photoshop limitation.

ssborbis commented 2 years ago

if photoshop doesn't have a built-in way, you can use the curl trick I posted in #500

for windows, it would probably be something like this curl "{searchTerms}" -o tmp & "c:\\path\to\photoshop.exe" tmp

If curl isn't included on macOS, it's easy enough to get. It should be similar syntax

runningcheese commented 2 years ago

I just try curl command, but still can not open image directly.

It's fine for me, if can not make it happen.

截屏图片

7peanuts commented 2 years ago

if photoshop doesn't have a built-in way, you can use the curl trick I posted in #500

"D:\\path\to\photoshop.exe" -n -a "{searchTerms}"

This can open PS, but no pictures.

curl "{searchTerms}" -o tmp & "D:\\path\to\photoshop.exe" tmp

This can also open PS, but PS doesn't support tmp format.

Cannot complete the clear request because it is not the type of document referred to.

20220630113006

But it can be used on Krita.

curl "{searchTerms}" -o tmp & "D:\\Program Files\\Krita (x64)\\bin\\krita.exe" tmp

20220630165031

ssborbis commented 2 years ago

Sorry, I don't have photoshop for testing. ( Is there a free version? ). There's always a way.

7peanuts commented 2 years ago

Sorry, I don't have photoshop for testing. ( Is there a free version? ). There's always a way.

Yeah, it has a 7-day free trial.

ssborbis commented 2 years ago

The following script allows for downloading a file via cURL to the macOS temporary folder and opening the file, by name, with the application of choice.

download.sh

#!/bin/sh

cd $TMPDIR
FILENAME=`curl -OJs -w %{filename_effective} $2`
open -a $1 $TMPDIR/$FILENAME

Make sure to chmod +x the file, and place it somewhere you know. Then your application launcher command will look like this:

/Users/virtualuser/download.sh "Firefox" "{searchTerms}"

replace "Firefox" with whatever app can be called by open -a. If calling binaries more directly, you'll need to modify the script.

runningcheese commented 2 years ago

@ssborbis

still not working! but it's fine, it's great enough for me.

ssborbis commented 2 years ago

I refuse to believe Photoshop can't open files from a shell script. If I can get PS installed, I'll figure out something.

7peanuts commented 2 years ago

I refuse to believe Photoshop can't open files from a shell script. If I can get PS installed, I'll figure out something.

Maybe you can download it from the Pirate Bay. I don't know if it's allowed in your region.

runningcheese commented 2 years ago

@ssborbis

One more question please!

How to lanugh "yt-dlp" on macOS? it doesn't work with open -a command.

7a6a15d5gy1gyqwjw57n9j223s19cnh0

iShot2022-07-02 17 54 59 iShot2022-07-02 18 07 43
ssborbis commented 2 years ago

@runningcheese

Have you tried calling yt-dlp directly, without the open -a "Terminal" ?

runningcheese commented 2 years ago

@ssborbis

Unfortunatly, Not Working!

iShot2022-07-03 10 04 18 iShot2022-07-03 10 02 56
ssborbis commented 2 years ago

mac appears to be a bit of a pain to play nice with the terminal. This is the command I've had the best luck with. Edit to your specs

osascript -e 'tell app "Terminal" to do script "/Users/virtualuser/Downloads/yt-dlp -P /Users/virtualuser/Desktop --no-playlist \"{searchTerms}\""'

I'm having some ssl cert issues, so that command doesn't actually download anything, but it looks like the command is working.

The terminal opens in the background, and doesn't close when complete. I just don't know enough about mac to fix that. I'm sure there's a way. You'll have to do some googling.

runningcheese commented 2 years ago

osascript -e 'tell app "Terminal" to do script "/Users/virtualuser/Downloads/yt-dlp -P /Users/virtualuser/Desktop --no-playlist \"{searchTerms}\""'

It works fine!! love you!

ssborbis commented 2 years ago

I had a mistake in the download.sh script. Put a $ when it should have been a %

Here's a corrected script that should work on mac and linux

#!/bin/sh

TMP="/tmp"
if [ "$OSTYPE" = 'darwin'* ]; then TMP=$TMPDIR; fi
cd $TMP
FILENAME=`curl -OJs -w "%{filename_effective}" $2`
$1 $TMP/$FILENAME

App launcher command would be something like:

/path/to/download.sh "open -a Photoshop" "{searchTerms}"

ssborbis commented 2 years ago

FYI, in future versions of this addon, you'll simply check a box on the app launcher edit modal to have the python native app download the file to be opened. No script needed. I'm testing now on linux. Looks good so far.

runningcheese commented 2 years ago

@ssborbis Thanks for your great work, looking forward to...

ssborbis commented 2 years ago

I posted a beta you can try out.

https://github.com/ssborbis/ContextSearch-web-ext/releases/download/1.40beta/contextsearch_web_ext-1.40b5.xpi

Replace the param {searchTerms} with {download_url} in app launcher templates to direct the native app to download the file found at the URL you've presumably searched for through CS.

For example, to download a file by URL and open in GIMP in linux, I'm using this template

gimp -a "{download_url}"

You'll need the lastest version of the native app ( ContextSearch.py v2.16 ) https://github.com/ssborbis/ContextSearch-Native-App/raw/master/ContextSearch.py

runningcheese commented 2 years ago

@ssborbis Seems not happening!

and when i replace the 2.16 version of ContextSearch.py, it will show "message app is not connected".

i have retyped "python3 install.py".

and please try photoshop on mac or linux:https://linuxhint.com/install_adobe_photoshop_linux

iShot2022-07-17 18 23 11
runningcheese commented 2 years ago

and one more question, how to lanuch yt-dl on linux?

this is what i did.

WechatIMG217

ssborbis commented 2 years ago

I just tried the install.py script. It seems to be working for me. What OS is it failing on? Any error messages?

ssborbis commented 2 years ago

and one more question, how to lanuch yt-dl on linux?

I'm not familiar with deepin-terminal. The -- command is probably gnome-terminal specific. Check the help output and see what it says about launching a new terminal.

ssborbis commented 2 years ago

I just tried the install.py script. It seems to be working for me. What OS is it failing on? Any error messages?

You might also double-check that ContextSearch.py has permission to execute. ( chmod +x ).

logusergithub commented 2 years ago

Thanks for the new parameter. I tried 1.40b5.xpi\2.17 with {download_url} and it seems to works fine with standard image\document links (on Windows: XnView, MSPaint, PS, SumatraPDF). It's just gets better and better.

7peanuts commented 2 years ago

Replace the param {searchTerms} with {download_url} in app launcher templates to direct the native app to download the file found at the URL you've presumably searched for through CS.

For example, to download a file by URL and open in GIMP in linux, I'm using this template

gimp -a "{download_url}"

Thanks, I haven't tried Ps since the update, now I can open it. 😍

"Photoshop.exe" - a "{download_url}"

@ssborbis For me, some image downloads require a proxy, so how do I get Messenger app to use a proxy to download?

ssborbis commented 2 years ago

For me, some image downloads require a proxy, so how do I get Messenger app to use a proxy to download?

Uh, I'm not sure. How does the proxy manage requests? If it's by tacking an url to the end of another url ( http://myproxyexample.com/url=http%3A%2F%2Furl.to%2Fimage.jpg ) or something similar, you can use the Modify Terms Regex field. If it's something more complicated, you might need to modify ContextSearch.py