nix_config/home/modules/gui/sway.nix

110 lines
2.7 KiB
Nix

{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.local.gui;
in {
config = mkIf cfg.enable {
home.packages = [
pkgs.wlr-randr
];
programs = {
waybar.enable = true;
wofi.enable = true;
};
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 = {
modifier = "Mod4";
focus.followMouse = true;
fonts = {
size = 11.0;
names = ["DejaVu Sans Mono"];
style = "Bold Semi-Condensed";
};
bars = singleton {
command = "waybar";
position = "top";
};
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}+i" = "exec busctl --user call rs.wl-gammarelay / rs.wl.gammarelay ToggleInverted";
"${mod}+o" = "exec ${getExe pkgs.gtklock} -d";
"${mod}+Return" = "exec ${lib.getExe pkgs.kitty} ${lib.getExe pkgs.tmux}";
"${mod}+Shift+e" = "input * xkb_layout latam";
"${mod}+Shift+u" = "input * xkb_layout us";
"${mod}+p" = "exec ${grimshot} copy active";
"${mod}+Shift+p" = "exec ${grimshot} copy area";
"${mod}+Ctrl+p" = "exec ${grimshot} copy window";
};
window.commands = [
# (No) Title Bars
{
command = "border pixel 5";
criteria.class = "^.*";
}
{
command = "floating enabled";
criteria.class = "floating";
}
];
};
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;
};
};
}