Skip to content

Commit

Permalink
update from
Browse files Browse the repository at this point in the history
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 gillescastel#6, since keybindings like Shift+t will still
work.
  • Loading branch information
OmerBenHayun committed Mar 28, 2023
1 parent 8a6056d commit e666188
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
52 changes: 34 additions & 18 deletions config.py
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -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)
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit e666188

Please sign in to comment.