zellij: rework layout configuration
extend the base zellij home-manager module to include the option to define layouts with zjstatus, opinionated module; will never be upstreamed in current state also re-enable cava as build failure has been fixed in nixpkgs
This commit is contained in:
parent
602b82fb04
commit
b07798e0e8
4 changed files with 184 additions and 65 deletions
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
osConfig,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
hozen,
|
||||
...
|
||||
}: let
|
||||
|
|
@ -13,6 +11,7 @@
|
|||
|
||||
cfg = osConfig.ooknet.console.tools.zellij;
|
||||
in {
|
||||
imports = [./options.nix];
|
||||
config = mkIf (cfg.enable || console.multiplexer == "zellij") {
|
||||
programs.zellij = {
|
||||
enable = true;
|
||||
|
|
@ -38,18 +37,37 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Layouts
|
||||
xdg.configFile = {
|
||||
# Default layout
|
||||
"zellij/layouts/default.kdl" = import ./layouts/defaultLayout.nix {inherit pkgs config osConfig hozen;};
|
||||
# Layout for bash scripts
|
||||
"zellij/layouts/script.kdl" = import ./layouts/scriptLayout.nix {inherit pkgs config osConfig hozen;};
|
||||
# Layout for configuring my flake
|
||||
"zellij/layouts/flake.kdl" = import ./layouts/flakeLayout.nix {inherit pkgs config osConfig hozen;};
|
||||
# Additional keybinds
|
||||
"zellij/config.kdl".text =
|
||||
# layout configurations
|
||||
layouts = {
|
||||
default = {
|
||||
tabs =
|
||||
#kdl
|
||||
''
|
||||
tab name="terminal" focus=true {
|
||||
pane name="term" focus=true
|
||||
}
|
||||
'';
|
||||
};
|
||||
flake = {
|
||||
tabs =
|
||||
# kdl
|
||||
''
|
||||
tab name="terminal" focus=true {
|
||||
pane name="term" cwd="$FLAKE" focus=true
|
||||
}
|
||||
tab name="editor" {
|
||||
pane name="edit" edit="$FLAKE"
|
||||
}
|
||||
tab name="git" {
|
||||
pane name="git" cwd="$FLAKE" command="lazygit"
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# keybind configuration
|
||||
extraSettings =
|
||||
# kdl
|
||||
''
|
||||
keybinds clear-defaults=true {
|
||||
|
|
@ -57,7 +75,7 @@ in {
|
|||
bind "Alt 1" { GoToTab 1; }
|
||||
bind "Alt 2" { GoToTab 2; }
|
||||
bind "Alt 3" { GoToTab 3; }
|
||||
bind "Alt 4" { GoToTab 4; }
|
||||
bind "Alt 4" { GoToTab 4; }
|
||||
bind "Alt 5" { GoToTab 5; }
|
||||
bind "Alt 6" { GoToTab 6; }
|
||||
bind "Alt 7" { GoToTab 7; }
|
||||
|
|
|
|||
|
|
@ -2,11 +2,28 @@
|
|||
pkgs,
|
||||
hozen,
|
||||
osConfig,
|
||||
ook,
|
||||
...
|
||||
}: let
|
||||
inherit (hozen) color;
|
||||
inherit (ook.lib.generators) mkZellijLayout;
|
||||
in {
|
||||
text =
|
||||
text = mkZellijLayout {
|
||||
zjstatusFile = "${inputs'.zjstatus.packages.default}/bin/zjstatus.wasm";
|
||||
icon = "";
|
||||
timeZone = "${osConfig.time.timeZone}";
|
||||
tabs = ''
|
||||
tab name="terminal" focus=true {
|
||||
pane name="term" cwd="$FLAKE" focus=true
|
||||
}
|
||||
tab name="editor" {
|
||||
pane name="edit" edit="$FLAKE"
|
||||
}
|
||||
tab name="git" {
|
||||
pane name="git" cwd="$FLAKE" command="lazygit"
|
||||
}
|
||||
'';
|
||||
};
|
||||
/*
|
||||
kdl
|
||||
*/
|
||||
|
|
|
|||
115
modules/home/console/tools/multiplexer/zellij/options.nix
Normal file
115
modules/home/console/tools/multiplexer/zellij/options.nix
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
inputs',
|
||||
osConfig,
|
||||
hozen,
|
||||
...
|
||||
}: let
|
||||
inherit (hozen) color;
|
||||
inherit (lib) optionalAttrs mapAttrs' nameValuePair mkIf mkOption;
|
||||
inherit (lib.types) nullOr lines submodule str attrsOf;
|
||||
|
||||
cfg = config.programs.zellij;
|
||||
|
||||
mkZellijLayout = {
|
||||
zjstatus,
|
||||
icon ? "",
|
||||
timeZone,
|
||||
tabs ? '''',
|
||||
}:
|
||||
# kdl
|
||||
''
|
||||
layout {
|
||||
default_tab_template {
|
||||
pane size=2 borderless=true {
|
||||
plugin location="file:${zjstatus}" {
|
||||
format_left "{mode}"
|
||||
format_right "{session} {datetime}"
|
||||
format_center "#[fg=#${color.base0D},bold] {tabs}"
|
||||
format_space ""
|
||||
|
||||
border_enabled "true"
|
||||
border_char "─"
|
||||
border_format "#[fg=#${color.base05}]{char}"
|
||||
border_position "bottom"
|
||||
|
||||
hide_frame_for_single_pane "true"
|
||||
|
||||
mode_normal "#[fg=#${color.base0D}]${icon} "
|
||||
mode_tmux "#[fg=#${color.base0E}]${icon} "
|
||||
mode_pane "#[fg=#${color.base08}]${icon} "
|
||||
mode_tab "#[fg=#${color.base08}]${icon} "
|
||||
mode_rename_tab "#[fg=#${color.base08}]${icon} "
|
||||
mode_rename_pane "#[fg=#${color.base08}]${icon} "
|
||||
mode_session "#[fg=#${color.base08}]${icon} "
|
||||
mode_locked "#[fg=#${color.base05}]${icon} "
|
||||
mode_move "#[fg=#${color.base0B}]${icon} "
|
||||
mode_resize "#[fg=#${color.base0B}]${icon} "
|
||||
mode_prompt "#[fg=#${color.base0A}]${icon} "
|
||||
mode_search "#[fg=#${color.base0A}]${icon} "
|
||||
mode_enter_search "#[fg=#${color.base0A}]${icon} "
|
||||
|
||||
tab_normal "#[bg=#${color.base01}] {name} "
|
||||
tab_active "#[bg=#${color.base02}] {name} "
|
||||
tab_separator " "
|
||||
|
||||
datetime "#[fg=#${color.base05},bold] {format} "
|
||||
datetime_format "%I:%M %p"
|
||||
datetime_timezone "${timeZone}"
|
||||
}
|
||||
}
|
||||
children
|
||||
}
|
||||
${tabs}
|
||||
}
|
||||
'';
|
||||
|
||||
layoutModule = submodule {
|
||||
options = {
|
||||
icon = mkOption {
|
||||
type = str;
|
||||
description = "Icon to display on the status bar";
|
||||
default = "";
|
||||
};
|
||||
timeZone = mkOption {
|
||||
type = str;
|
||||
description = "Timezone for the datetime display";
|
||||
default = osConfig.time.timeZone;
|
||||
};
|
||||
zjstatus = mkOption {
|
||||
type = str;
|
||||
default = "${inputs'.zjstatus.packages.default}/bin/zjstatus.wasm";
|
||||
};
|
||||
tabs = mkOption {
|
||||
type = lines;
|
||||
default = '''';
|
||||
description = "KDL configuration for layouts tabs";
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.programs.zellij = {
|
||||
# TODO: turn this into a binds options
|
||||
extraSettings = mkOption {
|
||||
type = nullOr lines;
|
||||
default = null;
|
||||
description = "Additional settings in KDL format";
|
||||
};
|
||||
layouts = mkOption {
|
||||
type = attrsOf layoutModule;
|
||||
description = "Zellij layouts with zjstatus";
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
xdg.configFile =
|
||||
mapAttrs' (name: layout:
|
||||
nameValuePair "zellij/layouts/${name}.kdl" {
|
||||
text = mkZellijLayout layout;
|
||||
})
|
||||
cfg.layouts
|
||||
// optionalAttrs (cfg.extraSettings != null) {
|
||||
"zellij/config.kdl".text = cfg.extraSettings;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ in {
|
|||
};
|
||||
|
||||
cava = {
|
||||
enable = false; # FIX ME!!!
|
||||
enable = true;
|
||||
settings = {
|
||||
general.framerate = 60;
|
||||
color = {
|
||||
|
|
@ -91,57 +91,26 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
xdg.configFile."zellij/layouts/music.kdl".text =
|
||||
mkIf (zellij.enable || multiplexer == "zellij")
|
||||
/*
|
||||
kdl
|
||||
*/
|
||||
''
|
||||
layout {
|
||||
default_tab_template {
|
||||
pane size=2 borderless=true {
|
||||
plugin location="file:${pkgs.zjstatus}/bin/zjstatus.wasm" {
|
||||
format_left "{mode}"
|
||||
format_right "{session} {datetime}"
|
||||
format_center "#[fg=#89B4FA,bold] {tabs}"
|
||||
format_space ""
|
||||
|
||||
border_enabled "true"
|
||||
border_char "─"
|
||||
border_format "#[fg=#${color.base0D}]{char}"
|
||||
border_position "bottom"
|
||||
|
||||
hide_frame_for_single_pane "true"
|
||||
|
||||
mode_normal "#[fg=${color.base0D}]"
|
||||
|
||||
tab_normal "#[bg=#${color.base01}] {name} "
|
||||
tab_active "#[bg=#${color.base02}] {name} "
|
||||
tab_separator " "
|
||||
|
||||
datetime "#[fg=#${color.base05},bold] {format} "
|
||||
datetime_format "%I:%M %p"
|
||||
datetime_timezone "${osConfig.time.timeZone}"
|
||||
}
|
||||
programs.zellij.layouts.music = {
|
||||
icon = "";
|
||||
tabs =
|
||||
# kdl
|
||||
''
|
||||
tab name="spotify" focus=true {
|
||||
pane name="spotify" {
|
||||
borderless true
|
||||
command "${getExe self'.packages.spotify-player}"
|
||||
focus true
|
||||
}
|
||||
children
|
||||
}
|
||||
|
||||
tab name="spotify" focus=true {
|
||||
pane name="spotify" {
|
||||
borderless true
|
||||
command "${getExe pkgs.spotify-player}"
|
||||
focus true
|
||||
}
|
||||
//pane name="Visualizer" {
|
||||
// borderless false
|
||||
// split_direction "horizontal"
|
||||
// size "20%"
|
||||
// command "cava"
|
||||
//}
|
||||
pane name="Visualizer" {
|
||||
borderless false
|
||||
split_direction "horizontal"
|
||||
size "20%"
|
||||
command "${getExe pkgs.cava}"
|
||||
}
|
||||
}
|
||||
'';
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
home.shellAliases = mkIf (zellij.enable || multiplexer == "zellij") {
|
||||
zjm = "zellij --layout music";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue