Skip to content

[FEATURE] Allow keybind action value to be an array #88

Description

@arkonger

Scope checklist

  • I read SCOPE.md and this request is not in the out of scope list.
  • I am not requesting a new tiling layout or a new layout paradigm.
  • I checked the documentation and examples/config.toml, and this is not already possible with configuration, window or layer rules, keybinds, submaps, or umbriel msg.
  • This needs the compositor. A desktop shell, an ordinary client, or a script over umbriel msg cannot do it.
  • I have searched existing issues and pull requests for the same request.
  • I understand this can be closed as out of scope, and that this is a decision about the project, not about the idea.

Problem

I wanted to use notify-send to provide some visual feedback on layout/submap changes, so I wrote a couple of scripts for QoL -- but then I need to make my binding something like "Mod+W" = "spawn:bash -c 'umbriel msg workspace-set-layout:toggle && MY_SCRIPT'" to actually run the script on the keybinding. This I was happy with, but when I got to setting up the same thing for submaps, I realized I was better off using "submap[test],X" = bash -c 'umbriel msg ACTION && umbriel msg submap:reset && MY_SCRIPT' than using the built-in submap key for the binding.

What you already tried

I can definitely get the behavior I want if I essentially just write a bash script in my config, but I don't imagine I'm the only one who would want a feature like this & thought it was worth asking.

Area

Configuration

Proposed behavior

See this draft PR for a proof-of-concept. I think it is probably sufficient to keep the same behavior on the basic "BINDING" = "ACTION" syntax, but for the more advanced key-value syntax something like "BINDING" = { action = ["ACTION1", "ACTION2", ...], repeat = false, ... } could be nice & would really expand what is possible within configuration without falling back on external tools like bash.

Scope fit

As above, it's very possible now to get this behavior with e.g., a multi-line string embedding a bash script into the config; it simply feels clunky to me, and bloats the file size.

Prior art and references

In i3/sway, for instance, it's very possible to bind a series of commands to one keybinding using semicolons like so:

# Mark focused container for swap
bindsym $mod+Shift+m [con_mark="^swap-target$"] unmark "swap-target";\
  mark --add "swap-target";\
  exec notify-send -t 1500 "Marked for swap"
# Swap the containers
bindsym $mod+Shift+g swap container with mark "swap-target";\
  [con_mark="^swap-target$"] unmark "swap-target"

The apparent way to translate that concept to toml is by using an array of command strings.

Participation

  • I am willing to implement this myself, after the scope is agreed.
  • I can test an implementation in my own session.

Additional context

I'm happy to continue testing & refining my PR when I have free time, but I'm very open to suggestions on how to approach it / what would create the least friction for future maintenance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions