From 3207922b6887c048f1e1d5a5a123e78bf37776f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Wed, 4 Mar 2026 00:39:51 -0300 Subject: [PATCH] update niri config --- flake.nix | 2 +- scripts/bmenu | 16 +++- system/boot.nix | 2 +- system/greetd.nix | 30 ++++-- system/niri.nix | 5 +- user/fish/default.nix | 2 +- user/gpg.nix | 2 +- user/home.nix | 13 +-- user/niri/config.kdl | 205 ++++++++++++++++++++++++++++++++++++++++ user/niri/default.nix | 90 ++++++++++++++++++ user/niri/theme.nix | 94 ++++++++++++++++++ user/sway/mako.nix | 2 +- user/sway/swayidle.nix | 5 +- user/variables.nix | 2 +- user/waybar/default.nix | 83 ++++++++++------ 15 files changed, 495 insertions(+), 58 deletions(-) create mode 100644 user/niri/config.kdl create mode 100644 user/niri/default.nix create mode 100644 user/niri/theme.nix diff --git a/flake.nix b/flake.nix index e914d82..4d5c3ef 100644 --- a/flake.nix +++ b/flake.nix @@ -109,7 +109,7 @@ { nixpkgs.pkgs = pkgs; } ./system/configuration.nix { - login-manager.greetd.enable = desktop == "sway"; + login-manager.greetd.enable = desktop == "sway" || desktop == "niri"; my.gnome.enable = desktop == "gnome"; my.kde.enable = desktop == "kde"; } diff --git a/scripts/bmenu b/scripts/bmenu index 8abad08..2321416 100755 --- a/scripts/bmenu +++ b/scripts/bmenu @@ -8,11 +8,16 @@ if test "$argv[1]" = "run" test -n "$argv[2]" && set t "$argv[2]" || set t "terminal" - exec j4-dmenu-desktop \ + set -l launcher_args \ --dmenu="bmenu start -p Iniciar:" \ --term "$t" \ - --i3-ipc \ --no-generic + + if test -n "$SWAYSOCK" + set launcher_args $launcher_args --i3-ipc + end + + exec j4-dmenu-desktop $launcher_args end if test -n "$SWAYSOCK" @@ -22,6 +27,13 @@ if test -n "$SWAYSOCK" test -n "$focused_output" and set focused_output "-m $focused_output" +else if test -n "$NIRI_SOCKET" + set -l focused_name (niri msg -j focused-output | jq -r '.name') + set -l focused_index (niri msg -j outputs | jq -r --arg focused "$focused_name" 'keys | index($focused)') + + if test -n "$focused_index"; and test "$focused_index" != "null" + set focused_output "-m $focused_index" + end end set -l config "$HOME/.config/bmenu.conf" diff --git a/system/boot.nix b/system/boot.nix index 3e0151d..b231288 100644 --- a/system/boot.nix +++ b/system/boot.nix @@ -42,7 +42,7 @@ }; plymouth = { enable = true; - theme = lib.mkIf (config.my.desktop == "sway") "red_loader"; + theme = lib.mkIf (config.my.desktop == "sway" || config.my.desktop == "niri") "red_loader"; themePackages = with pkgs; [ (adi1090x-plymouth-themes.override { selected_themes = [ "red_loader" ]; }) ]; diff --git a/system/greetd.nix b/system/greetd.nix index 8642968..32e24c3 100644 --- a/system/greetd.nix +++ b/system/greetd.nix @@ -14,6 +14,8 @@ let ; cfg = config.login-manager.greetd; + isSway = desktop == "sway"; + isNiri = desktop == "niri"; in { options.login-manager.greetd = { @@ -25,8 +27,7 @@ in # Enable the X11 windowing system. services.xserver.enable = false; - # enable sway window manager - programs.sway = { + programs.sway = lib.mkIf isSway { enable = true; package = pkgs.mySway; wrapperFeatures.gtk = true; @@ -42,14 +43,22 @@ in }; services.greetd = let - start-sway = pkgs.writeShellScriptBin "start-sway" '' - mkdir -p ~/.local/share/sway - exec sway 2>&1 | tee -a ~/.local/share/sway/sway.log - ''; + start-session = pkgs.writeShellScriptBin "start-session" ( + if isNiri then + '' + mkdir -p ~/.local/share/niri + exec niri-session 2>&1 | tee -a ~/.local/share/niri/niri.log + '' + else + '' + mkdir -p ~/.local/share/sway + exec sway 2>&1 | tee -a ~/.local/share/sway/sway.log + '' + ); greetd_main_script = pkgs.writeShellScriptBin "main" '' - export XDG_CURRENT_DESKTOP=sway GTK_THEME="${theme.gtk_theme}" XCURSOR_THEME="${theme.cursor_theme}" - ${pkgs.gtkgreet}/bin/gtkgreet -l -c ${lib.getExe start-sway} - swaymsg exit + export XDG_CURRENT_DESKTOP=${desktop} GTK_THEME="${theme.gtk_theme}" XCURSOR_THEME="${theme.cursor_theme}" + ${pkgs.gtkgreet}/bin/gtkgreet -l -c ${lib.getExe start-session} + ${lib.optionalString isSway "swaymsg exit"} ''; swayConfig = pkgs.writeText "greetd-sway-config" '' # `-l` activates layer-shell mode. Notice that `swaymsg exit` will run after gtkgreet. @@ -72,7 +81,7 @@ in enable = true; settings = { initial_session = { - command = lib.getExe start-sway; + command = lib.getExe start-session; user = "lelgenio"; }; default_session = { @@ -81,6 +90,7 @@ in }; }; environment.systemPackages = with pkgs; [ + niri sway swaylock swayidle diff --git a/system/niri.nix b/system/niri.nix index 1aef116..6b74d4f 100644 --- a/system/niri.nix +++ b/system/niri.nix @@ -10,6 +10,9 @@ config = lib.mkIf config.my.niri.enable { programs.niri.enable = true; niri-flake.cache.enable = true; - environment.systemPackages = with pkgs; [ fuzzel ]; + environment.systemPackages = with pkgs; [ + fuzzel + xwayland-satellite + ]; }; } diff --git a/user/fish/default.nix b/user/fish/default.nix index d3a5cd1..f97c00a 100644 --- a/user/fish/default.nix +++ b/user/fish/default.nix @@ -117,7 +117,7 @@ in wl-copy-file foreign-env ] - ++ (lib.optionals (desktop == "sway") [ + ++ (lib.optionals (desktop == "sway" || desktop == "niri") [ async-prompt done ]) diff --git a/user/gpg.nix b/user/gpg.nix index f1c472f..c371747 100644 --- a/user/gpg.nix +++ b/user/gpg.nix @@ -39,7 +39,7 @@ Unit = "gpg_unlock.service"; }; Install = { - WantedBy = [ "sway-session.target" ]; + WantedBy = [ "graphical-session.target" ]; }; }; }; diff --git a/user/home.nix b/user/home.nix index f6cc1e8..87ba8d8 100644 --- a/user/home.nix +++ b/user/home.nix @@ -40,7 +40,7 @@ ./satty ./man.nix ./mpd.nix - ./sway + ./niri ./gnome.nix ./thunar.nix ./xdg-dirs.nix @@ -52,7 +52,7 @@ ]; my = import ./variables.nix // { - sway.enable = true; + niri.enable = true; pass.enable = true; fish.enable = true; }; @@ -168,15 +168,6 @@ torrent-client = lib.mkDefault "torrent.desktop"; }; - wayland.windowManager.sway.extraConfig = - lib.optionalString (osConfig.networking.hostName or "" == "monolith") - '' - exec steam - exec obs --startreplaybuffer --disable-shutdown-check - exec deluge-gtk - exec nicotine - ''; - # This value determines the Home Manager release that your # configuration is compatible with. This helps avoid breakage # when a new Home Manager release introduces backwards diff --git a/user/niri/config.kdl b/user/niri/config.kdl new file mode 100644 index 0000000..451a4a4 --- /dev/null +++ b/user/niri/config.kdl @@ -0,0 +1,205 @@ +input { + keyboard { + xkb { + layout "us(colemak),br" + options "lv3:lsgt_switch,grp:shifts_toggle" + } + repeat-delay 200 + repeat-rate 30 + numlock + } + + touchpad { + dwt + tap + natural-scroll + } + + mouse { + accel-speed 0.0 + accel-profile "flat" + } +} + +output "AOC 24G2W1G4 ATNM6XA004804" { + mode "1920x1080@144.000" + position x=0 y=0 + variable-refresh-rate +} + +output "LG Electronics 25UM58G 0x01010101" { + mode "2560x1080@74.991" + scale 1.2 + position x=1920 y=215 + variable-refresh-rate +} + +layout { + gaps 5 + focus-ring { + width 2 + active-color "#F44336" + inactive-color "#141414" + } + border { + off + } +} + +prefer-no-csd +screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png" + +spawn-at-startup "systemctl" "--user" "import-environment" "PATH" +spawn-at-startup "systemctl" "--user" "restart" "waybar.service" +spawn-at-startup "firefox-devedition" +spawn-at-startup "thunderbird" +spawn-at-startup "discordcanary" +spawn-at-startup "Telegram" + +window-rule { + match app-id="^org.nicotine_plus.Nicotine$" + open-on-workspace "6" +} + +window-rule { + match app-id="^deluge$" + open-on-workspace "6" +} + +window-rule { + match app-id="^com.obsproject.Studio$" + open-on-workspace "6" +} + +window-rule { + match app-id="^thunderbird$" + open-on-workspace "7" +} + +window-rule { + match app-id="^astroid$" + open-on-workspace "7" +} + +window-rule { + match app-id=".*[Ss]team.*" + open-on-workspace "9" +} + +window-rule { + match app-id=".*[Tt]elegram.*" + open-on-workspace "10" +} + +window-rule { + match app-id="^vesktop$" + open-on-workspace "10" +} + +window-rule { + match app-id="^Element$" + open-on-workspace "10" +} + +binds { + Mod+Return { spawn "alacritty"; } + Mod+Ctrl+Return { spawn "thunar"; } + Mod+S { spawn "wlauncher"; } + Mod+P { spawn "wpass"; } + Mod+G { spawn "demoji" "--lang" "pt" "--fallback" "--copy" "--" "wdmenu"; } + Mod+C { spawn "color_picker"; } + Mod+L { spawn "swaylock" "-f"; } + Mod+K { spawn "showkeys"; } + Mod+Ctrl+V { spawn "bash" "-c" "wl-paste | tesseract -l por - - | wl-copy"; } + Mod+Alt+X { spawn "bash" "-c" "pkill wl-crosshair || exec wl-crosshair"; } + Mod+Alt+C { spawn "bash" "-c" "pkill caffeinated || exec caffeinated"; } + + XF86MonBrightnessDown { spawn "brightnessctl" "--min-value=1" "set" "5%-"; } + XF86MonBrightnessUp { spawn "brightnessctl" "--min-value=1" "set" "5%+"; } + + XF86AudioRaiseVolume allow-when-locked=true { spawn "volumesh" "-i" "10"; } + XF86AudioLowerVolume allow-when-locked=true { spawn "volumesh" "-d" "10"; } + XF86AudioMute allow-when-locked=true { spawn "volumesh" "-t"; } + XF86AudioMicMute allow-when-locked=true { spawn "pactl" "set-source-mute" "@DEFAULT_SOURCE@" "toggle"; } + XF86AudioPlay { spawn "playerctl" "play-pause"; } + XF86AudioPause { spawn "playerctl" "play-pause"; } + XF86AudioNext { spawn "playerctl" "next"; } + XF86AudioPrev { spawn "playerctl" "previous"; } + + Print { spawn "screenshotsh" "def"; } + Shift+Print { spawn "screenshotsh" "area"; } + Ctrl+Shift+Print { spawn "screenshotsh" "area-clip"; } + Ctrl+Print { spawn "screenshotsh" "clip"; } + Mod+Shift+S { spawn "screenshotsh" "edit"; } + + Mod+F { fullscreen-window; } + Mod+X { close-window; } + + Mod+Left { focus-column-left; } + Mod+Down { focus-window-down; } + Mod+Up { focus-window-up; } + Mod+Right { focus-column-right; } + Mod+N { focus-column-left; } + Mod+E { focus-window-down; } + Mod+I { focus-window-up; } + Mod+O { focus-column-right; } + + Mod+Ctrl+Left { move-column-left; } + Mod+Ctrl+Down { move-window-down; } + Mod+Ctrl+Up { move-window-up; } + Mod+Ctrl+Right { move-column-right; } + Mod+Ctrl+N { move-column-left; } + Mod+Ctrl+E { move-window-down; } + Mod+Ctrl+I { move-window-up; } + Mod+Ctrl+O { move-column-right; } + + Mod+Alt+Left { focus-monitor-left; } + Mod+Alt+Down { focus-monitor-down; } + Mod+Alt+Up { focus-monitor-up; } + Mod+Alt+Right { focus-monitor-right; } + Mod+Alt+N { focus-monitor-left; } + Mod+Alt+E { focus-monitor-down; } + Mod+Alt+I { focus-monitor-up; } + Mod+Alt+O { focus-monitor-right; } + + Mod+Alt+Ctrl+Left { move-column-to-monitor-left; } + Mod+Alt+Ctrl+Down { move-column-to-monitor-down; } + Mod+Alt+Ctrl+Up { move-column-to-monitor-up; } + Mod+Alt+Ctrl+Right { move-column-to-monitor-right; } + Mod+Alt+Ctrl+N { move-column-to-monitor-left; } + Mod+Alt+Ctrl+E { move-column-to-monitor-down; } + Mod+Alt+Ctrl+I { move-column-to-monitor-up; } + Mod+Alt+Ctrl+O { move-column-to-monitor-right; } + + Mod+Y { focus-workspace-down; } + Mod+U { focus-workspace-up; } + Mod+Ctrl+Y { move-column-to-workspace-down; } + Mod+Ctrl+U { move-column-to-workspace-up; } + + Mod+BracketLeft { focus-workspace-down; } + Mod+BracketRight { focus-workspace-up; } + Mod+Tab { focus-workspace-up; } + Mod+Shift+Tab { focus-workspace-down; } + + Mod+1 { focus-workspace 1; } + Mod+2 { focus-workspace 2; } + Mod+3 { focus-workspace 3; } + Mod+4 { focus-workspace 4; } + Mod+5 { focus-workspace 5; } + Mod+6 { focus-workspace 6; } + Mod+7 { focus-workspace 7; } + Mod+8 { focus-workspace 8; } + Mod+9 { focus-workspace 9; } + Mod+0 { focus-workspace 10; } + + Mod+Shift+1 { move-column-to-workspace 1; } + Mod+Shift+2 { move-column-to-workspace 2; } + Mod+Shift+3 { move-column-to-workspace 3; } + Mod+Shift+4 { move-column-to-workspace 4; } + Mod+Shift+5 { move-column-to-workspace 5; } + Mod+Shift+6 { move-column-to-workspace 6; } + Mod+Shift+7 { move-column-to-workspace 7; } + Mod+Shift+8 { move-column-to-workspace 8; } + Mod+Shift+9 { move-column-to-workspace 9; } + Mod+Shift+0 { move-column-to-workspace 10; } +} diff --git a/user/niri/default.nix b/user/niri/default.nix new file mode 100644 index 0000000..2a1e8c6 --- /dev/null +++ b/user/niri/default.nix @@ -0,0 +1,90 @@ +{ + config, + pkgs, + lib, + osConfig, + ... +}: +let + inherit (config.my) font theme; + monolithAutostart = lib.optionalString ((osConfig.networking.hostName or "") == "monolith") '' + spawn-at-startup "steam" + spawn-at-startup "obs" "--startreplaybuffer" "--disable-shutdown-check" + spawn-at-startup "deluge-gtk" + spawn-at-startup "nicotine" + ''; +in +{ + imports = [ + ../sway/kanshi.nix + ../sway/mako.nix + ../sway/swayidle.nix + ../sway/swaylock.nix + ../sway/gammastep.nix + ./theme.nix + ]; + + config = lib.mkIf (config.my.niri.enable or false) { + my.mako.enable = true; + my.kanshi.enable = true; + my.swayidle.enable = true; + my.swaylock.enable = true; + my.mpd.enable = true; + my.zathura.enable = true; + my.satty.enable = true; + my.waybar.enable = true; + my.gammastep.enable = true; + + xdg.configFile."niri/config.kdl".text = '' + ${builtins.readFile ./config.kdl} + ${monolithAutostart} + ''; + + services.kdeconnect = { + enable = true; + indicator = true; + }; + + services.gpg-agent.pinentry.package = pkgs.pinentry-all; + + xdg.configFile."OpenTabletDriver/settings.json" = { + force = true; + source = ../sway/open-tablet-driver.json; + }; + + home.packages = with pkgs; [ + swaybg + swaylock + wdisplays + + dhist + demoji + bmenu + wdmenu + wlauncher + volumesh + brightnessctl + showkeys + pamixer + libnotify + xdg-utils + screenshotsh + color_picker + wf-recorder + wl-clipboard + wtype + wl-crosshair + caffeinated + + grim + satty + xdg-user-dirs + (tesseract5.override { + enableLanguages = [ + "eng" + "por" + ]; + }) + ]; + }; +} diff --git a/user/niri/theme.nix b/user/niri/theme.nix new file mode 100644 index 0000000..267bdc1 --- /dev/null +++ b/user/niri/theme.nix @@ -0,0 +1,94 @@ +{ + config, + pkgs, + lib, + ... +}: +let + inherit (config.my) theme font desktop; + inherit (theme) + color + gtk_theme + icon_theme + cursor_theme + ; +in +lib.mkIf (desktop == "niri") { + home.pointerCursor = { + name = cursor_theme; + size = 24; + package = pkgs.bibata-cursors; + gtk.enable = true; + }; + gtk = { + enable = true; + font = { + name = font.interface; + size = font.size.small; + }; + theme = { + name = gtk_theme; + package = pkgs.orchis_theme_compact; + }; + iconTheme = { + name = icon_theme; + package = pkgs.papirus_red; + }; + } + // ( + let + shared.extraConfig = { + gtk-decoration-layout = "menu:"; + }; + in + { + gtk4 = shared; + gtk3 = shared; + } + ); + + xdg.configFile."gtk-3.0/settings.ini".force = true; + xdg.configFile."gtk-4.0/settings.ini".force = true; + + qt = { + enable = true; + platformTheme.name = "gtk3"; + style.name = "kvantum"; + }; + + dconf.settings = { + "org/gnome/desktop/interface" = { + gtk-theme = gtk_theme; + icon-theme = icon_theme; + cursor-theme = cursor_theme; + color-scheme = "prefer-${color.type}"; + }; + "org/gnome/desktop/wm/preferences" = { + button-layout = "menu:"; + }; + }; + + services.xsettingsd = { + enable = true; + settings = { + "Gtk/FontName" = "${font.interface} ${toString font.size.small}"; + "Net/ThemeName" = "${gtk_theme}"; + "Net/IconThemeName" = "${icon_theme}"; + "Gtk/CursorThemeName" = "${cursor_theme}"; + "Gtk/CursorThemeSize" = 24; + "Net/SoundThemeName" = "freedesktop"; + }; + }; + + home.packages = with pkgs; [ + pkgs.bibata-cursors + pkgs.orchis_theme_compact + pkgs.papirus_red + + liberation_ttf + hack-font + font-awesome_5 + fira-code + material-wifi-icons + ]; +} diff --git a/user/sway/mako.nix b/user/sway/mako.nix index 6c78c9f..9646b1c 100644 --- a/user/sway/mako.nix +++ b/user/sway/mako.nix @@ -66,7 +66,7 @@ in Restart = "on-failure"; }; Install = { - WantedBy = [ "sway-session.target" ]; + WantedBy = [ "graphical-session.target" ]; }; }; }; diff --git a/user/sway/swayidle.nix b/user/sway/swayidle.nix index 365b63f..70fe071 100644 --- a/user/sway/swayidle.nix +++ b/user/sway/swayidle.nix @@ -7,6 +7,7 @@ let asScript = filename: text: toString (pkgs.writeShellScript filename text); + isNiri = (config.my.desktop or "") == "niri"; cfg = config.my.swayidle; in { @@ -19,6 +20,8 @@ in timeout = 360; command = "${pkgs.swaylock}/bin/swaylock -f"; } + ] + ++ lib.optionals (!isNiri) [ { timeout = 1800; command = asScript "swayidle-suspend-monitors" '' @@ -37,7 +40,7 @@ in { event = "after-resume"; command = asScript "after-resume" '' - ${pkgs.sway}/bin/swaymsg "output * dpms on" + ${lib.optionalString (!isNiri) "${pkgs.sway}/bin/swaymsg \"output * dpms on\""} ${pkgs.systemd}/bin/systemctl --user restart \ kdeconnect.service kdeconnect-indicator.service ''; diff --git a/user/variables.nix b/user/variables.nix index 65bc69a..8206f43 100644 --- a/user/variables.nix +++ b/user/variables.nix @@ -115,7 +115,7 @@ rec { }; dmenu = "bmenu"; - desktop = "sway"; + desktop = "niri"; browser = "firefox-devedition"; editor = "kakoune"; } diff --git a/user/waybar/default.nix b/user/waybar/default.nix index df9048f..d5b73da 100644 --- a/user/waybar/default.nix +++ b/user/waybar/default.nix @@ -10,8 +10,55 @@ let theme accent font + desktop ; inherit (theme) color; + workspaceModule = if desktop == "niri" then "niri/workspaces" else "sway/workspaces"; + windowModule = if desktop == "niri" then "niri/window" else "sway/window"; + languageModule = if desktop == "niri" then "niri/language" else "sway/language"; + workspaceSettings = + if desktop == "niri" then + { + all-outputs = false; + current-only = false; + format = "{icon}"; + format-icons = { + "1" = ""; + "2" = ""; + "3" = "󰅩"; + "4" = ""; + "5" = ""; + "6" = ""; + "7" = "󰇮"; + "8" = ""; + "9" = ""; + "10" = ""; + empty = ""; + active = ""; + focused = ""; + urgent = ""; + default = ""; + }; + } + else + { + enable-bar-scroll = true; + format = "{icon}"; + format-icons = { + "1" = ""; + "2" = ""; + "3" = "󰅩"; + "4" = ""; + "5" = ""; + "6" = ""; + "7" = "󰇮"; + "8" = ""; + "9" = ""; + "10" = ""; + urgent = ""; + default = ""; + }; + }; cfg = config.my.waybar; in @@ -22,18 +69,18 @@ in programs.waybar = { enable = true; systemd.enable = true; - systemd.target = "sway-session.target"; + systemd.target = "graphical-session.target"; settings = [ { layer = "top"; modules-left = [ - "sway/workspaces" - "sway/mode" - "sway/window" - ]; + workspaceModule + ] + ++ (lib.optional (desktop != "niri") "sway/mode") + ++ [ windowModule ]; modules-center = [ "clock" ]; modules-right = lib.flatten [ - "sway/language" + languageModule "mpd" "custom/playerctl" "tray" @@ -82,26 +129,8 @@ in format-linked = "󰈀"; format-disconnected = ""; }; - "sway/workspaces" = { - enable-bar-scroll = true; - format = "{icon}"; - format-icons = { - "1" = ""; - "2" = ""; - "3" = "󰅩"; - "4" = ""; - "5" = ""; - "6" = ""; - "7" = "󰇮"; - "8" = ""; - "9" = ""; - "10" = ""; - urgent = ""; - # focused = ""; - default = ""; - }; - }; - "sway/window" = { + "${workspaceModule}" = workspaceSettings; + "${windowModule}" = { max-length = 40; }; "tray" = { @@ -158,7 +187,7 @@ in interval = 1; tooltip = false; }; - "sway/language" = { + "${languageModule}" = { format = "{short} {variant}"; }; "custom/controller-battery" = {