Compare commits
4 Commits
8bc6e6be7f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 28b39374ae | |||
| 4dadfaa162 | |||
| af82a53450 | |||
| 5c659a673b |
12
Makefile
Normal file
12
Makefile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||||
|
PLUGIN_NAME:=albert-plugin-python-uuid-generator
|
||||||
|
INSTALL_ROOT:=$(HOME)/.local/share/albert/python/plugins
|
||||||
|
INSTALL_DIR:=$(INSTALL_ROOT)/$(PLUGIN_NAME)
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: uninstall
|
||||||
|
ln -fs $(ROOT_DIR)/ $(INSTALL_DIR)
|
||||||
|
|
||||||
|
.PHONY: uninstall
|
||||||
|
uninstall:
|
||||||
|
rm -f $(INSTALL_DIR)
|
||||||
33
__init__.py
33
__init__.py
@@ -1,23 +1,15 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""
|
|
||||||
UUID generator extension.
|
|
||||||
|
|
||||||
Generates version 4 UUID(s).
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
import albert
|
import albert
|
||||||
|
|
||||||
md_iid = '4.0'
|
md_iid = '5.0'
|
||||||
md_name = "UUID Generator"
|
md_name = "UUID Generator"
|
||||||
md_description = "Generate version 4 UUID(s)"
|
md_description = "Generate version 4 UUID(s)"
|
||||||
md_version = "0.0.1"
|
md_version = "1.0.0"
|
||||||
md_license = "MIT"
|
md_license = "MIT"
|
||||||
md_url = "https://gitea.felix-boers.de/fboers/albert-uuid-generator"
|
md_url = "https://gitea.felix-boers.de/fboers/albert-plugin-python-uuid-generator"
|
||||||
md_authors = ["@felixboers"]
|
md_authors = ["@felixboers"]
|
||||||
md_maintainers = ["@felixboers"]
|
md_maintainers = ["@felixboers"]
|
||||||
|
|
||||||
@@ -37,32 +29,31 @@ def build_query_items(uuids):
|
|||||||
albert.StandardItem(
|
albert.StandardItem(
|
||||||
id='uuid',
|
id='uuid',
|
||||||
text=uuid,
|
text=uuid,
|
||||||
icon_factory=lambda: albert.makeImageIcon(icon_path),
|
icon_factory=lambda: albert.Icon.image(icon_path),
|
||||||
subtext=uuid,
|
subtext=uuid,
|
||||||
actions=[
|
actions=[
|
||||||
albert.Action(
|
albert.Action(
|
||||||
id='copy',
|
'copy',
|
||||||
text='Copy uuid to clipboard',
|
'Copy uuid to clipboard',
|
||||||
callable=lambda id=uuid: albert.setClipboardText(id)
|
lambda id_=uuid: albert.setClipboardText(id_)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
class Plugin(albert.PluginInstance, albert.TriggerQueryHandler):
|
class Plugin(albert.PluginInstance, albert.GeneratorQueryHandler):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
albert.PluginInstance.__init__(self)
|
albert.PluginInstance.__init__(self)
|
||||||
albert.TriggerQueryHandler.__init__(self)
|
albert.GeneratorQueryHandler.__init__(self)
|
||||||
|
|
||||||
def defaultTrigger(self):
|
def defaultTrigger(self):
|
||||||
return 'uuid '
|
return 'uuid '
|
||||||
|
|
||||||
def handleTriggerQuery(self, query):
|
def items(self, ctx):
|
||||||
if not query.isValid:
|
if not ctx.isValid:
|
||||||
return
|
return
|
||||||
|
|
||||||
uuid = str(uuid4())
|
uuid = str(uuid4())
|
||||||
formats = expand_uuid_formats(uuid)
|
formats = expand_uuid_formats(uuid)
|
||||||
query.add(build_query_items(formats))
|
yield [i for i in build_query_items(formats)]
|
||||||
|
|||||||
Reference in New Issue
Block a user