Files
nixos/apps/screenshot/default.nix
T

78 lines
2.4 KiB
Nix

{pkgs, myConfig, ...}: let
# Screenshot script with swappy integration
screenshot = pkgs.writeShellScriptBin "screenshot" ''
#!/usr/bin/env bash
case "$1" in
region)
# Select region and edit
grim -g "$(slurp)" - | swappy -f -
;;
window)
# Screenshot active window
grim -g "$(hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')" - | swappy -f -
;;
screen)
# Screenshot current monitor
grim -o "$(hyprctl -j monitors | jq -r '.[] | select(.focused) | .name')" - | swappy -f -
;;
all)
# Screenshot all monitors
grim - | swappy -f -
;;
region-save)
# Quick region screenshot (save without editing and copy to clipboard)
filepath=~/Pictures/Screenshots/$(date +'%Y-%m-%d_%H-%M-%S.png')
grim -g "$(slurp)" "$filepath"
wl-copy < "$filepath"
notify-send "Screenshot saved" "Saved and copied to clipboard"
;;
ocr)
# OCR Selection
grim -g "$(slurp)" - | tesseract stdin stdout | wl-copy
notify-send "OCR" "Text extracted to clipboard"
;;
*)
echo "Usage: screenshot {region|window|screen|all|region-save|ocr}"
exit 1
;;
esac
'';
in {
home.packages = with pkgs; [
grim # Screenshot utility
slurp # Region selector
swappy # Annotation tool
jq # For window selection
wl-clipboard # For copying to clipboard
tesseract # OCR tool
screenshot # Our wrapper script
];
# Create Screenshots directory
home.file."Pictures/Screenshots/.keep".text = "";
# Swappy configuration
home.file.".config/swappy/config".text = ''
[Default]
save_dir=$HOME/Pictures/Screenshots
save_filename_format=screenshot_%Y%m%d_%H%M%S.png
show_panel=true
line_size=5
text_size=20
text_font=${myConfig.font.sans}
paint_mode=brush
early_exit=false
fill_shape=false
'';
wayland.windowManager.hyprland.settings.bindd = [
# Screenshots
"SUPER, S, Screenshot Region (with edit), exec, screenshot region"
"SUPER SHIFT, S, Screenshot Active Window, exec, screenshot window"
"SUPER ALT, S, Quick Screenshot (no edit), exec, screenshot region-save"
"SUPER ALT SHIFT, S, Screenshot Current Monitor, exec, screenshot screen"
"SUPER ALT, E, OCR Selection, exec, screenshot ocr"
];
}