summaryrefslogtreecommitdiff
path: root/scriptlets/feh_action3.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scriptlets/feh_action3.sh')
-rwxr-xr-xscriptlets/feh_action3.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/scriptlets/feh_action3.sh b/scriptlets/feh_action3.sh
new file mode 100755
index 0000000..d45de39
--- /dev/null
+++ b/scriptlets/feh_action3.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+ROFI_THEME="ErikaScythe2"
+
+NEW_IMAGE="$1"
+NEW_IMAGE_SIZE="$( du -sh "$NEW_IMAGE" | cut -f1 )"
+FILELIST="$2"
+[[ $( wc -l $FILELIST | cut -d' ' -f1 ) -ne 2 ]] && notify-send "ERROR: FILE LIST DOESN'T HAVE TWO FILES" && exit
+OLD_IMAGE="$( cat "$FILELIST" | grep -v "$NEW_IMAGE" | sort | head -n1 )"
+OLD_IMAGE_SIZE="$( du -sh "$OLD_IMAGE" | cut -f1 )"
+
+CHOICE=$(echo -e "Yes\nNo" \
+| rofi -dmenu -i -no-custom -p "$( echo -e "Replace image\n$OLD_IMAGE (${OLD_IMAGE_SIZE})\nwith\n$NEW_IMAGE (${NEW_IMAGE_SIZE})?" )" -theme "$ROFI_THEME" -async-pre-read 2 -no-click-to-exit )
+
+if [[ "$CHOICE" == "Yes" ]]; then
+ NEW_EXTENSION="${NEW_IMAGE##*.}"
+ OLD_BASE="${OLD_IMAGE%.*}"
+ NEW_FINAL="${OLD_BASE}.${NEW_EXTENSION}"
+ gio trash "$OLD_IMAGE" && mv "${NEW_IMAGE}" "${NEW_FINAL}"
+fi