window-action

command module
v0.0.0-...-4297129 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

README

Window Action

A small utility that executes shell commands based on which window is currently focused. Useful for triggering hardware or software actions tied to application context, for example switching keyboard layers when a specific app has focus.

Requirements

Installation

go install codeberg.org/jmcs/window-action@latest

Usage

window-action [flags]

Flags:
  -i <id>    Command ID to execute (default: "default")
  -c <path>  Path to config file (default: $HOME/.config/window-action/config.json)

The tool reads the currently focused window, walks the configured rules in order, and executes the shell command from the first matching rule that contains the requested command ID. If no suitable rule matches, default_command is used as a fallback.

The -i flag lets you map a single invocation to a specific command ID within each rule, so you can bind different GNOME shortcuts to the same config with different behaviours.

Configuration

By default, the config is read from ~/.config/window-action/config.json.

{
  "default_command": "some-fallback-command",
  "rules": [
    {
      "name": "Firefox",
      "class": "firefox",
      "commands": {
        "default": "some-command",
        "alt": "some-other-command"
      }
    },
    {
      "name": "Terminal",
      "title": ".*fish.*",
      "commands": {
        "default": "another-command"
      }
    }
  ]
}
Field Description
default_command Shell command to run when no rule matches.
rules[].name Human-readable label for the rule (required).
rules[].class Regex matched against the window class.
rules[].title Regex matched against the window title.
rules[].commands Map of command IDs to shell commands.

Both class and title are optional; if both are set, the rule matches only when both match.

License

This project is licensed under GPLv3. A copy of the licence is available in LICENSE.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL