2024-05-04 20:57:33 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
}: let
|
2024-01-21 20:56:00 +01:00
|
|
|
cfg = config.jhome.gui.sway;
|
|
|
|
modifier = "Mod4";
|
2024-01-21 21:09:39 +01:00
|
|
|
terminal = config.jhome.gui.terminal;
|
|
|
|
termCmd =
|
2024-05-04 20:57:33 +02:00
|
|
|
if terminal == "wezterm"
|
|
|
|
then "wezterm start"
|
|
|
|
else if terminal == "alacritty"
|
|
|
|
then "alacritty -e"
|
|
|
|
else builtins.abort "no command configured for ${terminal}";
|
2024-01-21 21:09:39 +01:00
|
|
|
menu = "${pkgs.fuzzel}/bin/fuzzel --terminal '${termCmd}'";
|
2024-01-21 20:56:00 +01:00
|
|
|
# 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
|
2024-05-04 20:57:33 +02:00
|
|
|
configure-gtk = let
|
|
|
|
schema = pkgs.gsettings-desktop-schemas;
|
|
|
|
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
|
|
|
|
in
|
2024-04-05 11:55:35 +02:00
|
|
|
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
|
|
|
|
'';
|
2024-05-04 20:57:33 +02:00
|
|
|
cmdOnce = command: {inherit command;};
|
2024-01-21 20:56:00 +01:00
|
|
|
cmdAlways = command: {
|
|
|
|
inherit command;
|
|
|
|
always = true;
|
|
|
|
};
|
2024-05-04 20:57:33 +02:00
|
|
|
in {
|
2024-01-21 20:56:00 +01:00
|
|
|
inherit modifier terminal menu;
|
2024-05-04 20:57:33 +02:00
|
|
|
keybindings = import ./keybindings.nix {inherit config pkgs;};
|
2024-01-21 20:56:00 +01:00
|
|
|
# Appearance
|
2024-05-04 20:57:33 +02:00
|
|
|
bars = []; # Waybar is started as a systemd service
|
2024-01-21 20:56:00 +01:00
|
|
|
gaps = {
|
|
|
|
smartGaps = true;
|
|
|
|
smartBorders = "on";
|
|
|
|
inner = 4;
|
|
|
|
};
|
|
|
|
output."*".bg = "${cfg.background} fill";
|
|
|
|
# Window Appearance
|
|
|
|
window.border = 2;
|
|
|
|
# Make certain windows floating
|
|
|
|
window.commands = [
|
2024-04-05 11:55:35 +02:00
|
|
|
{
|
|
|
|
command = "floating enable";
|
|
|
|
criteria.title = "zoom";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
command = "floating enable";
|
|
|
|
criteria.class = "floating";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
command = "floating enable";
|
|
|
|
criteria.app_id = "floating";
|
|
|
|
}
|
2024-01-21 20:56:00 +01:00
|
|
|
];
|
|
|
|
# Startup scripts
|
2024-05-04 20:57:33 +02:00
|
|
|
startup =
|
|
|
|
[
|
|
|
|
(cmdAlways "${configure-gtk}/bin/configure-gtk")
|
|
|
|
]
|
|
|
|
++ (builtins.map cmdAlways cfg.exec.always)
|
|
|
|
++ (builtins.map cmdOnce cfg.exec.once);
|
2024-01-21 20:56:00 +01:00
|
|
|
# Keyboard configuration
|
2024-02-24 16:19:00 +01:00
|
|
|
input."type:keyboard" = {
|
|
|
|
repeat_delay = "300";
|
|
|
|
repeat_rate = "50";
|
|
|
|
xkb_options = "caps:swapescape,compose:ralt";
|
|
|
|
xkb_numlock = "enabled";
|
|
|
|
};
|
2024-01-21 20:56:00 +01:00
|
|
|
# Touchpad
|
2024-02-24 16:19:00 +01:00
|
|
|
input."type:touchpad" = {
|
|
|
|
click_method = "clickfinger";
|
|
|
|
natural_scroll = "enabled";
|
|
|
|
scroll_method = "two_finger";
|
|
|
|
tap = "enabled";
|
|
|
|
tap_button_map = "lrm";
|
|
|
|
};
|
2024-01-21 20:56:00 +01:00
|
|
|
}
|