This commit is contained in:
Riley Apeldoorn 2022-05-15 18:35:31 +02:00
parent a1a09c4b17
commit 030e457600
8 changed files with 75 additions and 40 deletions

View file

@ -33,8 +33,9 @@ let named = submodule {
misc = mkOption { type = attrsOf str; }; misc = mkOption { type = attrsOf str; };
hex = mkOption { type = themeType; }; hex = mkOption { type = themeType; };
}; };
}; in };
{ scripts = (import ../scripts/clip.nix { inherit pkgs; });
in {
options.riley = with lib; { options.riley = with lib; {
@ -152,8 +153,8 @@ let named = submodule {
# Sike I use kakoune # Sike I use kakoune
":e" = "kak"; ":e" = "kak";
# Launch [A]lacritty # Launch [T]erminal
"a" = "alacritty"; "t" = "alacritty";
# [D]isown # [D]isown
"d" = "disown"; "d" = "disown";

View file

@ -1,33 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, scripts, ... }:
(lib.mkIf (config.riley.gui) { (lib.mkIf (config.riley.gui) {
# Add some shell scripts that abstract away the # Add some shell scripts that abstract away the
# horrible reality that the clipboard is managed by # horrible reality that the clipboard is managed by
# the display server. # the display server.
users.users."riley".packages = with pkgs; [ users.users."riley".packages = with scripts; [ c p ];
(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
'';
})
];
}) })

View file

@ -8,7 +8,7 @@ with lib; {
./pulseaudio.nix ./pulseaudio.nix
./clipboard.nix ./clipboard.nix
./alacritty.nix ./terminal.nix
]; ];

View file

@ -1,10 +1,12 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
let theme = config.riley.theme.hex; let scripts = (import ./scripts.nix);
theme = config.riley.theme.hex;
modifier = "Mod4"; modifier = "Mod4";
terminal = "${pkgs.alacritty}/bin/alacritty";
keybindings = (import ./keybinds.nix { keybindings = (import ./keybinds.nix {
inherit modifier lib pkgs config; inherit modifier lib pkgs config scripts;
directional = { directional = {
left = "H"; left = "H";
@ -24,8 +26,9 @@ let theme = config.riley.theme.hex;
launchers = { launchers = {
browser = "google-chrome-stable"; browser = "google-chrome-stable";
inherit terminal;
}; };
}); });
in in
@ -42,14 +45,12 @@ with lib; (mkIf config.riley.gui {
config = with lib; (rec { config = with lib; (rec {
inherit modifier keybindings; inherit modifier keybindings terminal;
terminal = "${pkgs.alacritty}/bin/alacritty";
colors = { colors = {
focused = rec { focused = rec {
background = theme.background.normal; background = theme.background.normal;
text = theme."red".bright; text = theme."green".bright;
border = background; border = background;
childBorder = border; childBorder = border;
indicator = border; indicator = border;

View file

@ -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; with lib; let mod = modifier;
@ -51,9 +60,9 @@ with lib; let mod = modifier;
); );
# Application launchers # Application launchers
genLaunchers = ({ browser }: { genLaunchers = ({ browser, terminal }: {
"${mod}+Tab" = "exec ${browser}"; "${mod}+Tab" = "exec ${browser}";
"${mod}+Return" = "exec alacritty"; "${mod}+Return" = "exec ${terminal}";
}); });
# Layout manipulation # 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 [ in (mkMerge [
(media { inherit (pkgs) mpc_cli pulseaudio; }) (media { inherit (pkgs) mpc_cli pulseaudio; })
(utils { inherit (scripts) lock sc; })
(genDirectional directional) (genDirectional directional)
(genWorkspaces workspace) (genWorkspaces workspace)

View file

@ -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
'';
});
}

17
scripts/clip.nix Normal file
View file

@ -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";
});
}