rice/programs/sway.nix

216 lines
6.4 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
browser = "firefox";
2022-07-22 20:42:05 +00:00
mod = "Mod4";
2022-12-02 13:58:25 +00:00
terminal = "foot";
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_layout = "us,apl";
xkb_variant = ",dyalog";
xkb_options = "grp:switch,compose:prsc";
};
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;
};
2022-12-20 13:58:08 +00:00
keybindings = let
swaylockConf = pkgs.writeText "swaylock.conf" ''
ignore-empty-password
color=${theme.primary.background}
bs-hl-color=${theme.normal.red}
caps-lock-bs-hl-color=${theme.normal.red}
caps-lock-key-hl-color=${theme.bright.green}
inside-color=${theme.primary.background}
inside-clear-color=${theme.normal.yellow}
inside-caps-lock-color=${theme.primary.background}
inside-ver-color=${theme.normal.blue}
inside-wrong-color=${theme.normal.red}
key-hl-color=${theme.bright.green}
ring-color=${theme.normal.green}
ring-clear-color=${theme.normal.yellow}
ring-caps-lock-color=${theme.bright.yellow}
ring-ver-color=${theme.bright.blue}
ring-wrong-color=${theme.bright.red}
'';
in
2022-07-22 20:42:05 +00:00
{
"${mod}+Shift+c" = "kill";
"${mod}+Control+r" = "reload";
"${mod}+Shift+e" = "exit";
"${mod}+Shift+Return" = "exec ${terminal}";
"${mod}+i" = "exec ${browser}";
"${mod}+Shift+y" = "exec ${pkgs.swaylock}/bin/swaylock -C '${swaylockConf}'";
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
'';
}
];
};
2023-03-24 11:31:44 +00:00
2023-03-24 11:32:37 +00:00
extraConfig = ''
for_window [title="leftovers"] floating enable
'';
2022-07-22 20:42:05 +00:00
};
};
2022-09-12 18:35:15 +00:00
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
];
};
2022-07-22 20:42:05 +00:00
}