diff --git a/modules/default.nix b/modules/default.nix index c9c8826..7f5a8e2 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -33,8 +33,9 @@ let named = submodule { misc = mkOption { type = attrsOf str; }; hex = mkOption { type = themeType; }; }; - }; in -{ + }; + scripts = (import ../scripts/clip.nix { inherit pkgs; }); +in { options.riley = with lib; { @@ -152,8 +153,8 @@ let named = submodule { # Sike I use kakoune ":e" = "kak"; - # Launch [A]lacritty - "a" = "alacritty"; + # Launch [T]erminal + "t" = "alacritty"; # [D]isown "d" = "disown"; diff --git a/modules/gui/clipboard.nix b/modules/gui/clipboard.nix index c7c6f03..6f2fba9 100644 --- a/modules/gui/clipboard.nix +++ b/modules/gui/clipboard.nix @@ -1,33 +1,10 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, scripts, ... }: (lib.mkIf (config.riley.gui) { # Add some shell scripts that abstract away the # horrible reality that the clipboard is managed by # the display server. - users.users."riley".packages = with pkgs; [ - - (writeShellApplication { - name = "c"; - runtimeInputs = [ xclip ]; - text = "xclip -sel clip -i"; - }) - - (writeShellApplication { - name = "p"; - runtimeInputs = [ xclip ]; - text = "xclip -sel clip -o"; - }) - - (writeShellApplication { - name = "sc"; - runtimeInputs = [ xclip scrot ]; - text = '' - scrot -zso /tmp/sc.png - xclip -t "image/png" -sel clip -i < /tmp/sc.png - ''; - }) - - ]; + users.users."riley".packages = with scripts; [ c p ]; }) diff --git a/modules/gui/default.nix b/modules/gui/default.nix index 3ff575e..284e363 100644 --- a/modules/gui/default.nix +++ b/modules/gui/default.nix @@ -8,7 +8,7 @@ with lib; { ./pulseaudio.nix ./clipboard.nix - ./alacritty.nix + ./terminal.nix ]; diff --git a/modules/gui/alacritty.nix b/modules/gui/terminal.nix similarity index 100% rename from modules/gui/alacritty.nix rename to modules/gui/terminal.nix diff --git a/modules/gui/wm/default.nix b/modules/gui/wm/default.nix index bb7a2b3..8ba57c5 100644 --- a/modules/gui/wm/default.nix +++ b/modules/gui/wm/default.nix @@ -1,10 +1,12 @@ { pkgs, config, lib, ... }: -let theme = config.riley.theme.hex; +let scripts = (import ./scripts.nix); + theme = config.riley.theme.hex; modifier = "Mod4"; + terminal = "${pkgs.alacritty}/bin/alacritty"; keybindings = (import ./keybinds.nix { - inherit modifier lib pkgs config; + inherit modifier lib pkgs config scripts; directional = { left = "H"; @@ -24,8 +26,9 @@ let theme = config.riley.theme.hex; launchers = { browser = "google-chrome-stable"; + inherit terminal; }; - + }); in @@ -42,14 +45,12 @@ with lib; (mkIf config.riley.gui { config = with lib; (rec { - inherit modifier keybindings; - - terminal = "${pkgs.alacritty}/bin/alacritty"; + inherit modifier keybindings terminal; colors = { focused = rec { background = theme.background.normal; - text = theme."red".bright; + text = theme."green".bright; border = background; childBorder = border; indicator = border; diff --git a/modules/gui/wm/keybinds.nix b/modules/gui/wm/keybinds.nix index 3b30ad7..600e4a4 100644 --- a/modules/gui/wm/keybinds.nix +++ b/modules/gui/wm/keybinds.nix @@ -1,4 +1,13 @@ -{ lib, config, pkgs, modifier ? "Mod4", directional, workspace, launchers }: +{ + modifier ? "Mod4", + directional, + workspace, + launchers, + scripts, + config, + pkgs, + lib, +}: with lib; let mod = modifier; @@ -51,9 +60,9 @@ with lib; let mod = modifier; ); # Application launchers - genLaunchers = ({ browser }: { + genLaunchers = ({ browser, terminal }: { "${mod}+Tab" = "exec ${browser}"; - "${mod}+Return" = "exec alacritty"; + "${mod}+Return" = "exec ${terminal}"; }); # Layout manipulation @@ -99,10 +108,20 @@ with lib; let mod = modifier; }))) ); + + # Utility scripts, for example for making screenshots. + utils = ({ lock ? null, sc ? null }: + (optionalAttrs (lock != null) { + "${mod}+Escape" = "exec ${lock}/bin/lock"; + }) // (optionalAttrs (sc ? null) { + "${mod}+d" = "exec ${sc}/bin/sc"; + }) + ); in (mkMerge [ (media { inherit (pkgs) mpc_cli pulseaudio; }) + (utils { inherit (scripts) lock sc; }) (genDirectional directional) (genWorkspaces workspace) diff --git a/modules/gui/wm/scripts.nix b/modules/gui/wm/scripts.nix new file mode 100644 index 0000000..aa71049 --- /dev/null +++ b/modules/gui/wm/scripts.nix @@ -0,0 +1,20 @@ +# Utility scripts for use with a window manager. + +{ pkgs, ... }: with pkgs; { + + lock = writeShellApplication { + name = "lock"; + runtimeInputs = [ i3lock ]; + text = "i3lock"; + }; + + sc = (writeShellApplication { + name = "sc"; + runtimeInputs = [ xclip scrot ]; + text = '' + scrot -ozs /tmp/sc.png + xclip -t "image/png" -sel clip -i < /tmp/sc.png + ''; + }); + +} diff --git a/scripts/clip.nix b/scripts/clip.nix new file mode 100644 index 0000000..9ffea69 --- /dev/null +++ b/scripts/clip.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: with pkgs; { + + # Copy something to the clipboard + c = (writeShellApplication { + name = "c"; + runtimeInputs = [ xclip ]; + text = "xclip -sel clip -i"; + }); + + # Paste something from the clipboard + p = (writeShellApplication { + name = "p"; + runtimeInputs = [ xclip ]; + text = "xclip -sel clip -o"; + }); + +}