Commit 02360f4

HPCesia <me@hpcesia.com>
2026-10-07 18:36:15
niri: use grim + slurp + satty for screenshot
1 parent 0ca6295
Changed files (4)
modules/desktop/wm/niri/config/keybinds.kdl
@@ -6,11 +6,6 @@ binds {
   Mod+Shift+E     { quit; }
   Ctrl+Alt+Delete { quit; }
 
-  Print       { screenshot; }
-  Mod+Shift+S { screenshot; }
-  Ctrl+Print  { screenshot-screen; }
-  Alt+Print   { screenshot-window; }
-
   // === Window and Column Actions ===
   Mod+Q repeat=false { close-window; }
 
modules/desktop/wm/niri/config/misc.kdl
@@ -5,6 +5,8 @@ hotkey-overlay {
 
 prefer-no-csd
 
+screenshot-path null
+
 recent-windows {
   debounce-ms 750
   open-delay-ms 150
modules/desktop/wm/niri/config/window-rules.kdl
@@ -56,6 +56,7 @@ window-rule {
   open-maximized true
 }
 
+
 // Floating
 window-rule {
   match app-id="QQ" title="^(图片查看器|文件管理器|收藏|聊天记录管理|设置|群相册 - .*?)$"
@@ -63,6 +64,15 @@ window-rule {
   open-floating true
 }
 
+
+// Fullscreen
+window-rule {
+  match app-id="com.gabm.satty"
+
+  open-fullscreen true
+}
+
+
 // === Workspaces ===
 window-rule {
   match app-id="code"
modules/desktop/wm/niri/default.nix
@@ -23,6 +23,39 @@
             ${lib.concatMapAttrsStringSep "\n  " (key: bind: ''${key} { ${bind}; }'') binds}
           }
         '';
+
+        ix-screenshot = pkgs.writeShellApplication {
+          name = "ix-screenshot";
+          meta.mainProgram = "ix-screenshot";
+          runtimeInputs = with pkgs; [
+            grim
+            satty
+            slurp
+          ];
+          text = ''
+            MODE="''${1:-region}"
+            case "''${MODE}" in
+            region)
+              grim -g "$(slurp -d)" -
+              ;;
+            window)
+              niri msg action screenshot-window
+              sleep 0.5
+              wl-paste --type image/png
+              ;;
+            monitor-focused)
+              grim -o "$(niri msg --json focused-output | jq --raw-output .name)" -
+              ;;
+            monitor-all)
+              grim -
+              ;;
+            *)
+              echo "\"''${MODE}\" is not a supported." >&2
+              exit 1
+              ;;
+            esac | satty --filename - --output-filename "${config.xdg.user-dirs.directories.screenshots}/%Y-%m-%d_%H-%M-%S.png"
+          '';
+        };
       in {
         xdg.config.files =
           lib.mergeAttrsList
@@ -35,7 +68,6 @@
             "niri/nix/post.kdl".text = ''
               include "keybinds.kdl"
 
-              screenshot-path "${config.xdg.user-dirs.directories.pictures}/Screenshots/Screenshot_%Y-%m-%d_%H-%M-%S.png"
               xwayland-satellite { path "${lib.getExe pkgs.xwayland-satellite}"; }
             '';
             "niri/nix/keybinds.kdl" = {
@@ -44,6 +76,10 @@
                 "Mod+Grave" =
                   lib.mkIf (user.system.settings.desktop.app.term.default != null)
                   ''spawn "${user.system.settings.desktop.app.term.default}"'';
+                "Print" = ''spawn-sh "${lib.getExe ix-screenshot}"'';
+                "Mod+Shift+S" = ''spawn-sh "${lib.getExe ix-screenshot}"'';
+                "Ctrl+Print" = ''spawn-sh "${lib.getExe ix-screenshot} monitor-all"'';
+                "Alt+Print" = ''spawn-sh "${lib.getExe ix-screenshot} window"'';
               };
             };
           };