nix_config/home/modules/gui/sway.nix

183 lines
4.6 KiB
Nix

{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.local.gui;
in {
config = mkIf cfg.enable {
home.packages = [
pkgs.wlr-randr
];
services = {
swayidle = {
enable = true;
timeouts = [
{
timeout = 600;
command = "${getExe pkgs.gtklock} -d";
}
];
};
};
systemd.user.services.wl-gammarelay-rs = {
Unit.After = ["sway-session.target"];
Install.WantedBy = ["sway-session.target"];
Service.ExecStart = getExe pkgs.wl-gammarelay-rs;
};
wayland.windowManager.sway = {
enable = true;
config = {
output =
lib.mapAttrs (k: v: {
mode = "${toString v.width}x${toString v.height}@${v.rate}Hz";
pos = "${toString v.posX} ${toString v.posY}";
})
cfg.monitors;
modifier = "Mod4";
focus = {
followMouse = true;
wrapping = "workspace";
};
input = {
"*" = {
xkb_layout = "us";
xkb_variant = "altgr-intl";
};
};
fonts = {
names = ["JetBrains Mono"];
style = "Regular";
size = 8.0;
};
gaps = {
inner = 8;
outer = -10;
smartBorders = "on";
smartGaps = true;
};
bars = singleton {
command = "waybar";
position = "top";
};
window = {
hideEdgeBorders = "both";
titlebar = false;
border = 2;
};
floating = {
border = 0;
titlebar = false;
};
workspaceLayout = "tabbed";
colors = {
background = "#141414";
focused = {
border = "#1c1c1c";
background = "#000000";
text = "#eaeaea";
indicator = "#000000";
childBorder = "#000000";
};
focusedInactive = {
border = "#000000";
background = "#000000";
text = "#eaeaea";
indicator = "#000000";
childBorder = "#000000";
};
unfocused = {
border = "#000000";
background = "#000000";
text = "#eaeaea";
indicator = "#000000";
childBorder = "#000000";
};
urgent = {
border = "#ff6666";
background = "#ff6666";
text = "#eaeaea";
indicator = "#ff6666";
childBorder = "#ff6666";
};
placeholder = {
border = "#000000";
background = "#000000";
text = "#eaeaea";
indicator = "#000000";
childBorder = "#000000";
};
};
keybindings = let
mod = config.wayland.windowManager.sway.config.modifier;
wofi = config.programs.wofi.package;
grimshot = getExe pkgs.sway-contrib.grimshot;
in
mkOptionDefault {
"${mod}+a" = "focus parent";
"${mod}+c" = "focus child";
"${mod}+d" = "exec --no-startup-id ${getExe wofi} -S run";
"${mod}+l" = "exec ${getExe pkgs.gtklock} -d";
"${mod}+Return" = "exec ${lib.getExe pkgs.kitty} ${lib.getExe pkgs.tmux}";
"${mod}+Shift+s" = "exec ${grimshot} copy area";
"${mod}+Tab" = "focus right";
"${mod}+Shift+Tab" = "focus left";
"${mod}+Shift+w" = "move workspace to output right";
};
startup = [
{
command = "${lib.getExe pkgs.sway} 'workspace 1; exec ${lib.getExe pkgs.firefox}'";
}
{
command = "${lib.getExe pkgs.sway} 'workspace 2; exec ${lib.getExe pkgs.tdesktop}'";
}
{
command = "${lib.getExe pkgs.sway} 'workspace 2; exec ${lib.getExe pkgs.gajim}'";
}
{
command = "${lib.getExe pkgs.swaybg} -m fill -i ${config.home.homeDirectory}/Pictures/wallpapers/jupiter.png";
always = true;
}
{
command = "${lib.getExe pkgs.networkmanagerapplet}";
}
];
};
extraSessionCommands = ''
export SDL_VIDEODRIVER=wayland
# needs qt5.qtwayland in systemPackages
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
# Fix for some Java AWT applications (e.g. Android Studio),
# use this if they aren't displayed properly:
export _JAVA_AWT_WM_NONREPARENTING=1
'';
swaynag.enable = true;
systemd.enable = true;
xwayland = true;
};
};
}