mirror of
https://github.com/moons-14/dotfiles.git
synced 2026-10-06 03:08:11 +09:00
screenshot
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "screenshot";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils
|
||||
grim
|
||||
slurp
|
||||
wl-clipboard
|
||||
xdg-user-dirs
|
||||
];
|
||||
|
||||
text = ''
|
||||
mode="''${1:-region}"
|
||||
|
||||
pictures_dir="$(xdg-user-dir PICTURES)"
|
||||
if [[ -z "$pictures_dir" ]]; then
|
||||
pictures_dir="$HOME/Pictures"
|
||||
fi
|
||||
|
||||
output_dir="$pictures_dir/Screenshots"
|
||||
output_file="$output_dir/Screenshot from $(date '+%Y-%m-%d %H-%M-%S').png"
|
||||
|
||||
mkdir -p "$output_dir"
|
||||
|
||||
case "$mode" in
|
||||
region)
|
||||
geometry="$(slurp)" || exit 0
|
||||
grim -g "$geometry" "$output_file"
|
||||
;;
|
||||
|
||||
output)
|
||||
geometry="$(slurp -o)" || exit 0
|
||||
grim -g "$geometry" "$output_file"
|
||||
;;
|
||||
|
||||
all)
|
||||
grim "$output_file"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown screenshot mode: $mode" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
wl-copy --type image/png < "$output_file"
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
description = "Wayland screenshot command";
|
||||
}
|
||||
Reference in New Issue
Block a user