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

View File

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

View File

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

View File

@ -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;

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

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