194 lines
4.5 KiB
Nix
194 lines
4.5 KiB
Nix
{ pkgs, config, lib, ... }:
|
|
|
|
let theme = (import ./colors.nix)."dark";
|
|
hex = (c: "#${c}");
|
|
|
|
# Keybinds that launch an application.
|
|
launchers = ({ browser }: mod: {
|
|
"${mod}+Tab" = "exec ${browser}";
|
|
});
|
|
|
|
# Keybinds generated from a set of workspaces.
|
|
workspace = ({ numbered ? 0, named ? {} }: mod: with lib;
|
|
let nums = genAttrs (map toString (range 1 numbered)) id;
|
|
workspaces = named // nums;
|
|
genBinds = (n: k: {
|
|
|
|
# Focus the workspace
|
|
"${mod}+${k}" = "workspace ${n}";
|
|
|
|
# Move a window to the workspace
|
|
"${mod}+Shift+${k}" = "move window to workspace ${n}";
|
|
|
|
});
|
|
keybinds = mapAttrsToList genBinds workspaces; in
|
|
mkMerge (keybinds)
|
|
);
|
|
|
|
# Layout manipulation keybinds.
|
|
layout = (mod: {
|
|
|
|
"${mod}+A" = "split v";
|
|
"${mod}+S" = "split h";
|
|
|
|
"${mod}+F" = "fullscreen toggle";
|
|
|
|
});
|
|
|
|
# Directional keys are used for basic navigation.
|
|
directional = ({ left, right, up, down }: mod: {
|
|
|
|
# Change window focus
|
|
"${mod}+${left}" = "focus left";
|
|
"${mod}+${down}" = "focus down";
|
|
"${mod}+${up}" = "focus up";
|
|
"${mod}+${right}" = "focus right";
|
|
|
|
# Move windows
|
|
"${mod}+Shift+${left}" = "move left";
|
|
"${mod}+Shift+${down}" = "move down";
|
|
"${mod}+Shift+${up}" = "move up";
|
|
"${mod}+Shift+${right}" = "move right";
|
|
|
|
});
|
|
|
|
# Media controls.
|
|
media = ({ mpc ? null }: mod:
|
|
if (mpc != null)
|
|
then (let cmd = "${mpc}/bin/${mpc.pname}"; in {
|
|
"${mod}+comma" = "exec ${cmd} prev";
|
|
"${mod}+period" = "exec ${cmd} next";
|
|
"${mod}+slash" = "exec ${cmd} toggle";
|
|
})
|
|
else {}
|
|
);
|
|
|
|
# Utility scripts and such.
|
|
scripts = (mod: {}); in
|
|
|
|
{
|
|
|
|
services.xserver = {
|
|
enable = true;
|
|
windowManager.i3 = {
|
|
enable = true;
|
|
package = pkgs.i3; #-gaps;
|
|
};
|
|
};
|
|
|
|
home-manager.users."riley" =
|
|
let browser = pkgs.google-chrome;
|
|
term = pkgs.alacritty; in
|
|
{
|
|
|
|
home.packages = with pkgs; [
|
|
|
|
tdesktop
|
|
|
|
xclip
|
|
|
|
# Paste from clipboard
|
|
(writeShellApplication {
|
|
name = "xc.p";
|
|
runtimeInputs = [ xclip ];
|
|
text = "xclip -sel clip -o";
|
|
})
|
|
|
|
# Copy to clipboard
|
|
(writeShellApplication {
|
|
name = "xc.c";
|
|
runtimeInputs = [ xclip ];
|
|
text = "xclip -sel clip -i";
|
|
})
|
|
|
|
# Copy to clipboard with given mime type
|
|
(writeShellApplication {
|
|
name = "xc.t";
|
|
runtimeInputs = [ xclip ];
|
|
text = "xclip -sel clip -t \"$1\" -i";
|
|
})
|
|
|
|
] ++ [
|
|
term
|
|
browser
|
|
];
|
|
|
|
xsession.windowManager.i3 = {
|
|
enable = true;
|
|
|
|
package = pkgs.i3;
|
|
|
|
config = with lib; (rec {
|
|
|
|
modifier = "Mod4";
|
|
terminal = "${term}/bin/${term.pname}";
|
|
|
|
# Apply the modifier key to each of the keybinding generator functions
|
|
# and merge the resulting sets.
|
|
keybindings = let mod = modifier; in mkMerge (map (f: f (mod)) [
|
|
(mod: {
|
|
"${mod}+Return" = "exec ${terminal}";
|
|
"${mod}+BackSpace" = "kill";
|
|
})
|
|
(directional {
|
|
left = "H";
|
|
right = "L";
|
|
down = "J";
|
|
up = "K";
|
|
})
|
|
(workspace {
|
|
numbered = 5;
|
|
named = {
|
|
"dev" = "0";
|
|
"doc" = "minus";
|
|
"net" = "equal";
|
|
};
|
|
})
|
|
(launchers {
|
|
browser = "google-chrome-stable";
|
|
})
|
|
layout
|
|
(media {
|
|
mpc = pkgs.mpc_cli;
|
|
})
|
|
scripts
|
|
]);
|
|
|
|
colors = {
|
|
focused = rec {
|
|
background = hex (theme.background.normal);
|
|
text = hex (theme."red".bright);
|
|
border = background;
|
|
childBorder = border;
|
|
indicator = border;
|
|
};
|
|
unfocused = rec {
|
|
background = hex (theme.background.normal);
|
|
text = hex (theme.foreground.slight);
|
|
border = background;
|
|
childBorder = border;
|
|
indicator = border;
|
|
};
|
|
focusedInactive = colors.unfocused;
|
|
};
|
|
|
|
window = {
|
|
border = 2;
|
|
commands = [
|
|
{ command = "border pixel 2"; criteria = { class = ".*"; }; }
|
|
];
|
|
};
|
|
|
|
fonts = {
|
|
names = [ "Source Sans 3" ];
|
|
style = "Semibold";
|
|
size = 10.0;
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|