-
Notifications
You must be signed in to change notification settings - Fork 3
/
gtmsu
executable file
·45 lines (41 loc) · 1.36 KB
/
gtmsu
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
#!/bin/bash
# a "graphical tmsu frontend" which at this point only supports one use case:
# adding tags by selecting from a list of existing tags (and/or making a new one)
# to a list of specified files
# dependencies: zenity, sqlite3
db=${TMSU_DB:-$HOME/.tmsu/default.db}
function list_all_tags () {
echo 'select name from tag;' | sqlite3 $db
}
if [ "$1" == 'tag' ]; then
shift
files=("$@")
tags=$(list_all_tags | zenity --list --title="gtmsu tag" --text="Enter tag(s) to apply" --column=tags --editable --multiple --separator=' ')
if [ $? -eq 0 -a -n "$tags" ]; then
out=$(mktemp /tmp/tmsu.XXXX.out)
err=$(mktemp /tmp/tmsu.XXXX.err)
tmsu tag --tags "$tags" "${files[@]}" > $out 2> $err
ret=$?
txt="Return code: $ret\n\nStderr:\n$(cat $err)\n\nStdout:\n$(cat $out)"
if [ $ret -gt 0 ]; then
zenity --warning --text="$txt"
else
zenity --info --text="$txt"
fi
fi
fi
if [ "$1" == 'untag-all' ]; then
echo "here"
shift
file="$1"
out=$(mktemp /tmp/tmsu.XXXX.out)
err=$(mktemp /tmp/tmsu.XXXX.err)
tmsu untag --all "$(readlink "$file")" > $out 2> $err
ret=$?
txt="Return code: $ret\n\nStderr:\n$(cat $err)\n\nStdout:\n$(cat $out)"
if [ $ret -gt 0 ]; then
zenity --warning --text="$txt"
else
zenity --info --text="$txt"
fi
fi