Example #1
0
    wf.setItem(
        title="3rd Party Integration in 1Password is disabled!",
        subtitle=
        u'1Password > Preferences > Advanced > Integratons > [x] Enable Spotlight and 3rd party app integrations',
        valid=False)
    wf.addItem()
    passwords = list()

for p in passwords:
    # Add Password item if no vaultNames are defined OR item's vault name in valutName config
    # AND
    # query empty OR query match item title
    if ((vaults[0] == str() or p.get('vaultName') in vaults) and
        (query == str() or query.lower() in p.get('itemTitle').lower())):
        uuid = p.get('uuid')
        itemTitle = p.get('itemTitle')
        itemDesc = p.get('itemDescription')

        url = p.get('websiteURLs')[0] if p.get('websiteURLs') else str()

        wf.setItem(title=itemTitle,
                   subtitle=itemDesc,
                   arg=uuid,
                   quicklookurl=url)
        if url:
            wf.setIcon('purl.png', "image")
            wf.addMod(key="cmd", subtitle='OPEN: {0}'.format(url), arg=url)
            wf.addModsToItem()
        wf.addItem()
wf.write()
Example #2
0
)
items.addMod(
    arg=u"{0}||paste".format(query),
    icon_path="icons/new_from_clipboard.png",
    icon_type="image",
    key="alt",
    subtitle=u"\"{0}\" ({1})".format(query, zettel_action),
)
items.addMod(
    arg=u"{0}||paste".format(query_alt),
    icon_path="icons/new_from_clipboard.png",
    icon_type="image",
    key="cmd+alt",
    subtitle=u"\"{0}\"".format(query_alt),
)
items.setIcon('icons/new.png', 'image')
items.addItem()

templates_list = search.templates()

if len(templates_list) > 0:
    for file in templates_list:
        items.setItem(
            arg=u"{0}|{1}|".format(query, file['path']),
            subtitle=u"\"{0}\" ({1}, {2}. {3})".format(query, zettel_action,
                                                       paste_action,
                                                       quicklook_action),
            title=u"Create note from template: {0}".format(file['filename']),
            type='file',
            quicklookurl=file['path'],
        )
Example #3
0
if query is str():
    tag_results = search.tags(query, 'tag', reverse=False)
else:
    tag_results = search.tags(query, 'count', reverse=True)

if bool(tag_results):
    for tag, counter in tag_results.items():
        items.setItem(
            arg=
            tag,  # we cannot yet send a hash character with `thearchive://match/{query}`
            subtitle=u"{0} Hit(s), (\u2318 Paste Into Frontmost Application)".
            format(counter),
            title=tag,
            valid=True,
        )
        items.setIcon('icons/hashtag.png', 'image')
        items.addMod(
            arg=u"#{0} ".format(tag),
            icon_path='icons/paste.png',
            icon_type='image',
            key='cmd',
            subtitle='Paste this tag into the frontmost application',
        )
        items.addItem()
else:
    items.setItem(
        subtitle="No Tags matches search term",
        title="No Tags found!",
        valid=False,
    )
    items.addItem()
#!/usr/bin/python

from Alfred import Items, Tools

target_dir = Tools.getEnv('directory')

wf = Items()
# Back Item
wf.setItem(title="BACK",
           subtitle="Back to List",
           arg='{0}|{1}'.format(target_dir, "BACK"))
wf.setIcon(m_path="back.png", m_type="image")
wf.addItem()

# Purge Dir Item
wf.setItem(title="Purge Directory",
           subtitle='Purge "{}"'.format(target_dir),
           arg='{0}|{1}'.format(target_dir, "PURGE"))
wf.setIcon(m_path="purge.png", m_type="image")
wf.addItem()

# Delete Item
wf.setItem(title="Remove Folder",
           subtitle='Remove "{}" from configuration'.format(target_dir),
           arg='{0}|{1}'.format(target_dir, "DELETE"))
wf.setIcon(m_path="delete.png", m_type="image")
wf.addItem()

