Jump to content

deanishe

Member
  • Posts

    8,759
  • Joined

  • Last visited

  • Days Won

    522

Reputation Activity

  1. Like
    deanishe got a reaction from fonginator in Alfred won't show in Monterey after using Secure Entry field [Fixed in 4.6.4 b1291 pre-release]   
    Does anyone even know what this "CPS" is?
     
    I've found some similar reports for other apps, but no solutions
     
    The other affected applications also seem to use non-focusing windows.
     
    Has anyone tried setting Alfred's Focusing to "Compatibility Mode" in Alfred Preferences > Appearance > Options?
  2. Like
    deanishe got a reaction from Chris Messina in Workflow Folders   
    Then create a category called "Pinned" and put the workflows in it.
     
    The whole "the Alfred team has very limited resources for implementing new features" message isn't really getting through to you, is it?
  3. Like
    deanishe got a reaction from nadnosliw in Fallback file search isn't as successful as I'd expect   
    Hi @Norman Gray, welcome to the forum.
     
     
    How are you trying to find the file in this case? The open and find searches only search by file name. You need to use in to search file content.
     
     
    As a rule, you can use ^↩ on any result in Alfred to search for the current query in Spotlight.
  4. Like
    deanishe reacted to Vero in All files not showing up in searches after switching to m1 MacBook Air   
    @Sam Tang Welcome to the forum. What @deanishe is saying in his very succinct response is that this has been answered many times in recent months and that the best first step when looking for answers is to use the search feature.
     
    Having said that, we've now created a step-by-step guide to troubleshooting this issue, which seems to be caused by a bug in the macOS Monterey Migration Assistant, resulting in files not being found when they should be. 
     
    Please take a look at this guide and follow the instructions carefully:
    https://www.alfredapp.com/help/troubleshooting/indexing/monterey/
     
    I'm confident this will solve your issue, but if for any reason, you still have indexing issues, please follow up in the relevant thread linked below. I'll now lock this thread to avoid splitting up the discussion of the same topic any further.
     
    Cheers,
    Vero
     
  5. Like
    deanishe got a reaction from sin in Google Drive   
    https://console.developers.google.com/apis/dashboard
     
     
    https://github.com/azai91/alfred-drive-workflow/blob/master/src/google-drive.rb#L35
  6. Like
    deanishe got a reaction from vitor in Workflow Folders   
    Ah, right, I wasn't aware of that. Sorry, @Undertaker01.
  7. Like
    deanishe got a reaction from andy4222 in Text losing its formatting [when using universal actions]   
    They filter their own results.
     
    If you don't have "Alfred filters results" checked, Alfred passes the search query to the workflow script, and it should only return matching results.
     
     
    Then you'll have to implement it yourself, or use a shim script.
  8. Like
    deanishe got a reaction from Eseila in Is there a way to restrict the "in" command to search only in some specific folders?   
    See here: https://www.alfredapp.com/help/workflows/inputs/file-filter/
     
    Also, check out the example workflows built into Alfred.
  9. Like
    deanishe got a reaction from zlc1952 in Workflow to open a website, crawl a value by xpath and return it as a result in Alfred   
    Here's a workflow that scrapes results from a webpage and shows them in Alfred.
     
    Here's a tutorial on writing Script Filters (i.e. showing your own results in Alfred) and here's a tutorial on web scraping with Beautiful Soup. Beautiful Soup doesn't support XPath, but it does support regexes and a subset of CSS selectors.
     
    You can use XPath selectors with lxml, but that can be a bit of a pain to install on OS X.
  10. Like
    deanishe reacted to mlondon in How to modify default Google search?   
    Got it. Thank you.
     
    For those who may be interested, the correct URL to search Google with No Country Redirect is:
     
    https://www.google.com/search?q={query}&pws=0&gl=us&gws_rd=cr&gl=us&hl=en&pws=0
     
    Even if one is using a VPN, Google will make a best-guess of your location and automatically redirect search results to that country.
    Using the above URL will force Google to make your search default to "no location" which will give you results as if you were in the US.
     
  11. Sad
    deanishe got a reaction from zlc1952 in [Request] Google Tasks (add, list, complete, etc)   
    No, it's perfectly possible. Google just keep making it more and more difficult to do.
     
    At this points, it's so much hassle to get a workflow connected to Google in the first place, it's no wonder hardly anybody writes them.
  12. Thanks
    deanishe got a reaction from codedeeply in Workflow: Units - convert currency length temperature weight and more   
    In bash:
    curl -sfL -F v=3.6 -F "q=$1" http://units.dnsu.ch/units/server/alfred if [ $? -ne 0 ]; then echo '{"items": [{"title": "Units is unavailable", "subtitle": "sorry..", "icon": {"path": "Icons/error.png"}}]}' fi  
  13. Like
    deanishe got a reaction from Kelson01 in How can I copy a file to my clipboard with passed in finder path?   
    You need to put a file:/// URL on the clipboard with data type public.file-url. Here is a script (Language = "/usr/bin/osascript (JavaScript)") that will put the first file passed in on the clipboard:
     
    ObjC.import('AppKit'); function run(argv) { const pboard = $.NSPasteboard.generalPasteboard; // convert first command-line argument to file:/// URL let url = $.NSURL.fileURLWithPath(argv[0]); // put URL on clipboard as "public.file-url" pboard.clearContents; if (!pboard.setStringForType(url.absoluteString, $.NSPasteboardTypeFileURL)) { throw new Error('failed to put URL on pasteboard'); } }  
     
    Could you stop posting screenshots of Alfred and your workflows all the time? It's pointless.
  14. Like
    deanishe got a reaction from giovanni in Creating nested navigation trees with List Filters   
    Most languages are pretty similar at the end of the day. bash/zsh and especially AppleScript are weird, but the others are all general-purpose languages and tend to work quite similarly to each other.
     
    Python is considered an excellent first language. You can write almost anything in it, and it's extremely popular with non-programmers (scientists, engineers), so there are a lot of docs and tutorials for beginners. Ruby is very similar to Python. Those would be the best two choices, imo. bash/zsh and JavaScript are kinda unavoidable because of their special roles.
     
    I'd generally recommend against learning JS first. It's super important to know, but the language and community are both a bit out there. JS also doesn't have a standard library, which is what gives a language most of its capabilities.
  15. Like
    deanishe got a reaction from realliyifei in Overlapped hotkey for different apps in one workflow?   
    You enter the variable name in the box, not the value. The default is "focusedapp"
     
    You can get the variable in AppleScript with set _appname to (system attribute "focusedapp")
     
  16. Like
    deanishe got a reaction from bourben in openthesaurus.de - v2/3 Workflow   
    You have a version of macOS that no longer includes PHP. You need to install it with Homebrew. 

    https://www.alfredapp.com/blog/releases/alfred-4-6-ready-for-macos-monterey/
     
  17. Like
    deanishe got a reaction from bourben in openthesaurus.de - v2/3 Workflow   
    Possibly. What does the debugger say?
  18. Like
    deanishe got a reaction from a41456 in How can I "expand" a keyword into a Script Filter?   
    Like Vítor says, "expanding" is the territory of snippets. Just be sure to remove Alfred from the excluded apps list (Alfred doesn't expand snippets in Alfred by default).
     
    Your other option is to create a duplicate Script Filter and edit it so that the script receives your extra text in addition to your input, e.g. you change the script from some-script "$1" (which receives just your input) to some-script "#media/youtube $1" (which appends your input to #media/youtube).
     
  19. Like
    deanishe got a reaction from Kelson01 in Alfred Not Correctly Inputting Numpad Key Combo in keystroke action   
    I'd ask the Moom developers, tbh. I mean, they wrote both Moom and Key Codes, so they're the best people to explain why they appear to be seeing different keypress events.
     
    Happy New Year to you, too!
  20. Like
    deanishe got a reaction from jmantn in ESV Online Bible   
    I noticed an encoding error in my script when I entered "job" as the query (probably something to do with "smart" quotes).
     
    If you don't mind, I "Pythonified" the script and implemented the caching I mentioned. The script below catches and displays API errors (apparently the API returns a detail field if something went wrong), handles non-ASCII text, and caches the results for queries for 40 days (by default), which takes the response time from ~0.8 seconds to ~0.02 seconds for responses that are in the cache.

    Hitting ⌘L on the result will show the passage in Alfred's Large Type window, and ⌘C will copy the same to the clipboard.
     
    So if you'd like to, try this:
    # encoding: utf-8 """Alfred Script Filter to search the ESV Bible.""" from __future__ import print_function from hashlib import md5 import json import os import re import subprocess import sys from time import time from urllib import urlencode API_KEY = '<redacted>' API_URL = 'https://api.esv.org/v3/passage/text/' API_OPTIONS = { 'include-passage-references': 'false', 'include-first-verse-numbers': 'false', 'include-verse-numbers': 'false', 'include-footnotes': 'false', 'include-footnote-body': 'false', 'include-short-copyright': 'false', 'include-passage-horizontal-lines': 'false', 'include-heading-horizontal-lines': 'false', 'include-headings': 'false', 'include-selahs': 'false', 'indent-paragraphs': '0', 'indent-poetry': 'false', 'indent-poetry-lines': '0', 'indent-declares': '0', 'indent-psalm-doxology': '0' } # HTTP request headers API_HEADERS = { 'Accept': 'application/json', 'Authorization': 'Token ' + API_KEY, } # Directory for this workflow's cache data CACHEDIR = os.getenv('alfred_workflow_cache') CACHE_MAXAGE = 86400 * 40 # 40 days def log(s, *args): """Write message to Alfred's debugger. Args: s (basestring): Simple string or sprintf-style format. *args: Arguments to format string. """ if args: s = s % args print(s, file=sys.stderr) class ESVError(Exception): """Base error class.""" class NotFound(ESVError): """Raised if no passage was found.""" def __str__(self): """Error message.""" return 'No passage found' class APIError(ESVError): """Raised if API call fails.""" class Cache(object): """Cache results of API queries. Attributes: dirpath (str): Path to cache directory. """ def __init__(self, dirpath): """Create a new cache. Args: dirpath (str): Directory to store cache files. """ log('cache directory=%s', dirpath) self.dirpath = dirpath if dirpath is None: # not being run from Alfred return # Alfred doesn't create the directory for you... if not os.path.exists(dirpath): os.makedirs(dirpath) else: # remove old cache files self.clean() def search(self, query): """Perform API query, using cached results if not expired. Args: query (unicode): Search string. Returns: Passage: Passage from API or cache. """ cachepath = None if self.dirpath: cachepath = os.path.join( self.dirpath, md5(query.encode('utf-8')).hexdigest() + '.json' ) # ------------------------------------------------------ # Try to load data from cache if cachepath and os.path.exists(cachepath): # Expired cache files were deleted when `Cache` was created log('[cache] loading passage for "%s" from cache ...', query) with open(cachepath) as fp: data = json.load(fp) return Passage.from_response(data) # ------------------------------------------------------ # Fetch data from API # Combine query and options into GET parameters params = dict(q=query.encode('utf-8')) params.update(API_OPTIONS) # Execute request data = fetch_url(API_URL, params, API_HEADERS) passage = Passage.from_response(data) if cachepath: # Cache response with open(cachepath, 'wb') as fp: json.dump(data, fp) return passage def clean(self): """Remove expired cache files.""" i = 0 for fn in os.listdir(self.dirpath): p = os.path.join(self.dirpath, fn) if time() - os.stat(p).st_mtime > CACHE_MAXAGE: os.unlink(p) i += 1 if i: log('[cache] deleted %d stale cache file(s)', i) class Passage(object): """A Bible passage. Attributes: fulltext (unicode): Passage text as paragraphs ref (unicode): Canonical passage reference summary (unicode): Passage text on one line with_ref (unicode): Passage as paragraphs + reference """ @classmethod def from_response(cls, data): """Create a `Passage` from API response. Args: data (dict): Decoded JSON API response. Returns: Passage: Passage parsed from API response. Raises: NotFound: Raised if ``data`` contains no passage(s). """ if not data.get('canonical') or not data.get('passages'): raise NotFound() ref = data['canonical'] s = data['passages'][0] summary = re.sub(r'\s+', ' ', s).strip() p = cls(ref, summary, s) log('---------- passage -----------') log('%s', p) log('---------- /passage ----------') return p def __init__(self, ref=u'', summary=u'', fulltext=u''): """Create new `Passage`.""" self.ref = ref self.summary = summary self.fulltext = fulltext self.with_ref = u'{}\n\n({} ESV)'.format(fulltext.rstrip(), ref) def __str__(self): """Passage as formatted bytestring. Returns: str: Full text of passage with reference. """ return self.__unicode__().encode('utf-8') def __unicode__(self): """Passage as formatted Unicode string. Returns: unicode: Full text of passage with reference. """ return self.with_ref @property def item(self): """Alfred item `dict`. Returns: dict: Alfred item for JSON serialisation. """ return { 'title': self.ref, 'subtitle': self.summary, 'autocomplete': self.ref, 'arg': self.with_ref, 'valid': True, 'text': { 'largetype': self.with_ref, 'copytext': self.with_ref, }, } def fetch_url(url, params, headers): """Fetch a URL using cURL and parse response as JSON. Args: url (str): Base URL without GET parameters. params (dict): GET parameters. headers (dict): HTTP headers. Returns: object: Deserialised HTTP JSON response. Raises: APIError: Raised if API returns an error. """ # Encode GET parameters and add to URL qs = urlencode(params) url = url + '?' + qs # Build cURL command cmd = ['/usr/bin/curl', '-sSL', url] for k, v in headers.items(): cmd.extend(['-H', '{}: {}'.format(k, v)]) # Run command and parse response output = subprocess.check_output(cmd) log('---------- response -----------') log('%r', output) log('---------- /response ----------') data = json.loads(output) if 'detail' in data: # 'detail' contains any API error message raise APIError(data['detail']) return data def exit_with_error(title, err, tb=False): """Show an error message in Alfred and exit script. Args: title (unicode): Title of Alfred item. err (Exception): Error whose message to show as item subtitle. tb (bool, optional): If `True`, show a full traceback in Alfred's debugger. """ # Log to debugger if tb: import traceback log(traceback.format_exc()) else: log('ERROR: %s', err) # Send error message to Alfred output = { 'items': [{'title': title, 'subtitle': str(err)}] } json.dump(output, sys.stdout) sys.exit(1) # 1 indicates something went wrong def main(): """Run Script Filter.""" log('.') # Ensure real log starts on a new line # Fetch user query and decode to Unicode query = sys.argv[1].decode('utf-8') cache = Cache(CACHEDIR) try: passage = cache.search(query) except ESVError as err: exit_with_error(query, err, False) except Exception as err: exit_with_error(query, err, True) # Show passage in Alfred json.dump({'items': [passage.item]}, sys.stdout) if __name__ == '__main__': start = time() main() log('------ %0.3fs ------', time() - start)  
  21. Thanks
    deanishe got a reaction from Chris Messina in Creating nested navigation trees with List Filters   
    That’s what Script Filters are for. If you want to use a static JSON file, just use cat file.json as the Script.
     
     
    Seems likely. Perhaps a bug?
     
     
    Instead of having a "Clears value of {query} …" Arg & Vars on every branch out of the Conditional, you could put just one before it to clear arg and set a variable from {query}, then switch on the variable in the Conditional.
     
    More generally, moving more of the workflow into scripts. It's significantly easier to manage complexity in code. You could replace the Conditional and its List Filters with a single script. That really pays dividends when you decide you want to change something.
  22. Like
    deanishe reacted to Toontje in Keyword workflow to open several SSH sessions panes in iTerm   
    set hostnames to {"pi@host1.local", "pi@host2.local", "pi@host3.local", "pi@host4.local", "pi@host5.local", "-p 12345 gregorio@host12"}
    if application "iTerm" is running then
            tell application "iTerm"
                    create window with default profile
                    tell current tab of current window
                            select
                            tell current session
                                    -- make the window fullscreen
                                    tell application "System Events" to key code 36 using command down
                                    split horizontally with default profile
                                    set num_hosts to count of hostnames
                                    repeat with n from 1 to num_hosts
                                            if n - 1 is (round (num_hosts / 2)) then
                                                    -- move to lower split
                                                    tell application "System Events" to keystroke "]" using command down
                                            else if n > 1 then
                                                    -- split vertically
                                                    tell application "System Events" to keystroke "d" using command down
                                            end if
                                            delay 1
                                            write text "ssh " & (item n of hostnames)
                                    end repeat
                            end tell
                    end tell
            end tell
    else
            activate application "iTerm"
    end if
  23. Like
    deanishe got a reaction from Kelson01 in Is there a workflow that lets you search DuckDuckGo with relevant results?   
    This, probably. It's not just fetching your browser history, but combining the results with those from the search engine, and then figuring out how to make that work well with Alfred's own sorting.
     
    It's absolutely doable (depending on your browser), but so far nobody has cared enough to build it (well, release it).
     
     
    Every single time. I quit Alfred, then try to open Alfred in order to run Alfred. Then I panic for a bit while I try to remember how else to launch apps. Eventually, I remember I can double-click in Finder or run them from a shell, then I immediately try to open Alfred in order to launch Finder or iTerm, so I can launch Alfred…
     
  24. Like
    deanishe got a reaction from Kelson01 in Can I drag a script edit file into the script edit workflow object for it to paste the script?   
    Use External Script, so you can edit the script without opening Alfred Preferences.
  25. Like
    deanishe got a reaction from godbout in Is Alfred ready for 1Password 8?   
    For making their own lives easier, not for making a better application.
     
    They could have used Qt. They could have used each platform's native webstack. Instead they went with everyone's least favourite bloatware, Electron.
     
    Any developer who picks Electron is doing it for their own benefit, not their users’.
×
×
  • Create New...