1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.xserver.windowManager.bspwm; 7in 8 9{ 10 options = { 11 services.xserver.windowManager.bspwm = { 12 enable = mkEnableOption "bspwm"; 13 14 package = mkOption { 15 type = types.package; 16 default = pkgs.bspwm; 17 defaultText = "pkgs.bspwm"; 18 example = "pkgs.bspwm-unstable"; 19 description = '' 20 bspwm package to use. 21 ''; 22 }; 23 configFile = mkOption { 24 type = with types; nullOr path; 25 example = "${pkgs.bspwm}/share/doc/bspwm/examples/bspwmrc"; 26 default = null; 27 description = '' 28 Path to the bspwm configuration file. 29 If null, $HOME/.config/bspwm/bspwmrc will be used. 30 ''; 31 }; 32 33 sxhkd = { 34 package = mkOption { 35 type = types.package; 36 default = pkgs.sxhkd; 37 defaultText = "pkgs.sxhkd"; 38 example = "pkgs.sxhkd-unstable"; 39 description = '' 40 sxhkd package to use. 41 ''; 42 }; 43 configFile = mkOption { 44 type = with types; nullOr path; 45 example = "${pkgs.bspwm}/share/doc/bspwm/examples/sxhkdrc"; 46 default = null; 47 description = '' 48 Path to the sxhkd configuration file. 49 If null, $HOME/.config/sxhkd/sxhkdrc will be used. 50 ''; 51 }; 52 }; 53 }; 54 }; 55 56 config = mkIf cfg.enable { 57 services.xserver.windowManager.session = singleton { 58 name = "bspwm"; 59 start = '' 60 export _JAVA_AWT_WM_NONREPARENTING=1 61 SXHKD_SHELL=/bin/sh ${cfg.sxhkd.package}/bin/sxhkd ${optionalString (cfg.sxhkd.configFile != null) "-c \"${cfg.sxhkd.configFile}\""} & 62 ${cfg.package}/bin/bspwm ${optionalString (cfg.configFile != null) "-c \"${cfg.configFile}\""} & 63 waitPID=$! 64 ''; 65 }; 66 environment.systemPackages = [ cfg.package ]; 67 }; 68 69 imports = [ 70 (mkRemovedOptionModule [ "services" "xserver" "windowManager" "bspwm-unstable" "enable" ] 71 "Use services.xserver.windowManager.bspwm.enable and set services.xserver.windowManager.bspwm.package to pkgs.bspwm-unstable to use the unstable version of bspwm.") 72 (mkRemovedOptionModule [ "services" "xserver" "windowManager" "bspwm" "startThroughSession" ] 73 "bspwm package does not provide bspwm-session anymore.") 74 (mkRemovedOptionModule [ "services" "xserver" "windowManager" "bspwm" "sessionScript" ] 75 "bspwm package does not provide bspwm-session anymore.") 76 ]; 77}