rice/programs/sway.nix

180 lines
5.2 KiB
Nix
Raw Normal View History

2022-07-22 20:42:05 +00:00
{
pkgs,
lib,
...
}: {
programs.sway.enable = true;
home-manager.users.buffet = {
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
xwayland = false;
config = let
2022-08-23 20:53:09 +00:00
browser = "chromium";
2022-07-22 20:42:05 +00:00
mod = "Mod4";
terminal = "alacritty";
2022-08-13 23:50:02 +00:00
theme = import ../theme.nix;
2022-07-22 20:42:05 +00:00
makeWorkspaceBinds = num: let
ws = toString num;
in {
"${mod}+${ws}" = "workspace ${ws}";
"${mod}+Shift+${ws}" = "move container to workspace ${ws}";
};
joinAttrSets = builtins.foldl' (x: y: x // y) {};
statusCommand = pkgs.writeScript "status_command" ''
#!/bin/sh
while :; do
energy_full=
energy_now=
charge=
for bat in /sys/class/power_supply/*/capacity; do
bat="''${bat%/*}"
read -r full < $bat/energy_full
read -r now < $bat/energy_now
energy_full=$((energy_full + full))
energy_now=$((energy_now + now))
done
if cat /sys/class/power_supply/*/status | grep -q Charging; then
charge=+
fi
printf '%s %s ' "$charge$((energy_now * 100 / energy_full))%" "$(date +'%H:%M')"
sleep 3
done
'';
in {
modifier = mod;
window.border = 1;
focus.followMouse = true;
fonts = {
2022-08-13 23:50:02 +00:00
names = [theme.font.family];
2022-07-22 20:42:05 +00:00
style = "Regular";
2022-08-13 23:50:02 +00:00
size = theme.font.size * 1.0;
2022-07-22 20:42:05 +00:00
};
gaps = {
inner = 5;
outer = 0;
};
input."*" = {xkb_options = "compose:ralt";};
2022-08-13 23:50:02 +00:00
output."*" = {bg = "${theme.primary.background} solid_color";};
2022-07-22 20:42:05 +00:00
2022-08-13 23:50:02 +00:00
colors = with theme; rec {
2022-07-22 20:42:05 +00:00
focused = rec {
inherit (wm.focused) border text;
inherit (primary) background;
indicator = border;
childBorder = border;
};
unfocused = rec {
inherit (wm.unfocused) border text;
inherit (primary) background;
indicator = border;
childBorder = border;
};
focusedInactive = unfocused;
};
keybindings =
{
"${mod}+Shift+c" = "kill";
"${mod}+Control+r" = "reload";
"${mod}+Shift+e" = "exit";
"${mod}+Shift+Return" = "exec ${terminal}";
"${mod}+i" = "exec ${browser}";
2022-08-13 23:50:02 +00:00
"${mod}+Shift+y" = "exec ${pkgs.swaylock}/bin/swaylock -ec '${theme.primary.background}'";
2022-07-22 20:42:05 +00:00
"${mod}+z" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 1%-";
"${mod}+x" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 1%+";
"${mod}+Shift+z" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 5%-";
"${mod}+Shift+x" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 5%+";
2022-08-16 20:02:44 +00:00
"${mod}+p" = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot copy window";
"${mod}+Shift+p" = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot copy active";
2022-07-22 20:42:05 +00:00
"${mod}+o" = "splith";
"${mod}+u" = "splitv";
"${mod}+s" = "layout stacking";
"${mod}+t" = "layout tabbed";
"${mod}+e" = "layout toggle split";
"${mod}+f" = "fullscreen";
"${mod}+h" = "focus left";
"${mod}+j" = "focus down";
"${mod}+k" = "focus up";
"${mod}+l" = "focus right";
"${mod}+Left" = "focus left";
"${mod}+Down" = "focus down";
"${mod}+Up" = "focus up";
"${mod}+Right" = "focus right";
"${mod}+Shift+h" = "move left";
"${mod}+Shift+j" = "move down";
"${mod}+Shift+k" = "move up";
"${mod}+Shift+l" = "move right";
"${mod}+Ctrl+h" = "resize grow left 10 px or 10 ppt";
"${mod}+Ctrl+j" = "resize grow down 10 px or 10 ppt";
"${mod}+Ctrl+k" = "resize grow up 10 px or 10 ppt";
"${mod}+Ctrl+l" = "resize grow right 10 px or 10 ppt";
"${mod}+space" = "focus mode_toggle";
"${mod}+a" = "focus parent";
"${mod}+Shift+space" = "floating toggle";
}
// (joinAttrSets (map makeWorkspaceBinds (lib.range 1 9)));
2022-08-16 13:13:39 +00:00
seat."*" = {hide_cursor = "when-typing enable";};
2022-08-14 17:08:24 +00:00
2022-07-22 20:42:05 +00:00
bars = [
{
position = "top";
fonts = {
2022-08-13 23:50:02 +00:00
names = [theme.font.family];
2022-07-22 20:42:05 +00:00
style = "Regular";
2022-08-13 23:50:02 +00:00
size = theme.font.size * 1.0;
2022-07-22 20:42:05 +00:00
};
statusCommand = "${statusCommand}";
2022-08-13 23:50:02 +00:00
colors = with theme; {
2022-07-22 20:42:05 +00:00
statusline = primary.foreground;
inherit (primary) background;
focusedWorkspace = {
inherit (primary) background;
inherit (wm.focused) text;
2022-08-21 14:56:14 +00:00
inherit (wm.focused) border;
2022-07-22 20:42:05 +00:00
};
inactiveWorkspace = {
inherit (primary) background;
inherit (wm.unfocused) text;
border = primary.background;
};
};
extraConfig = ''
gaps 5
'';
}
];
};
};
};
}