This commit is contained in:
2025-12-09 12:01:43 +01:00
parent d53704c824
commit f5d3b5e1a1
5 changed files with 255 additions and 0 deletions

129
.gitignore vendored Normal file
View File

@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Peter De Bruycker
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

36
README.md Normal file
View File

@@ -0,0 +1,36 @@
# albert-uuid-gen
Extension for generating version 4 [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)s in [Albert launcher](https://albertlauncher.github.io/).
## Installation
1. Locate the `modules` directory in the Python extension data directory.
The data directories reside in the data directories of the application defined by Qt.
```
~/.local/share/albert/python/plugins
```
2. Clone this repository into your `modules` directory.
```bash
cd /path/to/modules
git clone git@gitea.felix-boers.de:fboers/albert-uuid-generator.git
```
3. Enable the extension in the settings under `Extensions`.
## Usage
Generates a version 4 UUID.
Synopsis: `<trigger>`
Example:
- `uuid`: generate a random UUID and copy to the clipboard.
## Contributing
If you have any questions, suggestions, or issues, please feel free to open an issue or pull request.

68
__init__.py Normal file
View File

@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
"""
UUID generator extension.
Generates version 4 UUID(s).
"""
import os
from uuid import uuid4
import albert
md_iid = '4.0'
md_name = "UUID Generator"
md_description = "Generate version 4 UUID(s)"
md_version = "0.0.1"
md_license = "MIT"
md_url = "https://gitea.felix-boers.de/fboers/albert-uuid-generator"
md_authors = ["@felixboers"]
md_maintainers = ["@felixboers"]
icon_path = os.path.dirname(__file__)+"/uuid.svg"
def expand_uuid_formats(uuid: str):
return [
uuid,
uuid.replace('-', ''),
"{" + uuid + "}"
]
def build_query_items(uuids):
results = []
for uuid in uuids:
results.append(
albert.StandardItem(
id='uuid',
text=uuid,
icon_factory=lambda: albert.makeImageIcon(icon_path),
subtext=uuid,
actions=[
albert.Action(
id='copy',
text='Copy uuid to clipboard',
callable=lambda: albert.setClipboardText(uuid)
)
]
)
)
return results
class Plugin(albert.PluginInstance, albert.TriggerQueryHandler):
def __init__(self):
albert.PluginInstance.__init__(self)
albert.TriggerQueryHandler.__init__(self)
def defaultTrigger(self):
return 'uuid '
def handleTriggerQuery(self, query):
if not query.isValid:
return
uuid = str(uuid4())
formats = expand_uuid_formats(uuid)
query.add(build_query_items(formats))

1
uuid.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 23 KiB