diff --git a/modules/app/firefox.nix b/modules/app/firefox.nix index 6eefab8..2ce63f9 100644 --- a/modules/app/firefox.nix +++ b/modules/app/firefox.nix @@ -2,6 +2,7 @@ let cfg = config.samfelag.modules.app.firefox; + i3Cfg = config.samfelag.modules.desktop.i3; in { options.samfelag.modules.app.firefox = { @@ -11,5 +12,9 @@ in environment.systemPackages = with pkgs; [ firefox ]; + + samfelag.modules.desktop.i3.extraKeybindings = lib.mkIf i3Cfg.enable { + "${i3Cfg.mod}+Control+3" = "exec ${pkgs.firefox}/bin/firefox"; + }; }; } diff --git a/modules/app/spotify.nix b/modules/app/spotify.nix index e590720..6f72c23 100644 --- a/modules/app/spotify.nix +++ b/modules/app/spotify.nix @@ -2,6 +2,7 @@ let cfg = config.samfelag.modules.app.spotify; + i3Cfg = config.samfelag.modules.desktop.i3; in { options.samfelag.modules.app.spotify = { @@ -11,5 +12,9 @@ in hm.home.packages = with pkgs; [ spotify ]; + + samfelag.modules.desktop.i3.extraKeybindings = lib.mkIf i3Cfg.enable { + "${i3Cfg.mod}+Control+0" = "exec ${pkgs.spotify}/bin/spotify"; + }; }; } diff --git a/modules/desktop/desktop.nix b/modules/desktop/desktop.nix index a9adc47..2f49713 100644 --- a/modules/desktop/desktop.nix +++ b/modules/desktop/desktop.nix @@ -16,6 +16,9 @@ in type = types.bool; default = false; }; + + bgColour = my.mkOpt' types.str "#808F85" "Background colour for the wallpaper"; + wallpapers = my.mkOpt' types.path ../../data/wallpapers/flors "Path to a folder containing wallpapers"; }; config = mkIf cfg.enable { @@ -50,19 +53,22 @@ in samfelag.modules = { - # Basic app.alacritty.enable = true; - desktop.polybar.enable = true; desktop.rofi.enable = true; + desktop.polybar.enable = true; + app.firefox.enable = true; desktop.i3 = { enable = true; laptop = cfg.laptop; - launcher.command = "${pkgs.rofi}/bin/rofi rofi -show run"; - terminal.command = "${pkgs.alacritty}/bin/alacritty"; - browser.command = "${pkgs.firefox}/bin/firefox"; - locker.command = "${pkgs.i3lock-blur}/bin/i3lock-color -c 808F85 && sleep 1"; - app.firefox.enable = true; + launcher = "${pkgs.rofi}/bin/rofi rofi -show run"; + terminal = "${pkgs.alacritty}/bin/alacritty"; + locker = "${pkgs.i3lock-blur}/bin/i3lock-color -c 808F85 && sleep 1"; + + extraStartup = [ + { command = "systemctl --user restart polybar"; always = true; notification = false; } + { command = "feh --bg-center -B \"${cfg.bgColour}\" -z --no-fehbg ${cfg.wallpapers}"; always = true; notification = false; } + ]; }; }; diff --git a/modules/desktop/i3.nix b/modules/desktop/i3.nix index d982db1..0d04e60 100644 --- a/modules/desktop/i3.nix +++ b/modules/desktop/i3.nix @@ -4,50 +4,24 @@ let cfg = config.samfelag.modules.desktop.i3; mod = "Mod4"; - cmdModule = lib.types.submodule ({ ... }: { - options = { - enable = lib.mkOption { - type = lib.types.bool; - default = true; - }; - command = lib.mkOption { - type = lib.types.str; - example = "${pkgs.rofi}/bin/rofi rofi -show run"; - }; - }; - }); - system_mode = "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown"; - bg_colour = "#808F85"; - - paths = { - wallpapers = ../../data/wallpapers; - }; - in { - options.samfelag.modules.desktop.i3 = { - enable = lib.mkEnableOption "i3 window manager"; + options.samfelag.modules.desktop.i3 = with lib; { + enable = mkEnableOption "i3 window manager"; - laptop = lib.mkOption { - description = "Enable features for a laptop (trackpad, battery, etc...)"; - type = lib.types.bool; - default = false; - }; + mod = my.mkOpt' types.str "Mod4" "Main modifier key for i3"; + + laptop = mkEnableOption "Enable features for a laptop (trackpad, battery, etc...)"; + + launcher = mkOption { type = types.str; }; + terminal = mkOption { type = types.str; }; + locker = mkOption { type = types.str; }; + + extraKeybindings = my.mkOpt (types.attrsOf types.str) {}; + extraStartup = my.mkOpt (types.listOf types.attrs) [ ]; - launcher = lib.mkOption { - type = cmdModule; - }; - terminal = lib.mkOption { - type = cmdModule; - }; - browser = lib.mkOption { - type = cmdModule; - }; - locker = lib.mkOption { - type = cmdModule; - }; }; config = lib.mkIf cfg.enable { @@ -59,8 +33,6 @@ in { playerctl ]; - hm.xdg.dataFile."wallpapers".source = paths.wallpapers; - services.xserver = { enable = true; @@ -121,9 +93,7 @@ in { startup = [ { command = "i3-msg workspace 1"; } - { command = "systemctl --user restart polybar"; always = true; notification = false; } - { command = "feh --bg-center -B \"${bg_colour}\" -z --no-fehbg ${paths.wallpapers}/flors"; always = true; notification = false; } - ]; + ] ++ cfg.extraStartup; modes = { "resize" = { @@ -142,10 +112,10 @@ in { }; "${system_mode}" = { - "l" = "exec --no-startup-id ${cfg.locker.command}, mode \"default\""; + "l" = "exec --no-startup-id ${cfg.locker}, mode \"default\""; "e" = "exec --no-startup-id i3-msg exit, mode \"default\""; - "s" = "exec --no-startup-id ${cfg.locker.command} && systemctl suspend, mode \"default\""; - "h" = "exec --no-startup-id ${cfg.locker.command} && systemctl hibernate, mode \"default\""; + "s" = "exec --no-startup-id ${cfg.locker} && systemctl suspend, mode \"default\""; + "h" = "exec --no-startup-id ${cfg.locker} && systemctl hibernate, mode \"default\""; "r" = "exec --no-startup-id systemctl reboot, mode \"default\""; "Shift+s" = "exec --no-startup-id systemctl poweroff -i, mode \"default\""; @@ -242,16 +212,9 @@ in { "${mod}+Shift+9" = "move container to workspace 9; workspace 9"; "${mod}+Shift+0" = "move container to workspace 10; workspace 10"; - } - // (if cfg.terminal.enable then { - "${mod}+Return" = "exec ${cfg.terminal.command}"; - } else {}) - // (if cfg.launcher.enable then { - "${mod}+space" = "exec ${cfg.launcher.command}"; - } else {}) - // (if cfg.browser.enable then { - "${mod}+Control+3" = "exec ${cfg.browser.command}"; - } else {}); + "${mod}+Return" = "exec ${cfg.terminal}"; + "${mod}+space" = "exec ${cfg.launcher}"; + } // cfg.extraKeybindings; }; }; };