update clipboard-image-recall screen size function
This commit is contained in:
parent
65b59676ba
commit
73d507f453
|
@ -24,6 +24,7 @@
|
|||
./scripts/emoji-picker.nix
|
||||
./scripts/clipboard-save.nix
|
||||
./scripts/clipboard-recall.nix
|
||||
./scripts/get-focused-monitor.nix
|
||||
];
|
||||
|
||||
home.packages = [
|
||||
|
@ -32,5 +33,6 @@
|
|||
pkgs.dunst
|
||||
pkgs.picom
|
||||
pkgs.sxhkd
|
||||
pkgs.nsxiv
|
||||
];
|
||||
}
|
||||
|
|
|
@ -52,18 +52,22 @@
|
|||
|
||||
(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//")
|
||||
monitor_name=$(get-focused-monitor)
|
||||
monitor_info=$(xrandr | grep "$monitor_name")
|
||||
|
||||
width=$(echo $monitor_info | grep -oP '\d+x\d+' | cut -dx -f1)
|
||||
height=$(echo $monitor_info | grep -oP '\d+x\d+' | cut -dx -f2)
|
||||
|
||||
scale_width=$(( $width/4 + $width/2 ))
|
||||
scale_height=$(( $height/4 + $height/2 ))
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Please provide directory"
|
||||
if [ "$1" == "" ] || [ -f "$1" ]; then
|
||||
notify-send -t 1000 "Clipboard Recall" "Directory not specified or missing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filesdir="$(find $1 -type f -printf '%T@ %p\n' | sort -rn | cut -d ' ' -f 2-)"
|
||||
[ "$filesdir" == "" ] && notify-send -t 1000 "Clipboard Recall" "No images in directory" && exit 1
|
||||
output="$(echo "$filesdir" | ${nsxiv}/bin/nsxiv -tioq -g "$scale_width"x"$scale_height" -N nsxiv-float )"
|
||||
num_lines=$( echo "$output" | wc -l)
|
||||
|
||||
|
|
Loading…
Reference in New Issue