New graphical tmsu script. Could use cleanup, but works perfectly.
This commit is contained in:
parent
6da3dcbb58
commit
7b9c9d8f29
2
mping.sh
2
mping.sh
|
@ -6,4 +6,4 @@ mp () {
|
|||
|
||||
export -f mp
|
||||
|
||||
parallel mp {} ::: $@ | column --table
|
||||
parallel mp {} ::: $@ | column -t
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
#!/bin/bash
|
||||
|
||||
# A TMSU (Tag My Shit Up) handler using YAD/Zenity for clickable GTK tagging and easy new tag creation.
|
||||
|
||||
TMSU_PROMPT_PROG="yad"
|
||||
APPLIED_TAGS=""
|
||||
TEMP_DIR=$(mktemp --directory /tmp/tmsu.XXXX)
|
||||
|
||||
if [ ! -d "/tmp/tmsu-prompt" ]; then
|
||||
mkdir /tmp/tmsu-prompt
|
||||
fi
|
||||
|
||||
LOGFILE=$(mktemp /tmp/tmsu-prompt/XXXX.log)
|
||||
|
||||
MOVE_DIR() {
|
||||
# Get images directory and move to tmsu base.
|
||||
WDIR=$(dirname $(readlink -f $1))
|
||||
cd $WDIR
|
||||
#OP_DIR=$(tmsu info | sed -n 's/Root.*: \(.*\)/\1/p')
|
||||
}
|
||||
|
||||
SET_TAG() {
|
||||
echo "" > $TEMP_DIR/tags
|
||||
|
||||
# Make arrays for master tags and images.
|
||||
declare -A tagArray
|
||||
|
||||
# Initial loop to get full list of tags, setting all to false.
|
||||
for t in $(tmsu tags -n "never" -1)
|
||||
do
|
||||
tagArray[$t]=FALSE
|
||||
done
|
||||
|
||||
# Loop again to set the tags of the image to TRUE.
|
||||
for t in $(tmsu tags -n "never" -1 $1)
|
||||
do
|
||||
tagArray[$t]=TRUE
|
||||
done
|
||||
|
||||
# Sort the array so we can print them correctly every time.
|
||||
SORTED=$(printf '%s\n' ${!tagArray[@]} | sort)
|
||||
|
||||
# Build the table for zenity or yad.
|
||||
for key in $SORTED
|
||||
do
|
||||
echo ${tagArray[$key]} $key >> $TEMP_DIR/tags
|
||||
done
|
||||
|
||||
# Unset to clear for next loop.
|
||||
unset tagArray
|
||||
}
|
||||
|
||||
CALL_PROMPT() {
|
||||
# Prompt files.
|
||||
APPLIED_TAGS=$($TMSU_PROMPT_PROG --list \
|
||||
--text "Tagging image $1" \
|
||||
--title "Tagging image $1" \
|
||||
--multiple \
|
||||
--width=600 --height=600 \
|
||||
--checklist \
|
||||
--column="" \
|
||||
--column "Select" \
|
||||
--editable \
|
||||
--image tag \
|
||||
--separator=" " \
|
||||
$(cat $TEMP_DIR/tags) | \
|
||||
sed 's/TRUE //' | tr -d '\n')
|
||||
}
|
||||
|
||||
APPLY_TAG() {
|
||||
tmsu untag --all $1 >> $LOGFILE 2>> $LOGFILE
|
||||
tmsu tag $1 $2 >> $LOGFILE 2>> $LOGFILE
|
||||
}
|
||||
|
||||
for x in $@
|
||||
do
|
||||
MOVE_DIR $x
|
||||
SET_TAG $x
|
||||
CALL_PROMPT $x
|
||||
APPLY_TAG $x "$APPLIED_TAGS"
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
rm $TEMP_DIR/*tags
|
||||
rmdir $TEMP_DIR
|
Loading…
Reference in New Issue