nixfiles/home/sway/sway.nix

157 lines
4.5 KiB
Nix
Raw Normal View History

2021-12-21 00:51:20 +00:00
{ config, pkgs, lib, ... }: {
home.sessionVariables = {
XDG_CURRENT_DESKTOP = "sway";
XDG_SESSION_TYPE = "wayland";
WLR_DRM_DEVICES = "/dev/dri/card0";
2021-12-21 15:26:21 +00:00
SDL_VIDEODRIVER = "wayland";
QT_QPA_PLATFORM = "wayland";
QT_WAYLAND_DISABLE_WINDOWDECORATION = 1;
_JAVA_AWT_WM_NONREPARENTING = 1;
};
2021-12-21 15:26:21 +00:00
home.packages = with pkgs; [
grim
slurp
wl-clipboard
jq
wofi
wmctrl
libnotify
light
2021-12-25 17:22:53 +00:00
gobar
2021-12-21 15:26:21 +00:00
];
programs.zsh.profileExtra = ''
# If running from tty1 start sway
if [ "$(tty)" = "/dev/tty1" ]; then
systemctl --user unset-environment \
SWAYSOCK \
I3SOCK \
WAYLAND_DISPLAY \
DISPLAY \
IN_NIX_SHELL \
__HM_SESS_VARS_SOURCED \
GPG_TTY \
NIX_PATH \
SHLVL
exec env --unset=SHLVL systemd-cat -t sway -- sway
fi
'';
2021-12-21 15:26:21 +00:00
programs.mako = {
enable = true;
defaultTimeout = 3000;
};
2021-12-21 12:59:07 +00:00
2021-12-21 15:26:21 +00:00
wayland.windowManager.sway = {
enable = true;
config =
let
2021-12-21 00:51:20 +00:00
terminal = "${pkgs.kitty}/bin/kitty";
menu = "${pkgs.wofi}/bin/wofi -idbt ${pkgs.kitty}/bin/kitty -p '' -W 25%";
cfg = config.wayland.windowManager.sway.config;
2021-12-21 15:26:21 +00:00
in
{
2021-12-21 12:59:07 +00:00
bars = [
2021-12-21 15:26:21 +00:00
{
position = "top";
2021-12-21 12:59:07 +00:00
fonts = {
names = [ "Comic Code" ];
2021-12-25 17:22:53 +00:00
size = 14.0;
2021-12-21 12:59:07 +00:00
};
2021-12-25 17:22:53 +00:00
statusCommand = lib.escapeShellArgs [
#"/home/chaoticryptidz/Projects/gobar/gobar "
"${pkgs.gobar}/bin/gobar"
"cpu\\|mem\\|weather\\(Leighton\\ Buzzard\\)\\|bat\\(BAT0\\)\\|time"
];
2021-12-21 12:59:07 +00:00
}
];
2021-12-21 00:51:20 +00:00
input = {
"*" = {
xkb_layout = "gb";
};
};
fonts = {
names = [ "Comic Code" ];
size = 18.0;
};
2021-12-21 15:26:21 +00:00
2021-12-21 00:51:20 +00:00
modifier = "Mod1";
terminal = "${pkgs.kitty}/bin/kitty";
startup = [
{ command = "systemctl --user restart mako"; always = true; }
];
2021-12-21 15:26:21 +00:00
seat = {
"*" = {
"xcursor_theme" = "Adwaita 24";
};
};
gaps = {
top = 10;
bottom = 10;
left = 10;
right = 10;
inner = 20;
outer = 20;
smartGaps = true;
};
2021-12-21 00:51:20 +00:00
window = {
border = 4;
titlebar = false;
2021-12-21 00:51:20 +00:00
};
keybindings = {
2021-12-21 01:30:26 +00:00
"${cfg.modifier}+Return" = "exec ${cfg.terminal}";
2021-12-21 00:51:20 +00:00
"${cfg.modifier}+Left" = "focus left";
"${cfg.modifier}+Down" = "focus down";
"${cfg.modifier}+Up" = "focus up";
"${cfg.modifier}+Right" = "focus right";
"${cfg.modifier}+Shift+Left" = "move left";
"${cfg.modifier}+Shift+Down" = "move down";
"${cfg.modifier}+Shift+Up" = "move up";
"${cfg.modifier}+Shift+Right" = "move right";
"${cfg.modifier}+Shift+space" = "floating toggle";
"${cfg.modifier}+space" = "focus mode_toggle";
"XF86AudioRaiseVolume" = "exec pactl set-sink-volume $(pacmd list-sinks |awk '/* index:/{print $3}') +5%";
"XF86AudioLowerVolume" = "exec pactl set-sink-volume $(pacmd list-sinks |awk '/* index:/{print $3}') -5%";
"XF86AudioMute" = "exec pactl set-sink-mute $(pacmd list-sinks |awk '/* index:/{print $3}') toggle";
"XF86AudioMicMute" = "exec pactl set-source-mute $(pacmd list-sources |awk '/* index:/{print $3}') toggle";
"XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 5";
"XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5";
"Print" = "exec ${pkgs.grim}/bin/grim -t png - | ${pkgs.wl-clipboard}/bin/wl-copy -t image/png";
"Shift+Print" = "exec ${pkgs.grim}/bin/grim -t png -g \"$(${pkgs.slurp}/bin/slurp -d)\" - | ${pkgs.wl-clipboard}/bin/wl-copy -t image/png";
2021-12-21 00:51:20 +00:00
"${cfg.modifier}+d" = "exec ${cfg.menu}";
"${cfg.modifier}+f" = "fullscreen";
"${cfg.modifier}+Shift+q" = "kill";
"${cfg.modifier}+Shift+c" = "reload";
"${cfg.modifier}+r" = "mode resize";
2021-12-21 15:26:21 +00:00
} // (lib.foldl lib.recursiveUpdate { } (map
(workspace: {
"${cfg.modifier}+${workspace}" = "workspace ${workspace}";
"${cfg.modifier}+Shift+${workspace}" = "move container to workspace ${workspace}";
}) [ "1" "2" "3" "4" "5" "6" "7" "8" "9" ]));
2021-12-21 00:51:20 +00:00
};
2021-12-21 15:26:21 +00:00
wrapperFeatures.gtk = true;
extraConfig = ''
bindswitch --reload --locked lid:on output eDP-1 disable
bindswitch --reload --locked lid:off output eDP-1 enable
'';
};
2021-12-21 00:51:20 +00:00
}