Exemplo n.º 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()
Exemplo n.º 2
0
#!/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()
Exemplo n.º 3
0
    tag_results = md.tagSearch(query, 'tag', reverse=False)
else:
    # Tag Search and sort based on number of Hits
    tag_results = md.tagSearch(query, 'count', reverse=True)

wf = Items()

if bool(tag_results):
    for tag, counter in tag_results.items():
        wf.setItem(
            title=f'{tag}',
            subtitle=f"{counter} Hit(s), ({K.CMD} to paste tag into frontmost app)",
            valid=True,
            arg=f'#{tag}'
        )
        wf.setIcon('icons/hashtag.png', 'image')
        wf.addMod(
            key='cmd',
            arg=f'#{tag} ',
            subtitle='Paste Tag into frontmost app',
            icon_path='icons/paste.png',
            icon_type='image'
        )
        wf.addItem()
else:
    wf.setItem(
        title="No Tags found!",
        subtitle="No Tags matches search term",
        valid=False
    )
    wf.addItem()
Exemplo n.º 4
0
        "icon": "icons/marked.png",
        "visible": True
    },
    {
        "title": "Url Scheme",
        "subtitle": "Copy Url Scheme as Markdown Link to Clipboard",
        "arg": f"urlscheme|{note_path}",
        "icon": "icons/scheme.png",
        "visible": Tools.getEnv("url_scheme")
    },
    {
        "title": "Delete Note",
        "subtitle": f'Delete "{note_title}". This action cannot be undone!',
        "arg": f"delete|{note_path}>{query}",
        "icon": "icons/delete.png",
        "visible": True
    },
]

# Generate ScriptFilter Output
wf = Items()
for a in ACTIONS:
    val = a.get('visible')
    if val:
        wf.setItem(title=a.get("title"),
                   subtitle=a.get("subtitle"),
                   arg=a.get("arg"))
        wf.setIcon(m_path=a.get("icon"), m_type="image")
        wf.addItem()
wf.write()
Exemplo n.º 5
0
connected_vpn = get_vpn(status=VPN.CONNECTED)
disconnected_vpn = get_vpn(status=VPN.DISCONNECTED)

vpn = list()
vpn = add_to_vpnlist(connected_vpn, vpn, VPN.CONNECTED)
vpn = add_to_vpnlist(disconnected_vpn, vpn, VPN.DISCONNECTED)

if len(vpn) > 0:
    vpn = arrange(vpn, VPN.CONNECTED)
    for v in vpn:
        if query.lower() in v[0].lower() or query == "":
            arg = f"connect" if v[1] == VPN.DISCONNECTED else f"disconnect"
            wf.setItem(title=f"{v[0]}",
                       subtitle=f"{v[1].upper()}, Press \u23CE to {arg}",
                       arg=f"{arg};{v[0]}")
            wf.setIcon(m_path=f"{v[1]}.png", m_type="image)")
            wf.addItem()
else:
    wf.setItem(
        title="No VPN configuration found",
        subtitle=
        "Please configure VPN connection in System Preferences → Network",
        valid=False)
    wf.addItem()

if wf.getItemsLengths == 0:
    wf.setItem(title=f'No VPN connection matches "{query}"',
               subtitle="Try again",
               valid=False)
    wf.addItem()
wf.write()
Exemplo n.º 6
0
        # use default icon in alf WF directory in case searched wf has not icon defined
        icon_path = ip if os.path.isfile(ip) else 'icon.png'
        keyword_text = kf.get_keywords_scriptfilter()
        valid = kf.has_keywords()
        subtitle = description + \
            u', Keywords: ' + \
            keyword_text if valid else description
        if len(kf.get_keyboard_shortcuts()) > 0:
            subtitle += ", Keyboard: " + ",".join(kf.get_keyboard_shortcuts())
        arg = os.path.dirname(info_plist_path) + "|" + name
        alf.setItem(title=name,
                    subtitle=subtitle,
                    arg=arg,
                    automcomplete=name,
                    valid=valid,
                    quicklookurl=quicklook_url)
        alf.setIcon(icon_path, m_type="image")
        alf.addMod('cmd',
                   subtitle='Choose Action...',
                   arg=arg,
                   icon_path='icons/start.png',
                   icon_type='image',
                   valid=True)
        alf.addItem()
else:
    alf.setItem(title='No Workflow matches the search query!',
                subtitle=f"...for query: \"{query}\"",
                valid=False)
    alf.addItem()
alf.write()
Exemplo n.º 7
0
wf = Items()

# exec search if search terms were entered
if len(search_terms) > 0:
    sorted_file_list = md_search.notes_search(search_terms, search_type)
    matches = len(sorted_file_list)
    file_pathes = [f['path'] for f in sorted_file_list]
    arg_string = "|".join(file_pathes)
    summary_file = write_summary(sorted_file_list, query)
    if matches > 0:
        wf.setItem(
            title=f"Batch delete {matches} notes with tag {query}",
            subtitle=
            f"{K.ENTER} to delete ALL notes and corresponding Assets. THIS CANNOT BE UNDONE!",
            arg=arg_string)
        wf.setIcon(m_path='icons/delete.png', m_type='image')
        wf.addItem()
        wf.setItem(
            title="Preview affected MD Notes",
            subtitle=
            f"Preview of affected md notes. {K.SHIFT} for Quicklook, {K.ENTER} to open. NOTES ARE NOT DELETED!",
            type='file',
            arg=summary_file)
        wf.setIcon(m_path='icons/clipboard.png', m_type='image')
        wf.addItem()
    else:
        wf.setItem(title=f"MD notes not found with tag: {query}",
                   subtitle="Try another tag name",
                   valid=False)
        wf.addItem()
else:
Exemplo n.º 8
0
todos = md_search.todoSearch(query)

wf = Items()
if len(todos) > 0:
    for i in todos:
        md_path = pathname2url(i['path'])
        md_title = i['title'] if i['title'] != str() else Tools.chop(i['filename'], ext)
        wf.setItem(
            title=i['todo'],
            subtitle=f"{K.ARROW_RIGHT} {md_title} (Created: {Tools.getDateStr(i['ctime'])}, Modified: {Tools.getDateStr(i['mtime'])})",
            arg=i['path'],
            valid=True,
            type='file'
        )
        wf.setIcon('icons/unchecked.png', 'image')
        # Mod for CMD - new action menu
        wf.addMod(
            key="cmd",
            arg=f"{i['path']}>{query}",
            subtitle="Actions..",
            icon_path="icons/action.png",
            icon_type="image"
        )
        wf.addItem()
else:
    wf.setItem(
        title="No todo found!",
        subtitle="No todo matches search term",
        valid=False
    )