wf.write()
Example #5
0
                "todo_status": file['status'],
            },
        )
        items.addMod(
            arg=file['path'],
            icon_path="icons/the-archive.png",
            icon_type="image",
            key="cmd",
            subtitle=u"Open \"{0}\" in The Archive".format(file['filename']),
        )
        items.addMod(
            arg=file['path'],
            icon_path="icons/editor.png",
            icon_type="image",
            key="alt",
            subtitle=u"Open \"{0}\" in the default editor".format(
                file['filename']),
        )
        items.setIcon(
            'icons/todo.png'
            if file['status'] == 'pending' else 'icons/done.png', 'image')
        items.addItem()
else:
    items.setItem(
        title="No tasks found!",
        subtitle="No task matches the search term",
        valid=False,
    )
    items.addItem()
items.write()
Example #6
0
query = Tools.getArgv(1)
todos = md_search.todoSearch(query)

wf = Items()
if len(todos) > 0:
    for i in todos:
        md_path = urllib.pathname2url(i['path'])
        md_title = i['title'] if i['title'] != str() else Tools.chop(
            i['filename'], ext)
        wf.setItem(title=i['todo'],
                   subtitle=u'\u2192 {0} (Created: {1})'.format(
                       md_title.decode('utf-8'), Tools.getDateStr(i['ctime'])),
                   arg=i['path'],
                   valid=True,
                   type='file')
        wf.setIcon('icons/unchecked.png', 'image')
        # Mod for CMD - new action menu
        wf.addMod(key="cmd",
                  arg="{0}>{1}".format(i['path'], query),
                  subtitle="Actions..",
                  icon_path="icons/action.png",
                  icon_type="image")
        # TODO: REmove
        # wf.addModsToItem()
        wf.addItem()
else:
    wf.setItem(title="No todo found!",
               subtitle="No todo matches search term",
               valid=False)
    wf.addItem()
