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/emoji-picker.nix
|
||||||
./scripts/clipboard-save.nix
|
./scripts/clipboard-save.nix
|
||||||
./scripts/clipboard-recall.nix
|
./scripts/clipboard-recall.nix
|
||||||
|
./scripts/get-focused-monitor.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
home.packages = [
|
home.packages = [
|
||||||
|
@ -32,5 +33,6 @@
|
||||||
pkgs.dunst
|
pkgs.dunst
|
||||||
pkgs.picom
|
pkgs.picom
|
||||||
pkgs.sxhkd
|
pkgs.sxhkd
|
||||||
|
pkgs.nsxiv
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,18 +52,22 @@
|
||||||
|
|
||||||
(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
|
monitor_name=$(get-focused-monitor)
|
||||||
width=$(${xorg.xwininfo}/bin/xwininfo -root | grep Width | sed "s/^.*:\s//")
|
monitor_info=$(xrandr | grep "$monitor_name")
|
||||||
height=$(${xorg.xwininfo}/bin/xwininfo -root | grep Height | sed "s/^.*:\s//")
|
|
||||||
|
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_width=$(( $width/4 + $width/2 ))
|
||||||
scale_height=$(( $height/4 + $height/2 ))
|
scale_height=$(( $height/4 + $height/2 ))
|
||||||
|
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ] || [ -f "$1" ]; then
|
||||||
echo "Please provide directory"
|
notify-send -t 1000 "Clipboard Recall" "Directory not specified or missing."
|
||||||
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-)"
|
||||||
|
[ "$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 )"
|
output="$(echo "$filesdir" | ${nsxiv}/bin/nsxiv -tioq -g "$scale_width"x"$scale_height" -N nsxiv-float )"
|
||||||
num_lines=$( echo "$output" | wc -l)
|
num_lines=$( echo "$output" | wc -l)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue