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

22 lines
905 B
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;
2024-08-22 19:54:20 +03:00
container = "mkv";
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.
2024-08-22 20:53:39 +03:00
bindsym --to-code $mod+shift+v exec 'pkill -SIGINT wf-recorder || wf-recorder --geometry "$(${selection})" --codec ${codec} --file "''${XDG_VIDEOS_DIR[0]}/$(date +${format}).${container}" --framerate ${toString framerate} --pixel-format ${pixfmt}'
2024-04-06 03:03:58 +03:00
'';
}