-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrofi-tmsu.sh
55 lines (43 loc) · 914 Bytes
/
rofi-tmsu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
OPEN=xdg-open
TMSU_DB="/path/to/.tmsu/db"
TMSU_CMD="tmsu -D $TMSU_DB"
ROFI_CMD="rofi -dmenu"
function gen_tags()
{
$TMSU_CMD tags
}
function files()
{
basename -a $FILES
}
function file_selection()
{
FILES=$($TMSU_CMD files "$TAGS")
if [ ! -z "$FILES" ]; then
SEL=$( files | $ROFI_CMD -p "Select File:")
if [ ! -z "$SEL" ]; then
for i in ${FILES[@]}; do
if test "$i" != "${i#*/$SEL}" ; then
coproc ( $OPEN $i );
fi
done
fi
else
show_selection
fi
}
function show_selection()
{
TAGS=$( gen_tags | $ROFI_CMD -p "Select Tag(s):")
if [ "$TAGS" = "" ]; then
exit;
fi
COUNT=$($TMSU_CMD files --count "$TAGS")
if [[ ${COUNT:0:1} -ne 0 ]]; then
file_selection
else
show_selection
fi
}
show_selection