eww: add terminal integration options

Use eww's shell-completions command to generate completions for
bash, zsh and fish.
This commit is contained in:
Jean Sidharta 2024-07-28 21:37:02 +00:00 committed by GitHub
parent a11cfcd0a1
commit 587fcca66e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,6 +5,7 @@ with lib;
let
cfg = config.programs.eww;
ewwCmd = "${cfg.package}/bin/eww";
in {
meta.maintainers = [ hm.maintainers.mainrs ];
@ -30,10 +31,40 @@ in {
{file}`$XDG_CONFIG_HOME/eww`.
'';
};
enableBashIntegration = mkEnableOption "Bash integration" // {
default = true;
};
enableZshIntegration = mkEnableOption "Zsh integration" // {
default = true;
};
enableFishIntegration = mkEnableOption "Fish integration" // {
default = true;
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."eww".source = cfg.configDir;
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
if [[ $TERM != "dumb" ]]; then
eval "$(${ewwCmd} shell-completions --shell bash)"
fi
'';
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
if [[ $TERM != "dumb" ]]; then
eval "$(${ewwCmd} shell-completions --shell zsh)"
fi
'';
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
if test "$TERM" != "dumb"
eval "$(${ewwCmd} shell-completions --shell fish)"
end
'';
};
}