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.