Exemple #1
0
def main():
    query = Tools.getArgv(1)
    wf = Items()
    if is_blueutil():
        for ap_name, status in paired_airpods().items():
            adr: str = status.get('address')
            ap_type: str = status.get('prod_label')
            is_connected: bool = status.get('connected')
            con_str: str = "connected, Press \u23CE to disconnect..." if is_connected else "NOT connected, \u23CE to connect..."
            ico: str = f"{ap_type}.png" if is_connected else f"{ap_type}_case.png"
            con_switch: str = "connected" if is_connected else "disconnected"
            if query == "" or query.lower() in ap_name.lower():
                wf.setItem(title=ap_name,
                           subtitle=f"{ap_name} are {con_str}",
                           arg=f"{adr};{con_switch}",
                           uid=adr)
                wf.setIcon(ico, "image")
                wf.addItem()
    else:
        wf.setItem(
            title="BLUEUTIL required!",
            subtitle='Please install with "brew install blueutil" first',
            valid=False)
        wf.addItem()
    wf.write()
def main():
    wf = Items()

    search_term = Tools.getArgv(1)
    locked_history_dbs = history_paths()
    results = list()
    if search_term is not None:
        results = get_histories(locked_history_dbs, search_term)
    else:
        sys.exit(0)
    if len(results) > 0:
        for i in results:
            url = i[0]
            title = i[1]
            visits = i[2]
            wf.setItem(title=title,
                       subtitle=f"(Visits: {visits}) {url}",
                       arg=url,
                       quicklookurl=url)
            wf.addItem()
    if wf.getItemsLengths() == 0:
        wf.setItem(
            title="Nothing found in History!",
            subtitle=f'Search "{search_term}" in Google?',
            arg=f"https://www.google.com/search?q={search_term}",
        )
        wf.addItem()
    wf.write()
#!/usr/bin/python3

import os

from Alfred3 import Items, Tools

# Script Filter icon [Title,Subtitle,arg/uid/icon]
wf_items = [
    ['Open Workflow', 'Open Workflow in Alfred Preferences', 'open'],
    ['Path to Clipboard', 'Copy Workflow path to Clipoard', 'clipboard'],
    ['Open in Terminal', 'Open Workflow path in Terminal', 'terminal'],
    ['Finder', 'Reveal in Finder', 'finder'],
]

# Add file manager defined in Alfred wf env
file_manager_path = Tools.getEnv('file_manager')
if file_manager_path and os.path.isfile(file_manager_path):
    app_name = os.path.splitext(os.path.basename(file_manager_path))[0]
    wf_items.append([app_name, f"Reveal in {app_name}", "file_manager"])

wf = Items()
for w in wf_items:
    wf.setItem(title=w[0], subtitle=w[1], arg=w[2])
    icon_path = f'icons/{w[2]}.png'
    wf.setIcon(icon_path, m_type='image')
    wf.addItem()

wf.write()
Exemple #4
0
if matches:
    for m in matches:
        note_title = m.get('title')
        note_path = m.get('path')
        links = m.get('links')
        for l in links:
            url_title = l.get('url_title')
            url = l.get('url')
            subtitle = f'NOTE: {note_title} URL: {url[:30]}...'
            alf.setItem(title=url_title,
                        subtitle=subtitle,
                        arg=url,
                        quicklookurl=url)
            alf.addMod('cmd',
                       note_path,
                       'Open MD Note',
                       icon_path='icons/markdown.png',
                       icon_type='image')
            alf.addMod('alt',
                       url,
                       "Copy URL to Clipboard",
                       icon_path='icons/clipboard.png',
                       icon_type='image')
            alf.addItem()
else:
    alf.setItem(title='No Bookmarks found...',
                subtitle='try again',
                valid=False)
    alf.addItem()
alf.write()