modified clipboard-image-recall for nsxiv-float

This commit is contained in:
Sam 2024-06-16 02:04:02 +01:00
parent 97d8a879eb
commit cfa74f52fe
3 changed files with 20 additions and 15 deletions

View File

@ -23,6 +23,7 @@
# Helper scripts
./scripts/emoji-picker.nix
./scripts/clipboard-save.nix
./scripts/clipboard-recall.nix
];
home.packages = [

View File

@ -8,13 +8,13 @@
local diff=$1
if ((diff<60)); then
echo "${diff} seconds"
echo "''${diff} seconds"
elif ((diff<3600)); then
echo "$((diff/60)) minutes"
echo "''$((diff/60)) minutes"
elif ((diff<86400)); then
echo "$((diff/3600)) hours"
echo "''$((diff/3600)) hours"
else
echo "$((diff/86400)) days"
echo "''$((diff/86400)) days"
fi
}
@ -43,7 +43,7 @@
get_files_info $clipboard_dir | ${fzf}/bin/fzf --ansi \
--height 100% \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--preview 'bat --style=numbers --color=always {1}' \
--preview '${bat}/bin/bat --style=numbers --color=always {1}' \
--preview-window 'up,70%,+{2}+3/3,~3' \
--bind 'enter:become(cat {1} | nohup xclip -loops 0 -i -selection CLIPBOARD >/dev/null 2>&1 && touch {1})'
@ -51,27 +51,34 @@
'')
(writeShellScriptBin "clipboard-image-recall" ''
# Script to view and select and output images in image clipboard dir to clipboard.
#!/bin/bash
width=$(${xorg.xwininfo}/bin/xwininfo -root | grep Width | sed "s/^.*:\s//")
height=$(${xorg.xwininfo}/bin/xwininfo -root | grep Height | sed "s/^.*:\s//")
offset_horiz=$(( $width/8 ))
offset_vert=$(( $height/8 ))
scale_width=$(( $width/4 + $width/2 ))
scale_height=$(( $height/4 + $height/2 ))
if [ "$1" == "" ]; then
echo "Please provide directory"
exit 1
fi
filesdir="$(find $1 -type f -printf '%T@ %p\n' | sort -rn | cut -d ' ' -f 2-)"
output="$(echo "$filesdir" | nsxiv -tioq -g 1000x1000+0+0)"
output="$(echo "$filesdir" | ${nsxiv}/bin/nsxiv -tioq -g "$scale_width"x"$scale_height"-$offset_horiz-$offset_vert -N nsxiv-float )"
num_lines=$( echo "$output" | wc -l)
if [ "$num_lines" -gt 1 ]; then
echo "More than one image selected, outputting list to clipboard as text"
echo "$output" | ${xclip}/bin/xclip -i -selection CLIPBOARD && ${libnotify}/bin/notify-send "Image to Clipboard" "Paths:\n$output\ncopied to clipboard" -t 5000
elif [ -z "$output" ]; then
echo "Nothing selected"
exit 1
else
echo "Outputted to clipboard"
xclip -selection clipboard -t image/png -i "$output" && ${libnotify}/bin/notify-send "Image to Clipboard" "$output copied to clipboard" -t 5000
${xclip}/bin/xclip -selection clipboard -t image/png -i "$output" && ${libnotify}/bin/notify-send "Image to Clipboard" "$output copied to clipboard" -t 5000
fi
'')

View File

@ -30,15 +30,12 @@
control + Insert
bookmark-insert
control + F12
nsxiv-clipboard-copy /tmp/clipboard/images/
control + F8
clipboard-image-recall /tmp/clipboard/images/
Print
flameshot gui
control + F8
dmenu-dict
control + F7
emoji-picker
'';