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