Use cmd
to launch programs (NixOS)
#1488
-
I'm struggling to use the
I tried other programs, but they either require DISPLAY to be set, or execute without any errors, but still don't open. How can I get this to work? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I made some progress. It seems that NixOS hardened the configuration of the Kanata service to such an extend, that it is hardly usable to execute commands. Instead I defined my own service and set the required environment variables. Unfortunately this makes the config VERY non-portable. I will harden it step by step to find out what the minimum required permissions are. systemd.services.kanata = {
enable = true;
unitConfig = {
Description = "Kanata keyboard remapper";
Documentation = "https://github.com/jtroo/kanata";
};
serviceConfig = let
DISPLAY = "DISPLAY=:0";
WAYLAND_DISPLAY = "WAYLAND_DISPLAY=wayland-0";
XAUTHORITY = "XAUTHORITY=...";
PATH = "PATH=...";
XDG_RUNTIME_DIR = "XDG_RUNTIME_DIR=...";
in {
Type = "simple";
User = "...";
Environment = "${DISPLAY} ${WAYLAND_DISPLAY} ${XAUTHORITY} ${PATH} ${XDG_RUNTIME_DIR}";
ExecStart = "/run/current-system/sw/bin/sh -c 'exec $$(which kanata) --cfg ${./config.kbd}'";
Restart = "no";
};
wantedBy = ["default.target"];
}; |
Beta Was this translation helpful? Give feedback.
-
Found an even better solution. I created the service using home-manager; that way I don't even have to setup the environment variables anymore. Another plus is, that other users can now use my PC without having to disable Kanata :D home-manager.users.<user> = {config, ...}:
with config; {
systemd.user.services.kanata = {
Unit = {
Description = "Kanata keyboard remapper";
Documentation = "https://github.com/jtroo/kanata";
};
Install = {
WantedBy = ["default.target"];
};
Service = {
Type = "notify";
ExecStart = "/run/current-system/sw/bin/sh -c 'exec $$(which kanata) --cfg ${./config.kbd}'";
Restart = "no";
};
};
}; |
Beta Was this translation helpful? Give feedback.
Did you try
services.kanata.package = kanata-with-cmd;
?