Jump to content

Mr Pennyworth

Member
  • Posts

    175
  • Joined

  • Last visited

  • Days Won

    10

Posts posted by Mr Pennyworth

  1. 2 hours ago, vitor said:

    But I think you’ll like this more: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump URLSchemeBinding. It shows every available URL scheme (on your machine).

    This is amazing!!! 🎉

     

    2 hours ago, vitor said:

    As to how to use them, that’s the job of the developer’s documentation.

    Unfortunately CleanShot X doesn't have any :(

    I had to go digging into the package bundle and had to resort to strings and got lucky at some places

    strings /Applications/CleanShot\ X.app/Contents/PlugIns/AnnotateShareExtension.appex/Contents/MacOS/AnnotateShareExtension | grep cleanshot
    
    # printed: cleanshot://share-extension-annotate?filepath=
    
    strings /Applications/CleanShot\ X.app/Contents/PlugIns/PinShareExtension.appex/Contents/MacOS/PinShareExtension | grep cleanshot
    
    # printed: cleanshot://share-extension-pin?filepath=
    
    

     

  2. 3 hours ago, Chris Messina said:

    Ha! I made a much more basic version of this but never released it... nice job! 

    Thanks @Chris Messina! :)

    Damn, you should've released it!!

     

    I have a couple of questions:

    1. Did you also find out about the cleanshot:// urls from Raycast? If not, please do tell how you went about it, it might come handy for other apps!
    2. Did you extract those icons from CleanShot's assets.car? If not, again, please do tell! (I have zero design chops or any related abilities, so it might come handy to me later on)

     

  3. On 5/27/2021 at 5:57 PM, deanishe said:

    Right. Somehow I managed to completely miss the "context menu" part despite it being in your post and the thread title… Sorry.

    Hey @deanishe I see your "I missed 'context menu'" and I raise you to "I missed the whole paragraph about not wanting to use another app" 🤣

     

    @vitor has a nice and gentle way of asking "have you even read the post fully?"
    Thanks! 😇

  4. 5 hours ago, JakeS said:

    I also have Xcode.  Never worked with Swift myself, but how hard can it be?

    @JakeS

    Seems like you'll have to resort to this.
    If you've been programming for a while, it won't be hard at all! :)
    (would most likely involve setting breakpoints, adding print statements etc (standard ad-hoc debugging))

    I need to learn a thing or two from @deanishe and do at least half as decent a job as he does in extensive, detailed documentation, logging and error reporting! sigh

     

    P.S. can you go through the whole log and search for "error", "Error", "ERROR"?
    Just want to make sure an error isn't buried there somewhere!

  5. 4 hours ago, JakeS said:

    If there's somewhere else I can look for logs or help troubleshoot I'm happy to.  I also have Xcode.  Never worked with Swift myself, but how hard can it be? :)

    Not having the logs sucks :(

     

    You can run the following in the terminal, and then use the workflow. That way, you can see the logs in the terminal in real time.

    killall AlfredGifBrowser; ./AlfredGifBrowser.app/Contents/MacOS/AlfredGifBrowser

     

     

  6. @Cyberskier apologies! The workflow right now doesn't support M1, and I'm not sure how much of a work it would be to support it. :(

     

    Technical details if curious:

    The workflow ships with compiled binaries (an entire nodejs runtime and a swift app).

    As they aren't universal binaries, it won't work on an M1 mac.

    I'm working on getting rid of nodejs right now.

    After that, I'll look into making the swift app universal.

  7. Following is from the JSON spec for script filter output:

    Quote

    "icon": {

        "type": "fileicon",

        "path": "~/Desktop"

    }

    By omitting the "type", Alfred will load the file path itself, for example a png. By using "type": "fileicon", Alfred will get the icon for the specified path. Finally, by using "type": "filetype", you can get the icon of a specific file, for example "path": "public.png"

     

     

    I'm having trouble understanding the difference between "filetype" and "fileicon" in my tests so far, it seems like "filetype" always gives a generic blank file icon (even for folders). Take a look at this screenshot. (Download the corresponding workflow)

    image.thumb.png.134081389b75a1490952736c2cb5803e.png

    In case you don't feel like downloading the workflow, but just want to take a look at the script filter JSON:

    file1="icon.png"
    file2="~/Desktop"
    file3="./"
    
    
    cat << EOF
    {"items":[
     {"title": "$file1",
      "subtitle": "no type",
      "icon": {"path": "$file1"}},
     {"title": "$file1",
      "subtitle": "type: fileicon",
      "icon": {"type": "fileicon", "path": "$file1"}},
     {"title": "$file1",
      "subtitle": "type: filetype",
      "icon": {"type": "filetype", "path": "$file1"}},
     {"title": "$file2",
      "subtitle": "no type",
      "icon": {"path": "$file2"}},
     {"title": "$file2",
      "subtitle": "type: fileicon",
      "icon": {"type": "fileicon", "path": "$file2"}},
     {"title": "$file2",
      "subtitle": "type: filetype",
      "icon": {"type": "filetype", "path": "$file2"}},
     {"title": "$file3",
      "subtitle": "no type",
      "icon": {"path": "$file3"}},
     {"title": "$file3",
      "subtitle": "type: fileicon",
      "icon": {"type": "fileicon", "path": "$file3"}},
     {"title": "$file3",
      "subtitle": "type: filetype",
      "icon": {"type": "filetype", "path": "$file3"}},
    ]}
    EOF

     

  8. 4 hours ago, Cyberskier said:

    and run the setup command (/tmp/alfred-gif-search.log).

    That's not the setup command though.

    After you download and import the workflow into alfred, you need to open alfred and type .setup-gif-search.

     

    Also, can you make sure that you area either using a custom theme for alfred, or, if not, then using a duplicated version of a built-in theme?

     

    Do not use any of these:
    image.thumb.png.2e6bbf333517c8b6133d68b0923b8ba6.png

     

    Here's how you can duplicate:

    Right-click on the theme name:

    image.png.a2c35b8332563632d1cb16485a953bbc.png

  9. 12 minutes ago, deanishe said:

    Wouldn’t public.url be more appropriate?

    Yep! I should change that :)

     

    13 minutes ago, deanishe said:

    Out of interest, why did you write the app in Swift, but the HTTP server in JS?

    Laziness and reluctance to learn swift.


    I have very little understanding of swift. Wrote only those things in swift, which felt like very difficult to write in other languages I know (Scala, Javascript, Python).

     

    Even the bundled python scripts in the swift app could be written in swift.

     

    Every once in while I get the enthusiasm: "lemme get rid of the huge JS dist, and go with a swift program instead"
    And it dies down quickly: "but it works" :(

     

     

  10. 5 minutes ago, deanishe said:

    What do "⌘: copy GIF" and "⌥: copy URL" mean, then?

    Both act on the "highlighted GIF"

    image.png.a2da2b6cdc98da962da6ccb9a0552670.png

    When the user presses cmd-enter, the highlighted GIF file gets copied to the clipboard (pasteboard data type public.file-url). In this case, if the user goes to finder, and hits cmd-v, a GIF file will appear in that folder.


    When the user presses option-enter, the web url of the highlighted GIF gets copied to the clipboard (pasteboard data type public.utf8-plain-text). In this case, if the user goes to any text editor, and hits cmd-v, a link like this will be pasted there: https://c.tenor.com/tVoDE6m_A0QAAAAM/jonah-hill-shriek.gif.

     

    You may ask who does the copying and option/cmd distinguishing etc. Again, the swift app. At this point, it feels like "why not spin out a separate app instead of an alfred workflow?" doesn't it? 🙈

     

    Look at the corresponding swift code:

    image.thumb.png.b5cb71c94057a19e596ee0e05aff5280.png

     

  11. 5 minutes ago, deanishe said:

    I understand the filename changes, but shouldn't there be some search results for Alfred somewhere in there, too? The workflow never shows any results in Alfred, just "Select with arrow keys, drag-n-drop with mouse". I presume that's referring to Alfred's list of results?

    That's where the convoluted-ness of it all comes in.

    Alfred has only one result (the one seen is json).

     

    43 minutes ago, Mr Pennyworth said:

    The swift app displays injects the css into the html, and displays this injected html in a webview

    This same swift app watches for keystrokes and mouse movements and passes them along to the webview. The webview accordingly highlights the corresponding GIF. Similarly, the swift app is responsible for the drag-and-drop functionality.

     

    Alfred never really sees all the GIF urls, or any other result list. He only sees one single html file.

    Here's the same HTML file opened in safari:

    image.thumb.png.b1441d6877e543f4534889c345b2af26.png

     

    In this whole thing, alfred acts as

    1. a text-input box for the query
    2. a platform (the workflow editor) that allows me to stitch multiple hodge-podge scripts to get the final thing working

    image.png.1adf66c2a4e9c1ef53394e15f770a8bf.png

  12. @deanishe
    Haha I'm so embarrassed right now! 🙈

     

    I'm doing things in a very convoluted manner :(

    For each response the `gifHtml` part is different. For example, you searched for "scream", so it created `scream-gifs.html.html` (meaning to delete that double extension too 🤣)

    1. That response is then piped into a python script.
    2. The python script creates css that matches alfred's theme and then sends the html from (1) and this css to the swift app
    3. The swift app displays injects the css into the html, and displays this injected html in a webview

     

    10 minutes ago, deanishe said:

    but it always returns the same response:

    TL;DR: the json is not the same, as the html filename is query-specific

     

    What I presently can't seem to figure out is why the swift app never displays the webview for both you and @Miteg !

  13. @Miteg I was wondering whether the problem could be because of BigSur.

    So I borrowed a BigSur macbook from someone, installed the workflow (0.1.1), and checked.

    I was not able to reproduce the problem :(

    Can you try the following?

    1. killall AlfredGifBrowser in terminal
    2. killall gif-downloader.bin in terminal
    3. Delete the workflow
    4. Delete AlfredGifBrowser from Security & Privacy > Accessibility (not just disable, but remove the entry completely)
    5. Download and install version 0.1.1 (which fixes issues @deanishe mentioned)

    Given that the downloader did download the gifs (as I can see from your logs), it feels like the gif browser is not making itself visible.

     

    Here's a last resort thing to really make sure the accessibility permissions are accurate:

    1. You have already downloaded 0.1.1 above and installed, still the gif browser doesn't show up
    2. killall AlfredGifBrowser in terminal
    3. Delete AlfredGifBrowser from Security & Privacy > Accessibility (not just disable, but remove the entry completely)
    4. Manually add AlfredGifBrowser app to that list again and enable it.
      1. Open the workflow folderimage.png.ae87b37e3c6f142a905f6e583581f311.png
      2. Drag AlfredGifBrowser from that folder into the accessibility permissions list
      3. Enable the checkbox for it
  14. 57 minutes ago, deanishe said:

    Looks like somebody forgot to wrap their handler in try…catch, so a bum request is crashing the whole program instead of getting a 400 or 500 response.

    🙈 Thanks! Fixed!

     

    1 hour ago, deanishe said:

    Also, the workflow keeps failing to save query-history.txt because it doesn't create the data directory it's trying to save it in.

    That error doesn't affect the working of the workflow, but definitely not a good idea to pollute the log with red herrings!
    Thanks again 😇! Fixed!

  15. @Miteg

     

    Thanks for the logs!

    Can you confirm the following?

    - you are on latest Alfred version (4.3 or above)

    - you have downloaded the latest workflow (0.1.0)

    - you are on an intel mac (I haven't tested the workflow on M1 macs)

    - when you run the following two commands in terminal, you get some number

      - `pgrep gif-downloader.bin`

      - `pgrep AlfredGifBrowser`

    - when you visit http://localhost:8910/?query=haha in your browser, you get some JSON output.

     

    Let me know which one of the above fails (if any)

  16. @Miteg

    That's all right, that's the part of the set up. Every time you run ".setup-gif-search", it is going to ask you to grant the permission.

     

    I have a feeling it is already installed correctly. Did you try running it? If it doesn't work, post the debug log here and I can take a look.

     

    P.S.: It is not good design that the setup exits without an indication of success. Also, let me see if I can make it such that if someone runs setup multiple times, it doesn't prompt for permissions if already given.

×
×
  • Create New...