Skip to content

Swhkd crashes when using @escape in a oneoff mode #312

@Borroot

Description

@Borroot

Version Information:

  • Distribution Information: Linux 6.14.6-arch1-1 x86_64 GNU/Linux
  • swhkd version: Simple-Wayland-HotKey-Daemon 1.3.0-dev

Expected behavior:

According to swhkd(5) escaping in a 'oneoff' mode pops two modes out of the mode stack, so it should return to 'normal mode', since this is the bottom of the stack.

Actual behavior:

Swhkd crashes.

To Reproduce:

Config file:

alt + m
	@enter music && echo

mode music oneoff
q
	@escape && echo
endmode

Start swhkd:

[2025-05-23T00:19:19Z ERROR swhkd] Could not open evdev device at /dev/input/mouse4: Inappropriate ioctl for device (os error 25)

thread 'main' panicked at swhkd/src/daemon.rs:495:78:
index out of bounds: the len is 0 but the index is 18446744073709551615
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
zsh: IOT instruction  sudo swhkd

Additional information:

The problem is likely that swhkd tries to pop two modes from the stack, i.e. music and normal mode, after which the stack is empty and it tries to access an element in there. I suspect it wraps around the stack index from 0 to the maximum size the unsigned number can hold.

Workaround is to simply use a command that does nothing, e.g.

alt + m
	@enter music && echo

mode music oneoff
q
	echo
endmode

Also, I think the error swhkd gives is unrelated and already discussed in issue #301. I further use the && echo to prevent the parse error from #311. Note that swhkd 1.2.1 does not capture any keystrokes on my setup for unknown reasons.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions