Coder Social home page Coder Social logo

Support for empty keyword about flashlight HOT 5 OPEN

shrx avatar shrx commented on June 4, 2024
Support for empty keyword

from flashlight.

Comments (5)

nate-parrott avatar nate-parrott commented on June 4, 2024

does this mean you want to always search google, no matter what's typed into Spotlight?

from flashlight.

shrx avatar shrx commented on June 4, 2024

Yes, along with other results (Definition, Documents, Folders, ...) I'd like to have a google result (or some other search engine) as well.

from flashlight.

danjessen avatar danjessen commented on June 4, 2024

In Alfred, unmatched keywords default to google. It doesn't work the same way in Spotlight, where Spotlight always defaults to some kind of result.

screen shot 2014-12-04 at 09 44 47

from flashlight.

nate-parrott avatar nate-parrott commented on June 4, 2024

I think this can be done by adding !always_invoke to the google plugin's examples.txt, and returning dont_force_top_hit in the results json. terminal is the only plugin I can think of that does this.

from flashlight.

jaxbot avatar jaxbot commented on June 4, 2024

This seems to work:

import urllib
import json
import i18n


def results(parsed, original_query):
    parsed = parsed["~googlequery"] if parsed else original_query

    url = "https://www.google.com/search?q="
    localizedurl = i18n.localstr(url)
    search_url = localizedurl + urllib.quote_plus(parsed.encode('UTF-8'))
    title = i18n.localstr(
        "Search {0} for '{1}'").format("Google", parsed.encode('UTF-8'))
    return {
        "title": title,
        "run_args": [search_url],
        "html": """
        <script>
        setTimeout(function() {
            window.location = %s
        }, 500);
        </script>
        """ % (json.dumps(search_url)),
        "dont_force_top_hit": True,
        "webview_user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53",
        "webview_links_open_in_browser": True
    }


def run(url):
    import os
    os.system('open "{0}"'.format(url))

But whether or not that should be default is questionable.

from flashlight.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.