nix/home/config/sway/module/Screenshot.nix

22 lines
1.1 KiB
Nix
Raw Normal View History

2024-08-22 19:13:40 +03:00
{ config, ... }: let
2024-08-22 19:54:20 +03:00
codec = "libsvtav1";
2024-08-22 19:13:40 +03:00
color = config.style.color;
container = "mp4";
2024-08-22 19:54:20 +03:00
format = "%Y-%m-%d_%H-%M-%S";
2024-08-28 03:09:03 +03:00
framerate = 10;
2024-08-22 19:13:40 +03:00
opacity = "26";
selection = "slurp -d -b ${color.bg.light}${opacity} -c ${color.fg.light} -w 0 -s 00000000";
2024-08-22 20:53:39 +03:00
pixfmt = "yuv420p10le";
2024-08-22 19:13:40 +03:00
in {
2024-04-06 03:03:58 +03:00
text = ''
# Fullscreen screenshot.
2024-08-22 19:13:40 +03:00
# bindsym --to-code $mod+shift+v exec grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') - | wl-copy -t image/png
2024-04-06 03:03:58 +03:00
# Select screenshot.
2024-08-22 19:54:20 +03:00
bindsym --to-code $mod+v exec grim -g "$(${selection})" - | tee "''${XDG_PICTURES_DIR[0]}/$(date +${format}).png" | wl-copy
2024-08-22 19:13:40 +03:00
# Select recording.
bindsym --to-code $mod+shift+v exec 'pkill -SIGINT wf-recorder || { export targetFile="''${XDG_VIDEOS_DIR[0]}/$(date +${format}).${container}"; wf-recorder --geometry "$(${selection})" --codec ${codec} --file "''${targetFile}" --framerate ${toString framerate} --pixel-format ${pixfmt} && ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i "''${targetFile}" -c:v copy -c:a libopus -shortest -f ${container} "''${targetFile}_" && mv "''${targetFile}_" "''${targetFile}"; }'
2024-04-06 03:03:58 +03:00
'';
}