diff options
| author | Gilles Castel <gilles@castel.dev> | 2019-06-19 17:57:49 +0200 |
|---|---|---|
| committer | Gilles Castel <gilles@castel.dev> | 2019-06-19 17:57:49 +0200 |
| commit | ef049dee98b7877815d44cb143417fa7bb118064 (patch) | |
| tree | a39b9c40ba28a613bd1712e35e5ea73dcdbe7112 /config.py | |
| parent | 11b786c82bbc77b3b4139a9bb8019be5454a1ebd (diff) | |
Make it configurable
Diffstat (limited to 'config.py')
| -rw-r--r-- | config.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/config.py b/config.py new file mode 100644 index 0000000..8940d9f --- /dev/null +++ b/config.py @@ -0,0 +1,51 @@ +import sys +import subprocess +from pathlib import Path + +def open_editor(filename): + subprocess.run([ + 'urxvt', + '-geometry', '60x5', + '-name', 'popup-bottom-center', + '-e', "vim", + f"{filename}", + ]) + +def latex_document(latex): + return r""" + \documentclass[12pt,border=12pt]{standalone} + + \usepackage[utf8]{inputenc} + \usepackage[T1]{fontenc} + \usepackage{textcomp} + \usepackage{amsmath, amssymb} + \newcommand{\R}{\mathbb R} + \usepackage{cmbright} + + \begin{document} + """ + latex + r"\end{document}" + +config = { + # For example '~/.config/rofi/ribbon.rasi' or None + 'rofi_theme': None, + # Font that's used to add text in inkscape + 'font': 'monospace', + 'font_size': 10, + 'open_editor': open_editor, + 'latex_document': latex_document, +} + + +# From https://stackoverflow.com/a/67692 +def import_file(name, path): + import importlib.util as util + spec = util.spec_from_file_location(name, path) + module = util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + +CONFIG_PATH = Path('~/.config/inkscape-shortcut-manager').expanduser() + +if (CONFIG_PATH / 'config.py').exists(): + userconfig = import_file('config', CONFIG_PATH / 'config.py').config + config.update(userconfig) |
