Skip to content

hyprkan crashes on niri #7

@stella-sf

Description

@stella-sf

Describe the bug

Whenever I do an action that I configured to do a layer switch, the script simply crashes.

Traceback (most recent call last):
  File "/home/stella/.local/bin/hyprkan.py", line 1007, in <module>
    main()
    ~~~~^^
  File "/home/stella/.local/bin/hyprkan.py", line 1003, in main
    session.wm.listen(kanata, cfg)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/stella/.local/bin/hyprkan.py", line 479, in listen
    self._setup_event_listener(on_focus_event)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/stella/.local/bin/hyprkan.py", line 606, in _setup_event_listener
    on_focus_callback()
    ~~~~~~~~~~~~~~~~~^^
  File "/home/stella/.local/bin/hyprkan.py", line 457, in on_focus_event
    matched_rule = cfg.detect_rule(win_info)
  File "/home/stella/.local/bin/hyprkan.py", line 415, in detect_rule
    if re.match(pattern_class, current_win_class) and re.match(
       ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/re/__init__.py", line 167, in match
    return _compile(pattern, flags).match(string)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

Expected behavior

not crashing

To Reproduce
Steps to reproduce the behavior:

  • be on niri
  • run kanata with -p 10000
  • run hyprkan
  • switch focus to a window you have a rule for
  • observe error message

Version

  • Kanata:
    1.10.0

  • Hyprkan:
    2.2.0

Relevant Kanata and Hyprkan config

apps.json:

[
  {
    "title": "^Minecraft.*",
    "layer": "gaming"
  },
  {
    "class": "^steam_app_.*",
    "layer": "gaming"
  },
  {
    "layer": "default"
  }
]

kanata.kbd:

;; [...]
(deflayermap (default)
  lsft @lshift
  rsft @rshift
  caps comp
)

(deflayermap (gaming)
  rsft @rshift
  caps comp
)
;; [...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions