summaryrefslogtreecommitdiff
path: root/pkgs/scripts/clip.nix
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2025-08-24 18:55:06 -0600
committerAlejandro Soto <alejandro@34project.org>2025-08-24 18:55:06 -0600
commitd7ac88762db111a7962c4e14b5f4e37ab85ccac7 (patch)
tree0c2c8c4383bef74215e3b7c48a2f6b0117f084bc /pkgs/scripts/clip.nix
parent504589d1035f27b766bd33040b415b2725ece4ca (diff)
tree-wide: reformat using alejandra after enabling trivionomicon
Diffstat (limited to 'pkgs/scripts/clip.nix')
-rw-r--r--pkgs/scripts/clip.nix54
1 files changed, 30 insertions, 24 deletions
diff --git a/pkgs/scripts/clip.nix b/pkgs/scripts/clip.nix
index b801ccf..3e16e3e 100644
--- a/pkgs/scripts/clip.nix
+++ b/pkgs/scripts/clip.nix
@@ -1,44 +1,50 @@
-{ lib
-, writeShellScriptBin
-, gnome-screenshot
-, xclip
-, file
-, imagemagick
-, toPDF
-, ...
+{
+ lib,
+ writeShellScriptBin,
+ gnome-screenshot,
+ xclip,
+ file,
+ imagemagick,
+ toPDF,
+ ...
}:
with lib; let
- name = if toPDF then "clip-pdf" else "clip";
+ name =
+ if toPDF
+ then "clip-pdf"
+ else "clip";
pdfCmdline = optionalString toPDF ''
if [ $# -lt 1 ]; then
echo "Usage: $0 <out.pdf> [opts...]" >&2
exit 1
fi
-
+
OUT="$1"
shift
'';
copyOut =
- if toPDF then ''
+ if toPDF
+ then ''
${imagemagick}/bin/convert "$CLIP" "$OUT"
- '' else ''
+ ''
+ else ''
${xclip}/bin/xclip -selection clipboard \
-t $(${file}/bin/file -b --mime-type $CLIP) <"$CLIP"
'';
in
-writeShellScriptBin name ''
- ${pdfCmdline}
+ writeShellScriptBin name ''
+ ${pdfCmdline}
+
+ OPTIONS=-a
+ if [ "x$@" != "x" ]; then
+ OPTIONS="$@"
+ fi
- OPTIONS=-a
- if [ "x$@" != "x" ]; then
- OPTIONS="$@"
- fi
-
- CLIP="$HOME/vtmp/$$.png"
- ${gnome-screenshot}/bin/gnome-screenshot "$OPTIONS" -f "$CLIP"
- ${copyOut}
+ CLIP="$HOME/vtmp/$$.png"
+ ${gnome-screenshot}/bin/gnome-screenshot "$OPTIONS" -f "$CLIP"
+ ${copyOut}
- rm "$CLIP"
-''
+ rm "$CLIP"
+ ''