fork/home-manager
git clone https://git.julia.blue/fork/home-manager
f63b39a6
master
1{ cfg , config , lib , moduleName } : 2 3with lib ; 4 5rec { 6criteriaStr = criteria : 7let 8toCriteria = k :v : 9if builtins . isBool v then 10( if v then " ${ k } " else "" ) 11else 12'' ${ k } =" ${ v } "'' ; 13in "[ ${ concatStringsSep " " ( mapAttrsToList toCriteria criteria )} ]" ; 14 15keybindingDefaultWorkspace = filterAttrs ( n :v : 16cfg . config . defaultWorkspace != null && v == cfg . config . defaultWorkspace ) 17cfg . config . keybindings ; 18 19keybindingsRest = filterAttrs ( n :v : 20cfg . config . defaultWorkspace == null || v != cfg . config . defaultWorkspace ) 21cfg . config . keybindings ; 22 23keybindingsStr = { keybindings , bindsymArgs ? "" , indent ? "" } : 24concatStringsSep "\n" ( mapAttrsToList ( keycomb :action : 25optionalString ( action != null ) " ${ indent } bindsym ${ 26lib . optionalString ( bindsymArgs != "" ) " ${ bindsymArgs } " 27}${ keycomb } ${ action } " ) keybindings ); 28 29keycodebindingsStr = keycodebindings : 30concatStringsSep "\n" ( mapAttrsToList ( keycomb :action : 31optionalString ( action != null ) "bindcode ${ keycomb } ${ action } " ) 32keycodebindings ); 33 34colorSetStr = c : 35concatStringsSep " " [ 36c . border 37c . background 38c . text 39c . indicator 40c . childBorder 41]; 42barColorSetStr = c :concatStringsSep " " [ c . border c . background c . text ]; 43 44modeStr = bindkeysToCode :name :keybindings :'' 45mode " ${ name } " { 46${ keybindingsStr { 47inherit keybindings ; 48bindsymArgs = lib . optionalString bindkeysToCode "--to-code" ; 49indent = " " ; 50}} 51} 52'' ; 53 54assignStr = workspace :criteria : 55concatStringsSep "\n" 56( map ( c :"assign ${ criteriaStr c } ${ workspace } " ) criteria ); 57 58fontConfigStr = let 59toFontStr = { names , style ? "" , size ? "" } : 60optionalString ( names != [ ]) concatStringsSep " " 61( remove "" [ "font" "pango: ${ concatStringsSep ", " names } " style size ]); 62in fontCfg : 63if isList fontCfg then 64toFontStr { names = fontCfg ; } 65else 66toFontStr { 67inherit ( fontCfg ) names style ; 68size = toString fontCfg . size ; 69}; 70 71barStr = { id , fonts , mode , hiddenState , position , workspaceButtons 72, workspaceNumbers , command , statusCommand , colors , trayOutput , trayPadding 73, extraConfig , ...} : 74let colorsNotNull = lib . filterAttrs ( n :v :v != null ) colors != { }; 75in concatMapStrings ( x :x + "\n" ) ( indent ( lists . subtractLists [ "" null ] 76( flatten [ 77"bar {" 78( optionalString ( id != null ) "id ${ id } " ) 79( fontConfigStr fonts ) 80( optionalString ( mode != null ) "mode ${ mode } " ) 81( optionalString ( hiddenState != null ) "hidden_state ${ hiddenState } " ) 82( optionalString ( position != null ) "position ${ position } " ) 83( optionalString ( statusCommand != null ) 84"status_command ${ statusCommand } " ) 85" ${ moduleName } bar_command ${ command } " 86( optionalString ( workspaceButtons != null ) 87"workspace_buttons ${ lib . hm . booleans . yesNo workspaceButtons } " ) 88( optionalString ( workspaceNumbers != null ) "strip_workspace_numbers ${ 89lib . hm . booleans . yesNo ( ! workspaceNumbers ) 90} " ) 91( optionalString ( trayOutput != null ) "tray_output ${ trayOutput } " ) 92( optionalString ( trayPadding != null ) 93"tray_padding ${ toString trayPadding } " ) 94( optionals colorsNotNull ( indent ( lists . subtractLists [ "" null ] [ 95"colors {" 96( optionalString ( colors . background != null ) 97"background ${ colors . background } " ) 98( optionalString ( colors . statusline != null ) 99"statusline ${ colors . statusline } " ) 100( optionalString ( colors . separator != null ) 101"separator ${ colors . separator } " ) 102( optionalString ( colors . focusedBackground != null ) 103"focused_background ${ colors . focusedBackground } " ) 104( optionalString ( colors . focusedStatusline != null ) 105"focused_statusline ${ colors . focusedStatusline } " ) 106( optionalString ( colors . focusedSeparator != null ) 107"focused_separator ${ colors . focusedSeparator } " ) 108( optionalString ( colors . focusedWorkspace != null ) 109"focused_workspace ${ barColorSetStr colors . focusedWorkspace } " ) 110( optionalString ( colors . activeWorkspace != null ) 111"active_workspace ${ barColorSetStr colors . activeWorkspace } " ) 112( optionalString ( colors . inactiveWorkspace != null ) 113"inactive_workspace ${ barColorSetStr colors . inactiveWorkspace } " ) 114( optionalString ( colors . urgentWorkspace != null ) 115"urgent_workspace ${ barColorSetStr colors . urgentWorkspace } " ) 116( optionalString ( colors . bindingMode != null ) 117"binding_mode ${ barColorSetStr colors . bindingMode } " ) 118"}" 119]) { })) 120extraConfig 121"}" 122])) { }); 123 124gapsStr = with cfg . config . gaps ; 125concatStringsSep "\n" ( lists . subtractLists [ "" null ] [ 126( optionalString ( inner != null ) "gaps inner ${ toString inner } " ) 127( optionalString ( outer != null ) "gaps outer ${ toString outer } " ) 128( optionalString ( horizontal != null ) 129"gaps horizontal ${ toString horizontal } " ) 130( optionalString ( vertical != null ) "gaps vertical ${ toString vertical } " ) 131( optionalString ( top != null ) "gaps top ${ toString top } " ) 132( optionalString ( bottom != null ) "gaps bottom ${ toString bottom } " ) 133( optionalString ( left != null ) "gaps left ${ toString left } " ) 134( optionalString ( right != null ) "gaps right ${ toString right } " ) 135( optionalString smartGaps "smart_gaps on" ) 136( optionalString ( smartBorders != "off" ) "smart_borders ${ smartBorders } " ) 137]); 138 139windowBorderString = window :floating : 140let 141titlebarString = { titlebar , border , ...} : 142" ${ if titlebar then "normal" else "pixel" } ${ toString border } " ; 143in concatStringsSep "\n" [ 144"default_border ${ titlebarString window } " 145"default_floating_border ${ titlebarString floating } " 146]; 147 148floatingCriteriaStr = criteria : 149"for_window ${ criteriaStr criteria } floating enable" ; 150windowCommandsStr = { command , criteria , ...} : 151"for_window ${ criteriaStr criteria } ${ command } " ; 152workspaceOutputStr = item : 153let outputs = concatMapStringsSep " " strings . escapeNixString item . output ; 154in ''workspace " ${ item . workspace } " output ${ outputs } '' ; 155 156indent = list : 157{ includesWrapper ? true , level ? 1 } : 158let prefix = concatStringsSep "" ( lib . genList ( x :" " ) ( level * 2 )); 159 160in ( lib . imap1 ( i :v : 161" ${ if includesWrapper && ( i == 1 || i == ( lib . length list )) then 162v 163else 164" ${ prefix }${ v } " } " ) list ); 165}