Use cmd
to launch programs (NixOS)
#1488
Replies: 2 comments
-
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.
-
I'm struggling to use the
cmd
action to launch applications. I tried tested multiple approaches with different applications, but none worked:mycmd (cmd wezterm)
:cmd
executes the binary directly and has no PATH, so of course it doesn't know whatwezterm
ismycmd (cmd /run/current-system/sw/bin/wezterm)
: This waycmd
finds the binary, butwezterm
requires DISPLAY to be set:wezterm_gui > XOpenDisplay failed to open a display. Check the $DISPLAY env var; terminating
mycmd (cmd /run/current-system/sw/bin/bash -c "DISPLAY=:0 /run/current-system/sw/bin/wezterm")
: doesn't work eithermycmd (cmd /run/current-system/sw/bin/bash -c "WAYLAND_DISPLAY=wayland-0 /run/current-system/sw/bin/wezterm")
: nopeI 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.
All reactions