I would like org-capture to populate properties from data I'm grabbing from shell.
That data, two strings for now (for two properties), is in turn captured from text fields on a webpage in a browser.
1. Open Firefox, go to the webpage with "ticket number" and "userid"
2. Run script, captures "ticket" & "userid" > strings
3. pass strings into org-capture as properties.
I'm sure someone figured this out somewhere, maybe Lisp, maybe bash, maybe there's an extension somewhere...
@jrss If you've got the script you want for (2) already, and you can make it output in a format you like, you can create a capture template with a Lisp expansion like %(shell-command-to-string "…"). Though using an external script to capture from a Firefox session feels weird to me.
If you don't have what you want for (2) yet, then I'm not sure what the most ergonomic way is to get there, but shoving data through the clipboard and munging it before/after might be more convenient.
@dasyatidprime I don't have a script yet. Can you please expand more on 2?
@jrss (Sorry, I don't always check here very often! :-) )
Extracting stuff from a running Firefox tab via a shell is going to have targeting and introspection issues. When you said shell, I thought that meant you had a script already, but if you don't have one, why not use either the bare clipboard or some sort of user scripting to capture the text from within Firefox, then use elisp to put it into its final form?
@jrss Specifically, if there's a section of the page that has the information you want, you could just grab the section into the clipboard manually (with loose targeting—that is, you don't have to be too careful about your selection bounds), then have elisp expansions in the capture template grab what's in the clipboard and scan it for the information you want. Assuming you're always going to be initiating or finalizing the capture manually, you can just punt edge cases.
@jrss If you're talking about more hidden properties of the page then you might want to see if you can grab the pages with curl or something instead. If you need to get them from inside the Firefox session, I don't know what the most ergonomic way is—maybe “save to temporary directory”, maybe “view source, C-a C-c”? (I'm assuming they're not just in the URL or something, in which case C-l C-c in Firefox would be a good starting gesture.)
@dasyatidprime ok we need to talk more about it (please?) I need to explain better how I get the info. I don't have anything in place right now all I do is mouse click and select text, alt tab back to capture, paste, the click again on the other window... Repeat there time for the three properties I need.
I don't know how to script in elisp. What can you tell me?
@jrss I feel like this conversation is likely to go beyond the amount of energy I originally expected to put in, so I'm probably going to cut it off after this.
But “teach me elisp” is a very open-ended request. Do you have experience in any other Lisps? Programming in general? Have you looked at the elisp Info pages? They're available either from within Emacs (C-h i, m elisp) or on the Web (don't feel like finding the link right now).
@jrss Did I read you correctly in your original post that you were angling toward hacking this up yourself? The way I read it implied that you were already handling the first part of the extraction.
I'm not sure what the state of “learning templates to extract via” is in Firefox extensions, but I'd bet it's not good enough to make you not have to write some data-munging code. And elisp is reasonably good at text processing and has clipboard access. You could still use a subprocess if you wanted.
This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either! We adhere to an adapted version of the TootCat Code of Conduct and have documented a list of blocked instances. Ash is the admin and is supported by Fuzzface, Brian!, and Daniel Glus as moderators. Hosting costs are largely covered by our generous supporters on Patreon – thanks for all the help!