From 805501fb3f0cb06816871fdcad5f53445f48ac95 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Fri, 20 Mar 2026 02:19:30 +0530 Subject: Added screen capture with ffmpeg --- modules/desktop/i3/keybindings.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'modules/desktop') diff --git a/modules/desktop/i3/keybindings.nix b/modules/desktop/i3/keybindings.nix index 9d6e668..5b16a05 100644 --- a/modules/desktop/i3/keybindings.nix +++ b/modules/desktop/i3/keybindings.nix @@ -84,4 +84,22 @@ in lib.mkIf config.tools.maim.enable "exec \"${lib.getExe pkgs.maim} -s | xclip -selection clipboard -t image/png\""; "${mod}+Shift+p" = lib.mkIf config.tools.maim.enable "exec \"mkdir -p ~/Pictures/Screenshots && ${lib.getExe pkgs.maim} -s ~/Pictures/Screenshots/screenshot-$(date +%Y%m%d-%H%M%S).png\""; + + # --- Screen Recordings --- + "${mod}+Mod1+r" = lib.mkIf config.tools.ffmpeg.enable ( + let + pidFile = "/tmp/ffmpeg-screenrecord.pid"; + outDir = "~/Videos/Recordings"; + in + "exec \"" + + "if [ -f ${pidFile} ]; then " + + "kill $(cat ${pidFile}) && rm ${pidFile}; " + + "else " + + "mkdir -p ${outDir} && " + + "${lib.getExe pkgs.ffmpeg-full} -f x11grab -i $DISPLAY " + + "-framerate 30 -c:v libx264 -preset ultrafast -crf 23 " + + "${outDir}/recording-$(date +%Y%m%d-%H%M%S).mp4 " + + "& echo $! > ${pidFile}; " + + "fi\"" + ); } -- cgit v1.2.3