nixos/home/desktop/sway.nix

154 lines
4.4 KiB
Nix

{
pkgs,
lib,
config,
...
}: let
modifier = config.wayland.windowManager.sway.config.modifier;
term = config.wayland.windowManager.sway.config.terminal;
# currently, there is some friction between sway and gtk:
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
# the suggested way to set gtk settings is with gsettings
# for gsettings to work, we need to tell it where the schemas are
# using the XDG_DATA_DIR environment variable
# run at the end of sway config
configure-gtk = pkgs.writeTextFile {
name = "configure-gtk";
destination = "/bin/configure-gtk";
executable = true;
text = let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
gtk-theme = config.gtk.theme.name;
icon-theme = config.gtk.iconTheme.name;
cursor-theme = config.gtk.cursorTheme.name;
in ''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface
gsettings set $gnome_schema gtk-theme '${gtk-theme}'
gsettings set $gnome_schema icon-theme '${icon-theme}'
gsettings set $gnome_schema cursor-theme '${cursor-theme}'
'';
};
in {
imports = [
./swaylock.nix
./waybar.nix
./gtk.nix
./dunst.nix
./rofi.nix
../gui/foot.nix
];
home.packages = with pkgs; [
configure-gtk
pipewire
wireplumber
wl-clipboard
swayimg
brightnessctl
];
programs.rofi.package = pkgs.rofi-wayland;
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
xwayland = true;
extraSessionCommands = ''
export GDK_BACKEND=wayland,x11
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"'';
config = {
input."*".xkb_layout = "gb";
output."*".bg = "~/nixos/wallpaper.jpg fill";
fonts = {
names = ["FiraCode Nerd Font" "FiraCode Nerd Font Mono"];
size = 12.0;
};
gaps = {
inner = lib.mkDefault 5;
outer = lib.mkDefault 20;
};
bars = [{command = "${pkgs.waybar}/bin/waybar";}];
assigns = {
"2" = [{app_id = "firefox";}];
"3" = [
{class = "Signal";}
{app_id = "fractal";}
{app_id = "discord";}
{class = "teams-for-linux";}
];
"4" = [{class = "Nxplayer.bin";}];
};
floating.criteria = [
{app_id = "foot";}
{app_id = "pavucontrol";}
{app_id = ".blueman-manager-wrapped";}
{app_id = "otpclient";}
{app_id = "thunar";}
{app_id = "^swayimg.*$";}
];
startup = [
{
command = "dbus-sway-environment";
always = true;
}
{
command = "configure-gtk";
always = true;
}
{command = "dunst";}
];
modifier = lib.mkDefault "Mod1";
terminal = lib.mkDefault "${pkgs.wezterm}/bin/wezterm";
window.titlebar = false;
workspaceAutoBackAndForth = true;
keybindings = lib.mkOptionDefault {
"${modifier}+Return" = "exec ${term}";
"${modifier}+Shift+Return" = "exec ${pkgs.foot}/bin/foot";
"${modifier}+space" = "exec ${pkgs.rofi}/bin/rofi -show drun";
"${modifier}+F1" = "exec ${pkgs.swaylock}/bin/swaylock";
"${modifier}+w" = "exec ${pkgs.firefox}/bin/firefox";
"${modifier}+f" = "exec ${pkgs.xfce.thunar}/bin/thunar";
"${modifier}+p" = "exec powermenu";
};
colors = {
focused = {
border = "#4c7899";
background = "#285577";
text = "#ffffff";
indicator = "#2e9ef4";
childBorder = "#285577";
};
focusedInactive = {
border = "#333333";
background = "#5f676a";
text = "#ffffff";
indicator = "#484e50";
childBorder = "#5f676a";
};
unfocused = {
border = "#333333";
background = "#222222";
text = "#888888";
indicator = "#292d2e";
childBorder = "#222222";
};
urgent = {
border = "#2f343a";
background = "#900000";
text = "#ffffff";
indicator = "#900000";
childBorder = "#900000";
};
placeholder = {
border = "#000000";
background = "#0c0c0c";
text = "#ffffff";
indicator = "#000000";
childBorder = "#0c0c0c";
};
background = "#ffffff";
};
};
};
}