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 # Helper scripts
./scripts/emoji-picker.nix ./scripts/emoji-picker.nix
./scripts/clipboard-save.nix ./scripts/clipboard-save.nix
./scripts/clipboard-recall.nix
]; ];
home.packages = [ home.packages = [

View File

@ -8,13 +8,13 @@
local diff=$1 local diff=$1
if ((diff<60)); then if ((diff<60)); then
echo "${diff} seconds" echo "''${diff} seconds"
elif ((diff<3600)); then elif ((diff<3600)); then
echo "$((diff/60)) minutes" echo "''$((diff/60)) minutes"
elif ((diff<86400)); then elif ((diff<86400)); then
echo "$((diff/3600)) hours" echo "''$((diff/3600)) hours"
else else
echo "$((diff/86400)) days" echo "''$((diff/86400)) days"
fi fi
} }
@ -43,7 +43,7 @@
get_files_info $clipboard_dir | ${fzf}/bin/fzf --ansi \ get_files_info $clipboard_dir | ${fzf}/bin/fzf --ansi \
--height 100% \ --height 100% \
--color "hl:-1:underline,hl+:-1:underline:reverse" \ --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' \ --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})' --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" '' (writeShellScriptBin "clipboard-image-recall" ''
# Script to view and select and output images in image clipboard dir to clipboard. # 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 if [ "$1" == "" ]; then
echo "Please provide directory" echo "Please provide directory"
exit 1 exit 1
fi fi
filesdir="$(find $1 -type f -printf '%T@ %p\n' | sort -rn | cut -d ' ' -f 2-)" 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) num_lines=$( echo "$output" | wc -l)
if [ "$num_lines" -gt 1 ]; then if [ "$num_lines" -gt 1 ]; then
echo "More than one image selected, outputting list to clipboard as text" 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 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 elif [ -z "$output" ]; then
echo "Nothing selected" echo "Nothing selected"
exit 1 exit 1
else else
echo "Outputted to clipboard" 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 fi
'') '')

View File

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