From e6661882a4471c9c9c387c7ec7c3d29d376f79fa Mon Sep 17 00:00:00 2001 From: Omer Ben Hayun Date: Tue, 28 Mar 2023 12:32:12 +0300 Subject: [PATCH] update from https://github.com/gillescastel/inkscape-shortcut-manager/pull/26/files using simonecig PR code Hi! Many tiling window managers use by default keybindings with both the Super key (Mod4) and the shift key pressed (i.e. Mod4+Shift+q to close the focused window). Currently, such key combinations are grabbed and therefore can't be used while the script is running. I was able to solve this by ungrabbing the Shift_L key with the modifier Mod4Mask (and also Mod1Mask for the Alt key). This should also resolve #6, since keybindings like Shift+t will still work. --- config.py | 52 ++++++++++++++++++++++++++++++++++------------------ main.py | 4 ++++ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/config.py b/config.py index 6b4202e..0aea410 100644 --- a/config.py +++ b/config.py @@ -1,18 +1,28 @@ -import sys import subprocess +import sys from pathlib import Path + def open_editor(filename): - subprocess.run([ - 'urxvt', - '-geometry', '60x5', - '-name', 'popup-bottom-center', - '-e', "vim", - f"{filename}", - ]) + subprocess.run( + [ + "urxvt", + "-geometry", + "60x5", + "-name", + "popup-bottom-center", + "-e", + "vim", + "-u", + "/home/omer/.vimrc_latex", + f"{filename}", + ] + ) + def latex_document(latex): - return r""" + return ( + r""" \documentclass[12pt,border=12pt]{standalone} \usepackage[utf8]{inputenc} @@ -22,29 +32,35 @@ def latex_document(latex): \newcommand{\R}{\mathbb R} \begin{document} - """ + latex + r"\end{document}" + """ + + latex + + r"\end{document}" + ) + config = { # For example '~/.config/rofi/ribbon.rasi' or None - 'rofi_theme': 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, + "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_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) diff --git a/main.py b/main.py index b448554..d67b3a8 100644 --- a/main.py +++ b/main.py @@ -45,6 +45,10 @@ def grab(self): # Ungrab window manager shortcuts (Super + ...) self.inkscape.ungrab_key(self.string_to_keycode('Super_L'), X.AnyModifier, True) self.inkscape.ungrab_key(self.string_to_keycode('Alt_L'), X.AnyModifier, True) + #see PR: + #https://github.com/gillescastel/inkscape-shortcut-manager/pull/26 + self.inkscape.ungrab_key(self.string_to_keycode('Shift_L'), X.Mod4Mask, True) + self.inkscape.ungrab_key(self.string_to_keycode('Shift_L'), X.Mod1Mask, True) self.inkscape.change_attributes(event_mask=X.KeyReleaseMask | X.KeyPressMask | X.StructureNotifyMask) def ungrab(self):