hyprkan is a layer switcher for kanata that works exclusively on Hyprland. It listens to Hyprland events, detects active windows, and switches the kanata layer based on window class and title using a JSON configuration.
Warning
Please be aware that hyprkan is currently in its beta version. As such, it may contain bugs that have not yet been identified or resolved.
After downloading hyprkan:
- Ensure that kanata is running and configured correctly.
- Set your rules in the configuration file.
- Now you can run hyprkan.
Important
Make sure hyprkan is executable:
chmod +x hyprkan
To run hyprkan automatically, you can set it up as a systemd service.
Create a systemd user service file at ~/.config/systemd/user/hyprkan.service
with the following content:
[Unit]
Description=Kanata Layer Switcher
After=graphical-session.target
[Service]
ExecStart=%h/.local/bin/hyprkan
Restart=on-failure
RestartSec=5
Type=simple
[Install]
WantedBy=graphical-session.target
Note
Make sure to replace %h/.local/bin/hyprkan
with the correct path to the hyprkan file.
-
Start the service:
systemctl --user start hyprkan
-
Enable the service to start automatically on boot:
systemctl --user enable hyprkan
-
Check the status of the service:
systemctl --user status hyprkan
The configuration file is a JSON file where you define window rules and the corresponding kanata layers. The default configuration file is located at: ~/.config/kanata/apps.json
Here are the properties you can include in the configuration file:
base
: The base layer used as a fallback when no specific rule matches the current app.exec
: Bash commands to execute every time the kanata layer switches. This can be useful if you want to send a notification when the layer changes. For example, you can usenotify-send -r 12345 'Current Layer' $CURRENT_LAYER
.CURRENT_LAYER
is an environment variable you can use to get the current layer's name.rules
: A set of rules that define which layer to switch to based on the active window's class or title. See nata's window rules for more information.
Here is an example structure for the configuration file:
{
"base": "BaseLayer",
"exec": "notify-send $CURRENT_LAYER",
"rules": [
{
"class": "ExampleClass",
"title": "ExampleTitle",
"layer": "ExampleLayer"
}
]
}
Here is a list of available options:
-h
,--help
Display the help message and exit-c
,--config
Path to the JSON configuration file (default:~/.config/kanata/apps.json
)-q
,--quiet
Suppress non-essential output (only errors are shown)-p
,--port
kanata server port (e.g.,10000
) or full address (e.g.,127.0.0.1:10000
, default:127.0.0.1:10000
)-d
,--debug
Enable debug mode-v
,--version
Show hyprkan version
Important
Ensure that the specified port or full address match those used by kanata to avoid connection issues.