nixos-config/modules/workstation/home-manager/desktop/sway.nix

247 lines
8 KiB
Nix
Raw Normal View History

2023-12-22 23:18:58 +01:00
{ config, pkgs, lib, keymap, ... }:
with lib;
let
2023-12-22 23:18:58 +01:00
isQwerty = keymap == "us";
gnomeSchema = "org.gnome.desktop.interface";
monitorModule = types.submodule {
options = {
name = mkOption {
type = types.str;
};
resolution = mkOption {
type = types.str;
};
position = mkOption {
type = types.str;
};
defaultWorkspace = mkOption {
type = types.int;
};
};
};
in
{
options = {
desktop.monitors = mkOption {
type = types.listOf monitorModule;
};
};
config.wayland.windowManager.sway = mkIf config.desktop.enableSwayStack {
enable = true;
#systemd.enable = false;
config = rec {
modifier = "Mod4";
left = "left";
right = "right";
up = "up";
down = "down";
terminal = "${pkgs.alacritty}/bin/alacritty";
menu = "${pkgs.wofi}/bin/wofi --show drun,run";
fonts = {
names = [ "pango:JetBrainsMono Nerd Font Mono" ];
size = 11.0;
};
input = {
"*" = {
2023-12-22 23:18:58 +01:00
xkb_layout = keymap;
xkb_options = mkIf isQwerty "compose:ralt";
};
};
seat = {
"seat0" = {
"xcursor_theme" = "Nordzy-cursors";
};
};
output = builtins.listToAttrs
(builtins.map
(monitor: {
name = monitor.name;
value = {
resolution = monitor.resolution;
position = monitor.position;
};
})
config.desktop.monitors) // {
"*".bg = "/home/dala/Perso/wallpapers/tanuki.jpg fill";
};
workspaceOutputAssign = map
(monitor: {
output = monitor.name;
workspace = builtins.toString monitor.defaultWorkspace;
})
config.desktop.monitors;
startup = [
{
command = ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 1200 '${pkgs.swaylock}/bin/swaylock -f' \
timeout 1800 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
before-sleep '${pkgs.swaylock}/bin/swaylock -f'
'';
}
{ command = "${pkgs.nextcloud-client}/bin/nextcloud --background"; }
{ command = "${pkgs.keepassxc}/bin/keepassxc"; }
{
command = ''
${pkgs.wl-clipboard}/bin/wl-paste -t text --watch ${pkgs.clipman}/bin/clipman store --no-persist
'';
}
{
command = "${pkgs.glib}/bin/gsettings set ${gnomeSchema} gtk-theme 'Nordic'";
always = true;
}
{
command = "${pkgs.glib}/bin/gsettings set ${gnomeSchema} cursor-theme 'Nordzy-cursors'";
always = true;
}
{
command = "${pkgs.glib}/bin/gsettings set ${gnomeSchema} font-name 'JetBrainsMono Nerd Font Mono'";
always = true;
}
];
modes = {
resize = {
"Left" = "resize shrink width 10px";
"Down" = "resize grow height 10px";
"Up" = "resize shrink height 10px";
"Right" = "resize grow width 10px";
"Return" = "mode default";
"Escape" = "mode default";
};
};
gaps = {
inner = 5;
smartGaps = true;
};
floating = {
modifier = "${modifier} normal";
};
bars = [{
command = "${pkgs.waybar}/bin/waybar";
}];
keybindings = {
"${modifier}+Return" = "exec ${terminal}";
"${modifier}+Shift+q" = "kill";
"${modifier}+d" = "exec ${menu}";
"${modifier}+Shift+r" = "reload";
"${modifier}+Shift+e" = "exec swaymsg exit";
"${modifier}+Shift+l" = "exec swaylock -f";
"${modifier}+Left" = "focus left";
"${modifier}+Down" = "focus down";
"${modifier}+Up" = "focus up";
"${modifier}+Right" = "focus right";
"${modifier}+Shift+Left" = "move left";
"${modifier}+Shift+Down" = "move down";
"${modifier}+Shift+Up" = "move up";
"${modifier}+Shift+Right" = "move right";
"${modifier}+1" = "workspace 1";
"${modifier}+2" = "workspace 2";
"${modifier}+3" = "workspace 3";
"${modifier}+4" = "workspace 4";
"${modifier}+5" = "workspace 5";
"${modifier}+6" = "workspace 6";
"${modifier}+7" = "workspace 7";
"${modifier}+8" = "workspace 8";
"${modifier}+9" = "workspace 9";
"${modifier}+0" = "workspace 10";
"${modifier}+ampersand" = "workspace 1";
"${modifier}+eacute" = "workspace 2";
"${modifier}+quotedbl" = "workspace 3";
"${modifier}+apostrophe" = "workspace 4";
"${modifier}+parenleft" = "workspace 5";
"${modifier}+minus" = "workspace 6";
"${modifier}+egrave" = "workspace 7";
"${modifier}+underscore" = "workspace 8";
"${modifier}+ccedilla" = "workspace 9";
"${modifier}+agrave" = "workspace 10";
"${modifier}+Shift+1" = "move container to workspace 1";
"${modifier}+Shift+2" = "move container to workspace 2";
"${modifier}+Shift+3" = "move container to workspace 3";
"${modifier}+Shift+4" = "move container to workspace 4";
"${modifier}+Shift+5" = "move container to workspace 5";
"${modifier}+Shift+6" = "move container to workspace 6";
"${modifier}+Shift+7" = "move container to workspace 7";
"${modifier}+Shift+8" = "move container to workspace 8";
"${modifier}+Shift+9" = "move container to workspace 9";
"${modifier}+Shift+0" = "move container to workspace 10";
"${modifier}+Shift+ampersand" = "move container to workspace 1";
"${modifier}+Shift+eacute" = "move container to workspace 2";
"${modifier}+Shift+quotedbl" = "move container to workspace 3";
"${modifier}+Shift+apostrophe" = "move container to workspace 4";
"${modifier}+Shift+parenleft" = "move container to workspace 5";
"${modifier}+Shift+minus" = "move container to workspace 6";
"${modifier}+Shift+egrave" = "move container to workspace 7";
"${modifier}+Shift+underscore" = "move container to workspace 8";
"${modifier}+Shift+ccedilla" = "move container to workspace 9";
"${modifier}+Shift+agrave" = "move container to workspace 10";
"${modifier}+h" = "splith";
"${modifier}+v" = "splitv";
"${modifier}+s" = "layout stacking";
"${modifier}+w" = "layout tabbed";
"${modifier}+e" = "layout toggle split";
"${modifier}+f" = "fullscreen";
"${modifier}+Shift+space" = "floating toggle";
"${modifier}+space" = "focus mode_toggle";
"${modifier}+a" = "focus parent";
"${modifier}+Shift+parenright" = "move scratchpad";
"${modifier}+parenright" = "scratchpad show";
"${modifier}+r" = "mode resize";
"XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume 0 +5%"; #increase sound volume
"XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume 0 -5%"; #decrease sound volume
"XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute 0 toggle"; # mute sound
"XF86MonBrightnessUp" = "exec --no-startup-id light -A 10";
"XF86MonBrightnessDown" = "exec --no-startup-id light -U 10";
"Control+XF86AudioMute" = "exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"Print" = "exec grim -g \"$(${pkgs.slurp}/bin/slurp)\" -t png - | wl-copy --type image/png";
};
};
extraConfig = ''
default_border pixel
for_window [class=".*"] inhibit_idle fullscreen
for_window [app_id=".*"] inhibit_idle fullscreen
'';
extraSessionCommands = ''
export WLR_NO_HARDWARE_CURSORS=1
export XDG_CURRENT_DESKTOP=sway
export _JAVA_AWT_WM_NONREPARENTING=1
export NIXOS_OZONE_WL=1
export QT_QPA_PLATFORM=wayland
export QT_QPA_PLATFORMTHEME=qt5ct
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
export MOZ_ENABLE_WAYLAND=1
export SDL_VIDEODRIVER=wayland
'';
};
}