-
Posts
175 -
Joined
-
Last visited
-
Days Won
10
Content Type
Blogs
Gallery
Downloads
Events
Profiles
Forums
Articles
Media Demo
Posts posted by Mr Pennyworth
-
-
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:
- 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!
- 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)
-
CleanShot X Workflow: Download
Requiremens
- Alfred 4
- CleanShot X (version 3.5.1 or above)
Screenshots
CreditsThis workflow is based on, and a slight improvement of, Raycast’s CleanShot X script commands.
Icon Credits
-
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! 😇 -
EDIT: the post below is a result of not reading the original post properly where the author clearly mentions they have seen BTT and don't want to use it.
Take a look at BetterTouchTool.
Here's forum thread discussing the same feature.
Looks like exactly the thing you want:
-
5 hours ago, JakeS said:
I also have Xcode. Never worked with Swift myself, but how hard can it be?
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! sighP.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! -
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
-
@Cyberskier @JakeS could you try the latest release and see if works on M1 macs?
(I don't have access to an M1 mac)
Technical details:
The workflow no longer depends on nodejs
-
@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.
-
-
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)
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
-
-
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?
Here's how you can duplicate:
Right-click on the theme name:
-
10 minutes ago, deanishe said:
Sure, but the HTTP server could have been written in Python, too. Maybe it's just me. I'd never use JS when there's another option. It's such a silly language.
True! Agreed!
-
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" -
5 minutes ago, deanishe said:
What do "⌘: copy GIF" and "⌥: copy URL" mean, then?
Both act on the "highlighted GIF"
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:
-
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:
In this whole thing, alfred acts as
- a text-input box for the query
- a platform (the workflow editor) that allows me to stitch multiple hodge-podge scripts to get the final thing working
-
@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 🤣)
- That response is then piped into a python script.
- The python script creates css that matches alfred's theme and then sends the html from (1) and this css to the swift app
- 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 !
-
@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?- killall AlfredGifBrowser in terminal
- killall gif-downloader.bin in terminal
- Delete the workflow
- Delete AlfredGifBrowser from Security & Privacy > Accessibility (not just disable, but remove the entry completely)
- 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:
- You have already downloaded 0.1.1 above and installed, still the gif browser doesn't show up
- killall AlfredGifBrowser in terminal
- Delete AlfredGifBrowser from Security & Privacy > Accessibility (not just disable, but remove the entry completely)
-
Manually add AlfredGifBrowser app to that list again and enable it.
- Open the workflow folder
- Drag AlfredGifBrowser from that folder into the accessibility permissions list
- Enable the checkbox for it
-
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! -
Seems like the gif-downloader.bin keeps crashing.
I wonder what is causing the crash.
Can you post the contents of /tmp/alfred-gif-search.log?
-
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)
-
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.
-
In the meanwhile, if you insist on CSV instead of excel sheets, here's a workflow for you: https://github.com/mr-pennyworth/alfred-lf2csv
Example setup:
1) set hotkey to cmd+option+c
2) in the workflow editor, select the list filter you want to export as csv
3) press the hotkey (cmd+option+c), alfred should have a CSV file ready to be dragged-and-dropped
- Chris Messina and giovanni
- 1
- 1
-
If like me, you don't care about what emacs does with ⌘-v by default, you can add the following to your ~/.emacs
;; Make macOS paste work with ⌘-v (global-set-key (kbd "M-v") 'clipboard-yank)
CleanShot X Workflow
in Share your Workflows
Posted
This is amazing!!! 🎉
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