configuration.nix/home/gui/sway-config.nix
Jalil David Salamé Messina a449d9041d
All checks were successful
/ check (push) Successful in 46s
/ build (audiomenu) (push) Successful in 2s
/ build (docs) (push) Successful in 2s
/ build (jpassmenu) (push) Successful in 2s
/ build (nixosConfigurations.vm.config.system.build.toplevel) (push) Successful in 2s
/ build (nvim) (push) Successful in 2s
[chore] flake.lock: update inputs
Flake lock file updates:

• Updated input 'home-manager':
    'github:nix-community/home-manager/62d536255879be574ebfe9b87c4ac194febf47c5' (2024-12-01)
  → 'github:nix-community/home-manager/c7ffc9727d115e433fd884a62dc164b587ff651d' (2024-12-07)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/b681065d0919f7eb5309a93cea2cfa84dec9aa88' (2024-12-03)
  → 'github:NixOS/nixpkgs/4dc2fc4e62dbf62b84132fe526356fbac7b03541' (2024-12-05)
• Updated input 'nixvim':
    'github:nix-community/nixvim/6348336db0e0b17ab6d9c73bc8206db84ebf00d1' (2024-12-05)
  → 'github:nix-community/nixvim/08be20270d62e31f215f4592867d53576af15001' (2024-12-07)
• Updated input 'unstable':
    'github:NixOS/nixpkgs/55d15ad12a74eb7d4646254e13638ad0c4128776' (2024-12-03)
  → 'github:NixOS/nixpkgs/d0797a04b81caeae77bcff10a9dde78bc17f5661' (2024-12-05)
2024-12-08 14:07:57 +01:00

97 lines
3.2 KiB
Nix

{ config, pkgs }:
let
cfg = config.jhome.gui.sway;
modifier = "Mod4";
inherit (config.jhome.gui) terminal;
termCmd =
if terminal == "wezterm" then
"wezterm start"
else if terminal == "alacritty" then
"alacritty -e"
else
builtins.abort "no command configured for ${terminal}";
menu = "${pkgs.fuzzel}/bin/fuzzel --terminal '${termCmd}'";
# 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 =
let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in
pkgs.writers.writeDashBin "configure-gtk" ''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface
config="${config.xdg.configHome}/gtk-3.0/settings.ini"
if [ ! -f "$config" ]; then exit 1; fi
# Read settings from gtk3
gtk_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
icon_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-icon-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
cursor_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-cursor-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
font_name="$(grep 'gtk-font-name' "$config" | sed 's/.*\s*=\s*//')"
${pkgs.glib}/bin/gsettings set "$gnome_schema" gtk-theme "$gtk_theme"
${pkgs.glib}/bin/gsettings set "$gnome_schema" icon-theme "$icon_theme"
${pkgs.glib}/bin/gsettings set "$gnome_schema" cursor-theme "$cursor_theme"
${pkgs.glib}/bin/gsettings set "$gnome_schema" font-name "$font_name"
${pkgs.glib}/bin/gsettings set "$gnome_schema" color-scheme prefer-dark
'';
cmdOnce = command: { inherit command; };
cmdAlways = command: {
inherit command;
always = true;
};
in
{
inherit modifier terminal menu;
keybindings = import ./keybindings.nix { inherit config pkgs; };
# Appearance
bars = [ ]; # Waybar is started as a systemd service
gaps = {
smartGaps = true;
smartBorders = "on";
inner = 4;
};
output."*".bg = "${cfg.background} fill";
# Window Appearance
window.border = 2;
# Make certain windows floating
window.commands = [
{
command = "floating enable";
criteria.title = "zoom";
}
{
command = "floating enable";
criteria.class = "floating";
}
{
command = "floating enable";
criteria.app_id = "floating";
}
];
# Startup scripts
startup =
[
(cmdAlways "${configure-gtk}/bin/configure-gtk")
]
++ (builtins.map cmdAlways cfg.exec.always)
++ (builtins.map cmdOnce cfg.exec.once);
# Keyboard configuration
input."type:keyboard" = {
repeat_delay = "300";
repeat_rate = "50";
xkb_options = "caps:swapescape,compose:ralt";
xkb_numlock = "enabled";
};
# Touchpad
input."type:touchpad" = {
click_method = "clickfinger";
natural_scroll = "enabled";
scroll_method = "two_finger";
tap = "enabled";
tap_button_map = "lrm";
};
}