summaryrefslogtreecommitdiff
path: root/scriptlets/findlast.sh
blob: 32d5c92301d3a7b313288b1376b7fdd75185c0a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

# THUNAR CUSTOM ACTION

# Name: Set Art lookup directory
# Description: Set the current directory as the one findlast.sh will check

# Command: $HOME/stuf/scripts/scriptlets/findlast.sh --set-artdir
# Keyboard Shortcut: Shift+F2
# Icon: shupogaki.png

# Appearance Conditions -> Check "Directories **"

if [[ "$1" = "--set-artdir" ]]; then
    echo $(pwd) > $HOME/stuf/artdir.txt
    $HOME/stuf/scripts/notification_wrapper.sh "Set $(pwd) as the new artdir." "FINDLAST"
else
    ARTDIR="$( head -n1 "$HOME/stuf/artdir.txt" )"
    SELECTION="$( xclip -o -sel primary | sed -r "s|\.[a-zA-Z]+||g" )"
    [[ -z $SELECTION ]] && exit -1

    $HOME/stuf/scripts/notification_wrapper.sh "$( find "$ARTDIR" -type f -iregex ".*/${SELECTION}[0-9]+[a-zA-Z]*\.[a-zA-Z]+" | sort -V | tail -n1 )" "FINDLAST"
fi