wf.write()
    # Tag Search and sort based on tag name
    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='{0}'.format(tag),
            subtitle=u"{0} Hit(s), (\u2318 to paste tag into frontmost app)".
            format(counter),
            valid=True,
            arg='#{0}'.format(tag))
        wf.setIcon('icons/hashtag.png', 'image')
        wf.addMod(key='cmd',
                  arg='#{0} '.format(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()

wf.write()
Example #8
0
    {
        "arg": u"wiki_link|[[{0}]]".format(note_title),
        "icon": "icons/link.png",
        "subtitle": u"Copy a Wiki Link for \"{0}\" to the Clipboard".format(note_title),
        "title": "Wiki Link",
    },
    {
        "arg": "editor|{0}".format(note_path),
        "icon": "icons/editor.png",
        "subtitle": "Open \"{0}\" with the default editor".format(os.path.basename(note_path)),
        "title": "External Editor",
    },
    {
        "arg": "delete|{0}>{1}".format(note_path, query),
        "icon": "icons/delete.png",
        "subtitle": u"Delete \"{0}\"".format(os.path.basename(note_path)),
        "title": "Delete Note",
    },
]

for a in actions:
    items.setItem(
        arg=a.get("arg"),
        subtitle=a.get("subtitle"),
        title=a.get("title"),
    )
    items.setIcon(a.get("icon"), "image")
    items.addItem()

items.write()
        "subtitle": "Copy Url Scheme as Markdown Link to Clipboard",
        "arg": "{0}|{1}".format("urlscheme", note_path),
        "icon": "icons/scheme.png",
        "visible": Tools.getEnv("url_scheme")
    },
    {
        "title":
        "Delete Note",
        "subtitle":
        u"Delete \"{0}\". This action cannot be undone!".format(note_title),
        "arg":
        "{0}|{1}>{2}".format("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()
ws_home = f_path if f_path else os.path.expanduser(
    Tools.getEnv('workspaces_home'))
p_path = str(
    PurePath(f_path).parent
) if f_path and f_path != Tools.getEnv('workspaces_home') else str()

query = Tools.getArgv(1)
if query == str():
    it = sorted(get_dirs(ws_home))
else:
    it = sorted(get_files(ws_home))

wf = Items()
if p_path:
    wf.setItem(title='Back', arg=p_path)
    wf.setIcon(m_path='back.png', m_type='image')
    wf.addItem()
if len(it) > 0:
    for i in it:
        if (query == str() or query.lower() in PurePath(i).stem.lower()
            ) and not (os.path.basename(i).startswith('.')):
            ic = 'folder.png' if os.path.isdir(i) else 'workspace.png'
            sub = 'Folder' if os.path.isdir(i) else "Workspace in VSCode"
            title = os.path.basename(i).replace('.code-workspace', '')
            wf.setItem(title=title,
                       subtitle=u'\u23CE to open {0}'.format(sub),
                       arg=i)
            wf.setIcon(m_path=ic, m_type='image')
            wf.addItem()
    if len(wf.getItems(response_type='dict').get('items')) == 0:
        wf.setItem(title="Search does not match a workspace",
        config = json.load(f)
    # List Folders from folders.json
    if len(config.keys()) > 0:
        for k, v in config.items():
            if os.path.isdir(v) and (query == str()
                                     or k.lower().startswith(query.lower())):
                wf.setItem(
                    title=k,
                    subtitle=
                    u"\u23CE to list Files or \u2318 for addtional actions",
                    arg=v)
                wf.addMod(key="cmd", arg=v, subtitle="Enter Action Menu")
                wf.addModsToItem()
            elif not (os.path.isdir(v)):
                wf.setItem(title=k, subtitle="Folder not found!", arg=k)
                wf.setIcon("attention.png", "image")
            wf.addItem()
    else:
        wf.setItem(title="Folder configuration is empty",
                   subtitle="Add folder via File Action",
                   valid=False)
        wf.setItem('attention.png', 'image')
        wf.addItem()
else:
    wf.setItem(
        title="Add Folder(s) to config",
        subtitle=
        "Your run WF for the first time, please add folder(s) via file action first",
        valid=False)
    wf.setIcon("attention.png", 'image')
    wf.addItem()
Example #12
0
        quicklook_url = create_hint_file(wf_path, content)
        ip = wf_path + "/icon.png"
        # 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', Press \u23CE to choose from Keyword(s): ' + \
            keyword_text if valid else description
        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='...for query: \"%s\"' % query,
                valid=False)
    alf.addItem()
alf.write()
Example #13
0
#!/usr/bin/python

from Alfred import Items

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

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

wf.write()
#!/usr/bin/python
from Alfred import Items, Tools
from Workflows import Workflows

wf = Workflows()
alf = Items()
wpath = Tools.getEnv('plist_path') + "/info.plist"

keyword_list = wf.get_item(wpath).get('keywords')
if keyword_list:
    for k in keyword_list:
        withspace = k.get('withspace')
        keyw = k.get('keyword')
        keyword = '{0} '.format(keyw) if withspace and keyw else keyw
        title = k.get('title')
        text = k.get('text')
        if keyword:
            alf.setItem(title=title,
                        subtitle=u'Press \u23CE to proceed with Keyword: %s' %
                        keyword,
                        arg=keyword)
            alf.setIcon('icons/start.png', m_type='image')
            alf.addItem()
else:
    alf.setItem(title="This workflow has not keywords defined", valid=False)
alf.write()
Example #15
0
if working_path:
    rf = RecentFiles(working_path)
    files_in_directory = rf.getRecentFilesDeep(
        reverse=True) if search_subfolders else rf.getRecentFiles(reverse=True)
    file_list = RecentFiles.search(query, files_in_directory) if bool(
        query) and files_in_directory else files_in_directory

wf = Items()

# When path not found, expose error to script filter
if files_in_directory is None:
    wf.setItem(
        title='Path "{0}" not found...'.format(t_dir),
        subtitle='Change path in List Filter, e.g. /Users/<user>/Desktop',
        valid=False)
    wf.setIcon('attention.png', 'png')
    wf.addItem()
# In case no files were found in directory
elif len(files_in_directory) == 0:
    wf.setItem(title='Folder is empty!',
               subtitle=u"\u23CE to start again",
               arg="*RESTART*",
               valid=True)
    wf.setIcon('attention.png', 'png')
    wf.addItem()
# if file search has no results
elif len(file_list) == 0:
    wf.setItem(title='Cannot find file starting with "{0}"'.format(query),
               valid=False)
    wf.setIcon('attention.png', 'png')
    wf.addItem()