nixos-config/home-manager/modules/sway/default.nix

296 lines
10 KiB
Nix
Raw Normal View History

2021-11-12 17:10:17 +01:00
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.eboskma.programs.sway;
mod = "Mod4";
2021-11-21 19:07:12 +01:00
swaylockcmd = "${pkgs.swaylock-effects}/bin/swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --clock --image ~/.wallpapers/river-2560.png --fade-in 0.5 --scaling fill";
2022-02-03 22:57:53 +01:00
# swaylockcmd = "${pkgs.swaylock}/bin/swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image ~/.wallpapers/river-2560.png --scaling fill";
2021-11-22 08:04:54 +01:00
rofiPower = pkgs.writeShellScriptBin "rofi-power" (builtins.readFile ./powermenu.sh);
2021-11-12 17:10:17 +01:00
in
{
options.eboskma.programs.sway.enable = mkEnableOption "Enable sway";
config = mkIf cfg.enable {
wayland.windowManager.sway = {
enable = true;
config = {
modifier = mod;
assigns = {
"1" = [{ app_id = "firefox"; }];
"2" = [{ app_id = "Alacritty"; } { app_id = "foot"; }];
2021-11-12 17:10:17 +01:00
"3" = [{ class = "Code"; }];
"10" = [{ class = "telegramdesktop"; } { app_id = "Signal"; }];
2021-11-12 17:10:17 +01:00
};
bars = [
{
command = "${pkgs.waybar}/bin/waybar";
}
];
2021-12-18 16:23:14 +01:00
# Dracula theme
colors = {
background = "#f8f8f2";
focused = {
border = "#6272a4";
background = "#6272A4";
text = "#f8f8f2";
indicator = "#6272a4";
childBorder = "#6272a4";
};
focusedInactive = {
border = "#44475a";
background = "#44475a";
text = "#f8f8f2";
indicator = "#44475a";
childBorder = "#44475a";
};
unfocused = {
border = "#282a36";
background = "#282a36";
text = "#bfbfbf";
indicator = "#282a36";
childBorder = "#282a36";
};
urgent = {
border = "#44475a";
background = "#ff5555";
text = "#f8f8f2";
indicator = "#ff5555";
childBorder = "#ff5555";
};
placeholder = {
border = "#282a36";
background = "#282a36";
text = "#f8f8f2";
indicator = "#282a36";
childBorder = "#282a36";
};
};
defaultWorkspace = "workspace number 1";
2021-11-12 17:10:17 +01:00
left = "n";
down = "e";
up = "i";
right = "o";
floating = {
criteria = [{ app_id = "gnome-calculator"; }];
modifier = mod;
};
fonts = {
names = [ "Iosevka Nerd Font" ];
style = "Regular";
size = 12.0;
};
gaps = {
inner = 10;
outer = 5;
smartBorders = "on";
};
input = {
"36125:40349:splitKB_Kyria" = {
2021-11-25 17:18:13 +01:00
xkb_layout = "us";
xkb_options = "lv3:ralt_switch,eurosign:5";
2021-11-12 17:10:17 +01:00
};
"1133:49291:Logitech_G502_HERO_SE" = {
natural_scroll = "enabled";
};
};
output = {
"Virtual-1" = {
bg = "~/.wallpapers/river-1920.png fill";
mode = "1920x1080@60Hz";
};
"DP-2" = {
bg = "~/.wallpapers/river-2560.png fill";
mode = "2560x1440@144Hz";
adaptive_sync = "on";
};
};
2021-11-22 08:04:54 +01:00
# menu = "${pkgs.wofi}/bin/wofi --show drun -i | ${pkgs.findutils}/bin/xargs swaymsg exec --";
menu = "${pkgs.rofi}/bin/rofi -show drun -no-lazy-grab";
2021-11-12 17:10:17 +01:00
keybindings = {
"${mod}+Return" = "exec ${config.wayland.windowManager.sway.config.terminal}";
"${mod}+Shift+q" = "kill";
"${mod}+s" = "exec ${config.wayland.windowManager.sway.config.menu}";
"${mod}+Shift+s" = "exec ${pkgs.wofi}/bin/wofi --show run | ${pkgs.findutils}/bin/xargs swaymsg exec --";
"${mod}+${config.wayland.windowManager.sway.config.left}" = "focus left";
"${mod}+${config.wayland.windowManager.sway.config.down}" = "focus down";
"${mod}+${config.wayland.windowManager.sway.config.up}" = "focus up";
"${mod}+${config.wayland.windowManager.sway.config.right}" = "focus right";
"${mod}+Left" = "focus left";
"${mod}+Down" = "focus down";
"${mod}+Up" = "focus up";
"${mod}+Right" = "focus right";
"${mod}+Shift+${config.wayland.windowManager.sway.config.left}" = "move left";
"${mod}+Shift+${config.wayland.windowManager.sway.config.down}" = "move down";
"${mod}+Shift+${config.wayland.windowManager.sway.config.up}" = "move up";
"${mod}+Shift+${config.wayland.windowManager.sway.config.right}" = "move right";
"${mod}+Shift+Left" = "move left";
"${mod}+Shift+Down" = "move down";
"${mod}+Shift+Up" = "move up";
"${mod}+Shift+Right" = "move right";
"${mod}+h" = "split h";
"${mod}+v" = "split v";
"${mod}+t" = "fullscreen toggle";
"${mod}+a" = "focus parent";
"${mod}+r" = "layout stacking";
"${mod}+w" = "layout tabbed";
"${mod}+f" = "layout toggle split";
"${mod}+Shift+space" = "floating toggle";
"${mod}+space" = "focus mode_toggle";
"${mod}+1" = "workspace number 1";
"${mod}+2" = "workspace number 2";
"${mod}+3" = "workspace number 3";
"${mod}+4" = "workspace number 4";
"${mod}+5" = "workspace number 5";
"${mod}+6" = "workspace number 6";
"${mod}+7" = "workspace number 7";
"${mod}+8" = "workspace number 8";
"${mod}+9" = "workspace number 9";
2021-12-06 09:58:39 +01:00
"${mod}+0" = "workspace number 10";
2021-11-12 17:10:17 +01:00
"${mod}+Shift+1" =
"move container to workspace number 1";
"${mod}+Shift+2" =
"move container to workspace number 2";
"${mod}+Shift+3" =
"move container to workspace number 3";
"${mod}+Shift+4" =
"move container to workspace number 4";
"${mod}+Shift+5" =
"move container to workspace number 5";
"${mod}+Shift+6" =
"move container to workspace number 6";
"${mod}+Shift+7" =
"move container to workspace number 7";
"${mod}+Shift+8" =
"move container to workspace number 8";
"${mod}+Shift+9" =
"move container to workspace number 9";
2021-12-06 09:58:39 +01:00
"${mod}+Shift+0" =
"move container to workspace number 10";
2021-11-12 17:10:17 +01:00
"${mod}+Shift+minus" = "move scratchpad";
"${mod}+minus" = "scratchpad show";
"${mod}+Shift+c" = "reload";
2021-11-22 08:04:54 +01:00
"${mod}+Shift+f" = "exec --no-startup-id ${rofiPower}/bin/rofi-power";
2021-11-12 17:10:17 +01:00
"${mod}+l" = "exec ${swaylockcmd}";
"${mod}+p" = "mode resize";
2021-11-18 15:02:12 +01:00
"${mod}+Print" = "exec ${pkgs.grim}/bin/grim -o $(${pkgs.sway}/bin/swaymsg -t get_outputs | ${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .name')";
"${mod}+Shift+Print" = "exec ${pkgs.grim}/bin/grim -o $(${pkgs.sway}/bin/swaymsg -t get_outputs | ${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .name') - | ${pkgs.wl-clipboard}/bin/wl-copy -t \"image/png\" -f";
"${mod}+Shift+Ctrl+Print" = "exec ${pkgs.grim}/bin/grim -g \"$(${pkgs.slurp}/bin/slurp)\" - | ${pkgs.wl-clipboard}/bin/wl-copy -t \"image/png\" -f";
"${mod}+Shift+Alt+Print" = "exec ${pkgs.grim}/bin/grim -g \"$(${pkgs.slurp}/bin/slurp)\"";
2021-11-12 17:10:17 +01:00
2021-11-25 17:18:13 +01:00
"XF86AudioRaiseVolume" = "exec ${pkgs.pamedia}/bin/pamedia up";
"XF86AudioLowerVolume" = "exec ${pkgs.pamedia}/bin/pamedia down";
"XF86AudioMute" = "exec ${pkgs.pamedia}/bin/pamedia mute";
2021-11-12 17:10:17 +01:00
"XF86Calculator" = "exec ${pkgs.gnome.gnome-calculator}/bin/gnome-calculator";
};
# terminal = "${pkgs.alacritty}/bin/alacritty";
terminal = "${pkgs.foot}/bin/foot";
2021-11-12 17:10:17 +01:00
window = {
border = 1;
titlebar = false;
};
workspaceAutoBackAndForth = true;
};
extraConfig = ''
assign [app_id="firefox"] 1
assign [app_id="Alacritty"] 2
assign [app_id="Code"] 3
assign [app_id="telegramdesktop"] 10
assign [app_id="Signal"] 10
for_window [app_id="^.*"] inhibit_idle fullscreen
for_window [class="^.*"] inhibit_idle fullscreen
for_window [app_id="gnome-calculator"] floating enable
2021-12-06 09:58:39 +01:00
for_window [shell="xwayland"] title_format "%title [XWayland]"
2021-11-12 17:10:17 +01:00
exec --no-startup-id ${pkgs.networkmanagerapplet}/bin/nm-applet --indicator
2022-02-02 21:26:10 +01:00
include /etc/sway/config.d/*
2021-11-12 17:10:17 +01:00
'';
# exec --no-startup-id ${pkgs.swayidle}/bin/swayidle -w timeout 900 "${swaylockcmd}"
# exec --no-startup-id ${pkgs.swayidle}/bin/swayidle -w timeout 1200 "${pkgs.sway}/bin/swaymsg 'output * dpms off'" resume "${pkgs.sway}/bin/swaymsg 'output * dpms on'"
# exec_always --no-startup-id systemctl --user import-environment _JAVA_AWT_WM_NONREPARENTING MOZ_ENABLE_WAYLAND MOZ_DBUS_REMOTE QT_QPA_PLATFORM QT_WAYLAND_DISABLE_WINDOWDECORATION QT_QPA_PLATFORMTHEME SDL_VIDEODRIVER SSH_AUTH_SOCK
# exec_always --no-startup-id dbus-update-activation-environment --systemd _JAVA_AWT_WM_NONREPARENTING MOZ_ENABLE_WAYLAND MOZ_DBUS_REMOTE QT_QPA_PLATFORM QT_WAYLAND_DISABLE_WINDOWDECORATION QT_QPA_PLATFORMTHEME SDL_VIDEODRIVER SSH_AUTH_SOCK
2021-11-18 15:02:12 +01:00
# extraSessionCommands =
# ''
# export _JAVA_AWT_WM_NONREPARENTING=1
# export MOZ_ENABLE_WAYLAND=1
# export MOZ_DBUS_REMOTE=1
# export QT_QPA_PLATFORM=wayland
# export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
# export QT_QPA_PLATFORMTHEME=qt5ct
# export SDL_VIDEODRIVER=wayland
# export SSH_AUTH_SOCK="''${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh"
# '';
2021-11-18 15:02:12 +01:00
wrapperFeatures = {
base = true;
gtk = true;
};
xwayland = true;
systemdIntegration = false;
2021-11-18 15:02:12 +01:00
};
home = {
file.".wallpapers".source = ./wallpapers;
packages = with pkgs; [
dunst
2022-02-03 22:57:53 +01:00
# swayidle
# swaylock-effects
2021-11-18 15:02:12 +01:00
];
};
services = {
swayidle = {
enable = true;
events = [
{ event = "after-resume"; command = "${pkgs.sway}/bin/swaymsg 'output * dpms on'"; }
];
timeouts = [
{ timeout = 900; command = swaylockcmd; }
{ timeout = 1200; command = "${pkgs.sway}/bin/swaymsg 'output * dpms off'"; }
];
};
};
2021-11-18 15:02:12 +01:00
systemd.user.targets.tray = {
Unit = {
Description = "Home Manager System Tray";
Requires = [ "graphical-session-pre.target" ];
};
2021-11-12 17:10:17 +01:00
};
};
}