JonnyHaystack / i3-resurrect

Simple solution to saving and restoring i3 workspaces
GNU General Public License v3.0
379 stars 19 forks source link

Add a way to interpolate actual cmdline args into custom command mappings #61

Closed JonnyHaystack closed 4 years ago

JonnyHaystack commented 4 years ago

Is your feature request related to a problem? Please describe. Currently, custom command mappings only allow a fixed command. This is limiting in cases where you might only want to change part of the command, but keep the rest.

Describe the solution you'd like Python's str.format() function makes it possible for users to use Python format specifiers in custom commands, which will then be replaced by the corresponding argument from the actual command.

Example:

Command mapping:

{
  "window_command_mappings": [
    {
      "class": "Code",
      "command": "code -n {1}"
    }
  ]
}

Actual cmdline: ['code', '/path/to/file.txt']

Resulting command that gets saved: code -n /path/to/file.txt

Additional context https://github.com/JonnyHaystack/i3-resurrect/issues/60#issuecomment-554657498