2018-08-28 15:46:24 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.xsession.windowManager.bspwm;
|
|
|
|
|
2021-06-20 00:40:17 +02:00
|
|
|
camelToSnake =
|
|
|
|
builtins.replaceStrings upperChars (map (c: "_${c}") lowerChars);
|
2018-08-28 15:46:24 +02:00
|
|
|
|
2021-06-20 00:40:17 +02:00
|
|
|
formatMonitor = monitor: desktops:
|
|
|
|
"bspc monitor ${strings.escapeShellArg monitor} -d ${
|
|
|
|
strings.escapeShellArgs desktops
|
|
|
|
}";
|
|
|
|
|
|
|
|
formatSetting = n: v:
|
2018-08-28 15:46:24 +02:00
|
|
|
let
|
2021-06-20 00:40:17 +02:00
|
|
|
vStr = if isBool v then
|
|
|
|
boolToString v
|
|
|
|
else if isInt v || isFloat v then
|
|
|
|
toString v
|
|
|
|
else if isString v then
|
|
|
|
strings.escapeShellArg v
|
|
|
|
else
|
|
|
|
throw "unsupported setting type for ${n}";
|
|
|
|
in "bspc config ${strings.escapeShellArg n} ${vStr}";
|
|
|
|
|
|
|
|
formatRule = target: directives:
|
2018-08-28 15:46:24 +02:00
|
|
|
let
|
|
|
|
formatDirective = n: v:
|
2021-06-20 00:40:17 +02:00
|
|
|
let
|
|
|
|
vStr = if isBool v then
|
|
|
|
if v then "on" else "off"
|
|
|
|
else if isInt v || isFloat v then
|
|
|
|
toString v
|
|
|
|
else if isString v then
|
|
|
|
v
|
|
|
|
else
|
|
|
|
throw "unsupported rule attribute type for ${n}";
|
|
|
|
in "${camelToSnake n}=${vStr}";
|
|
|
|
|
|
|
|
directivesStr = strings.escapeShellArgs (mapAttrsToList formatDirective
|
|
|
|
(filterAttrs (n: v: v != null) directives));
|
|
|
|
in "bspc rule -a ${strings.escapeShellArg target} ${directivesStr}";
|
|
|
|
|
|
|
|
formatStartupProgram = s: "${s} &";
|
2018-08-28 15:46:24 +02:00
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2021-06-20 00:40:17 +02:00
|
|
|
meta.maintainers = [ maintainers.ncfavier ];
|
|
|
|
|
|
|
|
options = import ./options.nix { inherit pkgs lib; };
|
2018-08-28 15:46:24 +02:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-06-20 00:40:17 +02:00
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
xdg.configFile."bspwm/bspwmrc".source = pkgs.writeShellScript "bspwmrc" ''
|
|
|
|
${concatStringsSep "\n" (mapAttrsToList formatMonitor cfg.monitors)}
|
|
|
|
|
|
|
|
${concatStringsSep "\n" (mapAttrsToList formatSetting cfg.settings)}
|
|
|
|
|
|
|
|
bspc rule -r '*'
|
|
|
|
${concatStringsSep "\n" (mapAttrsToList formatRule cfg.rules)}
|
|
|
|
|
|
|
|
# java gui fixes
|
|
|
|
export _JAVA_AWT_WM_NONREPARENTING=1
|
|
|
|
bspc rule -a sun-awt-X11-XDialogPeer state=floating
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
|
|
|
${concatMapStringsSep "\n" formatStartupProgram cfg.startupPrograms}
|
|
|
|
'';
|
|
|
|
|
|
|
|
xsession.windowManager.command =
|
|
|
|
"${cfg.package}/bin/bspwm -c ${config.xdg.configHome}/bspwm/bspwmrc";
|
2018-08-28 15:46:24 +02:00
|
|
|
};
|
|
|
|
}
|