nixos-config/modules/wm/sway/home.nix

333 lines
12 KiB
Nix
Raw Normal View History

2022-10-31 10:05:30 +01:00
#
2022-10-31 16:46:15 +01:00
# Sway NixOS & Home manager configuration
2022-10-31 10:05:30 +01:00
#
# flake.nix
# ├─ ./hosts
# │ └─ ./laptop
# │ └─ home.nix
# └─ ./modules
# └─ ./desktop
2022-10-31 16:46:15 +01:00
# └─ ./sway
2022-10-31 10:05:30 +01:00
# └─ home.nix *
#
{ config, lib, pkgs, ... }:
{
2023-01-28 16:20:22 +01:00
home.file.".config/sway/scripts/2in1screen".source = ../scripts/2in1screen;
2022-10-31 10:05:30 +01:00
wayland.windowManager.sway = {
2022-10-31 16:46:15 +01:00
enable = true;
2024-06-03 20:24:22 +02:00
checkConfig = false;
2022-10-31 16:46:15 +01:00
config = rec {
2024-08-11 19:44:14 +02:00
menu = "${pkgs.rofi}/bin/rofi -show combi -show-icons";
2022-11-06 12:51:13 +01:00
left = "m";
2022-10-31 16:46:15 +01:00
down = "n";
up = "e";
right = "i";
modifier = "Mod4";
2022-11-01 22:46:22 +01:00
floating.modifier = "Mod4";
floating.titlebar = true;
2022-10-31 10:05:30 +01:00
input = {
2022-10-31 16:46:15 +01:00
"type:keyboard" = {
2024-08-10 06:09:33 +02:00
xkb_layout = "us,de";
xkb_variant = "altgr-intl,";
xkb_options = "grp:win_space_toggle";
2022-10-31 10:05:30 +01:00
};
2022-10-31 16:46:15 +01:00
"type:touchpad" = {
tap = "enabled";
natural_scroll = "disabled";
drag = "enabled";
dwt = "enabled";
middle_emulation = "enabled";
scroll_method = "two_finger";
tap_button_map = "lmr";
2022-10-31 10:05:30 +01:00
};
};
output = {
2022-10-31 16:46:15 +01:00
"*" = {
bg = "$HOME/.config/wall fill";
2022-10-31 10:05:30 +01:00
};
#"HDMI-A-1" = {
# mode = "2560x1440";
# pos = "0,0";
# #scale = "1.1";
#};
"DP-2" = {
mode = "2560x1440";
2022-11-02 10:56:48 +01:00
pos = "0,0";
2022-10-31 16:46:15 +01:00
};
"DP-3" = {
mode = "1920x1200";
2024-08-11 19:44:14 +02:00
pos = "2560,180";
2022-10-31 10:05:30 +01:00
};
2022-11-06 12:51:13 +01:00
#"eDP-1" = {
# mode = "1920x1080";
# #pos = "4480,0";
# pos = "2560,0";
# subpixel = "none";
# scale = "1.3";
#};
2022-10-31 10:05:30 +01:00
};
2022-10-31 16:46:15 +01:00
terminal = "${pkgs.alacritty}/bin/alacritty";
2022-10-31 10:05:30 +01:00
2022-10-31 16:46:15 +01:00
fonts = {
2024-05-02 14:16:25 +02:00
names = [ "Cascadia Code" ];
2022-10-31 16:46:15 +01:00
size = 10.0;
};
colors.focused = {
2022-11-06 12:51:13 +01:00
background = "#212121";
2022-10-31 16:46:15 +01:00
border = "#999999";
childBorder = "#999999";
2022-11-06 12:51:13 +01:00
indicator = "#999999";
text = "#FFFFFF";
2022-10-31 16:46:15 +01:00
};
2022-10-31 10:05:30 +01:00
startup = [
{ command = "exec ${pkgs.rot8}/bin/rot8 -Y -k"; }
2022-10-31 16:46:15 +01:00
{ command = "xrdb -load ~/.Xresources"; }
2024-10-05 10:32:00 +02:00
# { command = "gsettings set org.gnome.desktop.interface gtk-theme Dracula"; }
# { command = "gsettings set org.gnome.desktop.interface icon-theme Dracula"; }
# { command = "gsettings set org.gnome.desktop.interface cursor-theme Adwaita"; }
#{ command = "exec ${pkgs.networkmanagerapplet}/bin/nm-applet --indicator"; }
{ command = "${pkgs.thunderbird}/bin/thunderbird"; }
{ command = "${pkgs.firefox}/bin/firefox"; }
2023-01-28 10:10:54 +01:00
{ command = "${pkgs.element-desktop}/bin/element-desktop"; }
2022-10-31 10:05:30 +01:00
];
workspaceAutoBackAndForth = true;
gaps.inner = 8;
gaps.outer = 4;
gaps.smartGaps = true;
gaps.smartBorders = "on";
2022-10-31 10:05:30 +01:00
assigns = {
"workspace number 1" = [{ app_id = "thunderbird"; }];
"workspace number 2" = [{ app_id = "firefox"; }];
"workspace number 3" = [{ class = "Element"; }];
};
2022-10-31 10:05:30 +01:00
window.commands = [
{ command = "floating enable"; criteria = { app_id = ".yubioath-flutter-wrapped"; }; }
{ command = "floating enable"; criteria = { app_id = "pavucontrol"; }; }
{ command = "floating enable"; criteria = { app_id = "galculator"; }; }
{ command = "floating enable"; criteria = { app_id = "com.nitrokey."; }; }
{ command = "floating enable"; criteria = { app_id = "org.keepassxc.KeePassXC."; }; }
{ command = "floating enable"; criteria = { app_id = "virt-manager"; }; }
{ command = "floating enable"; criteria = { title = "^OpenSSH Authentication"; }; }
{ command = "floating enable"; criteria = { class = "pop-up"; }; }
2022-10-31 10:05:30 +01:00
];
2022-10-31 16:46:15 +01:00
bars = [
{ command = "${pkgs.waybar}/bin/waybar"; }
];
2022-10-31 10:05:30 +01:00
2022-10-31 16:46:15 +01:00
defaultWorkspace = "workspace number 2";
2022-10-31 10:05:30 +01:00
2022-11-01 22:46:22 +01:00
keybindings =
let
mod = config.wayland.windowManager.sway.config.modifier;
alt = "Mod1";
left = config.wayland.windowManager.sway.config.left;
down = config.wayland.windowManager.sway.config.down;
up = config.wayland.windowManager.sway.config.up;
right = config.wayland.windowManager.sway.config.right;
in
{
"${mod}+Escape" = "exec swaymsg exit"; # Exit Sway
"${mod}+Return" = "exec ${terminal}"; # Open terminal
"${mod}+d" = "exec ${menu}"; # Open menu
"${mod}+l" = "exec ${pkgs.swaylock}/bin/swaylock"; # Lock Screen
"${mod}+r" = "reload"; # Reload environment
"${mod}+q" = "kill"; # Kill container
"${mod}+Shift+f" = "exec ${pkgs.pcmanfm}/bin/pcmanfm"; # File Manager
"${alt}+${left}" = "workspace prev_on_output"; # Navigate to previous or next workspace on output if it exists
"${alt}+${right}" = "workspace next_on_output";
"${alt}+Shift+${left}" = "move container to workspace prev, workspace prev"; # Move container to next available workspace and focus
"${alt}+Shift+${right}" = "move container to workspace next, workspace next";
"XF86TouchpadToggle" = "input type:touchpad events toggle enabled disabled";
"XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioNext" = "exec playerctl next";
"XF86AudioPrev" = "exec playerctl previous";
"XF86AudioStop" = "exec playerctl stop";
2024-08-11 19:44:14 +02:00
# Sink volume raise optionally with --device
"XF86AudioRaiseVolume" = "exec swayosd-client --output-volume raise";
"XF86AudioLowerVolume" = "exec swayosd-client --output-volume lower";
# Sink volume toggle mute
"XF86AudioMute" = "exec swayosd-client --output-volume mute-toggle";
# Source volume toggle mute
"XF86AudioMicMute" = "exec swayosd-client --input-volume mute-toggle";
# Capslock (If you don't want to use the backend)
#bindsym --release Caps_Lock exec swayosd-client --caps-lock;
# Brightness raise
"XF86MonBrightnessUp" = "exec swayosd-client --brightness raise";
# Brightness lower
"XF86MonBrightnessDown" = "exec swayosd-client --brightness lower";
2022-11-01 22:46:22 +01:00
"${mod}+${left}" = "focus left";
"${mod}+${down}" = "focus down";
"${mod}+${up}" = "focus up";
"${mod}+${right}" = "focus right";
"${mod}+Shift+${left}" = "move left";
"${mod}+Shift+${down}" = "move down";
"${mod}+Shift+${up}" = "move up";
"${mod}+Shift+${right}" = "move right";
"${mod}+${alt}+${left}" = "resize grow width 10px";
"${mod}+${alt}+${down}" = "resize shrink height 10px";
"${mod}+${alt}+${up}" = "resize grow height 10px";
"${mod}+${alt}+${right}" = "resize shrink width 10px";
"${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";
"${mod}+0" = "workspace number 10";
"${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";
"${mod}+Shift+0" = "move container to workspace number 10";
"${mod}+Tab" = "workspace next";
"${mod}+Alt+Tab" = "workspace prev";
2022-11-01 22:46:22 +01:00
"${mod}+k" = "splith";
"${mod}+v" = "splitv";
"${mod}+b" = "layout stacking";
"${mod}+w" = "layout tabbed";
"${mod}+p" = "layout toggle split";
"${mod}+f" = "fullscreen";
"${mod}+Shift+space" = "floating toggle";
2022-11-06 12:51:13 +01:00
"${mod}+h" = "focus mode_toggle";
2022-11-01 22:46:22 +01:00
"${mod}+a" = "focus parent";
"${mod}+Shift+minus" = "move scratchpad";
"${mod}+minus" = "scratchpad show";
2022-10-31 10:05:30 +01:00
};
};
2023-06-23 15:47:12 +02:00
systemd.enable = true;
2022-10-31 10:05:30 +01:00
wrapperFeatures.gtk = true;
2022-10-31 16:46:15 +01:00
extraSessionCommands = ''
export MOZ_ENABLE_WAYLAND="1";
export MOZ_WEBRENDER="1";
export MOZ_USE_XINPUT2="2";
export MOZ_DBUS_REMOTE="1";
2024-09-30 20:59:37 +02:00
export WLR_RENDERER="vulkan";
2022-10-31 16:46:15 +01:00
export LIBVA_DRIVER_NAME="iHD";
export VDPAU_DRIVER="iHD";
export XDG_SESSION_TYPE="wayland";
2022-11-01 22:46:22 +01:00
export XDG_CURRENT_DESKTOP="sway";
2024-10-05 10:32:00 +02:00
#export QT_QPA_PLATFORMTHEME="wayland-egl";
export QT_QPA_PLATFORMTHEME="qt6ct";
2022-10-31 16:46:15 +01:00
export GST_VAAPI_ALL_DRIVERS="1";
export GTK_THEME="Arc";
export _JAVA_AWT_WM_NONREPARENTING="1";
#export LIBCL_ALWAYS_SOFTWARE="1"; # For applications in VM like alacritty to work
#export WLR_NO_HARDWARE_CURSORS="1"; # For cursor in VM
'';
extraConfig = ''
set $output-primary DP-2
set $output-secondary DP-3
workspace 1 output $output-secondary
workspace 2 output $output-primary
workspace 3 output $output-secondary
'';
2022-10-31 10:05:30 +01:00
};
2024-08-11 19:44:14 +02:00
programs = {
swaylock = {
2024-01-13 11:52:35 +01:00
enable = true;
settings = {
color = "000000";
image = "$HOME/.config/lockwall";
indicator-caps-lock = true;
show-keyboard-layout = true;
};
2024-08-11 19:44:14 +02:00
};
rofi = {
enable = true;
package = pkgs.rofi-wayland;
extraConfig = {
modi = "window,drun,ssh";
kb-primary-paste = "Control+V,Shift+Insert";
kb-secondary-paste = "Control+v,Insert";
};
font = "Cascadia Code";
location = "top-left";
plugins = [
pkgs.rofi-calc
pkgs.rofi-bluetooth
pkgs.pinentry-rofi
];
terminal = "${pkgs.alacritty}/bin/alacritty";
2024-10-14 12:16:47 +02:00
theme = "arthur";
2024-08-11 19:44:14 +02:00
};
2022-10-31 10:05:30 +01:00
};
2024-08-11 19:44:14 +02:00
services = {
swayidle = {
enable = true;
events = [
{ event = "before-sleep"; command = "${pkgs.swaylock}/bin/swaylock"; }
{ event = "lock"; command = "${pkgs.swaylock}/bin/swaylock -fF"; }
{ event = "after-resume"; command = "${pkgs.sway}/bin/swaymsg 'output * dpms on'"; }
{ event = "unlock"; command = "${pkgs.sway}/bin/swaymsg 'output * dpms on'"; }
];
timeouts = [
{ timeout = 300; command = "${pkgs.swaylock}/bin/swaylock -fF"; }
{ timeout = 600; command = "${pkgs.sway}/bin/swaymsg 'output * dpms off'"; resumeCommand = "${pkgs.sway}/bin/swaymsg 'output * dpms on'"; }
];
};
swayosd.enable = true;
2022-10-31 10:05:30 +01:00
};
2024-10-05 10:32:00 +02:00
# qt = {
# enable = true;
# style.package = [
# pkgs.dracula-theme
# pkgs.dracula-icon-theme
# pkgs.catppuccin-kvantum
# pkgs.catppuccin-kde
# pkgs.catppuccin-gtk
# pkgs.qt6Packages.qtstyleplugin-kvantum
# ];
# style.name = "kvantum";
# platformTheme.name = "qtct";
# };
# xdg.configFile = {
# "Kvantum/Catppuccin".source = "${pkgs.catppuccin-kvantum}/share/Kvantum/Catppuccin-Frappe-Blue";
# "Kvantum/kvantum.kvconfig".text = "[General]\ntheme=Catppuccin-Frappe-Blue";
# };
2022-10-31 10:05:30 +01:00
}