/
ma_plan_view_feh
executable file
·63 lines (56 loc) · 1.26 KB
/
ma_plan_view_feh
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
56
57
58
59
60
61
62
63
#!/bin/sh -e
# Ma_Sys.ma Plan View Feh 1.0.0.2, Copyright (c) 2015 Ma_Sys.ma.
# For further info send an e-mail to Ma_Sys.ma@web.de.
mpvf_main() {
if [ $# = 0 ]; then
mpvf_invoc .
elif [ "$1" = "-s" ]; then
shift
mpvf_special "$@"
elif [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "-?" -o "$1" = "help" ];
then
mpvf_help
elif [ $# = 1 -a -f "$1" ]; then
dn="$(dirname "$1")"
mpvf_invoc --start-at "$dn/$(basename "$1")" "$dn"/*
else
mpvf_invoc "$@"
fi
return $?
}
mpvf_invoc() {
# exec is crucial for keeping the same pid!
exec /usr/bin/feh --action1 "; $0 -s store %F" \
--action2 "; $0 -s go $$ %F" -. -S filename "$@"
}
# -s store PATH
# -s go PID PATH
mpvf_special() {
if [ "$1" = store ]; then
mpvf_store "$2"
elif [ "$1" = go ]; then
mpvf_go "$2" "$3"
else
echo "ERROR: Need to give store|go."
echo "Program bug or malformed invocation."
return 1
fi
}
# $1 FILE
mpvf_store() {
echo "$1" >> planview_sel.txt
}
# PID PATH
mpvf_go() {
sel="$(zenity --file-selection --title="Directory selection" \
--filename="$2" --directory)"
if [ -n "$sel" -a -d "$sel" ]; then
mpvf_replace "$1" "$sel"
fi
}
# PID PATH
mpvf_replace() {
kill -s TERM "$1" || echo WARNING: Failed to terminate old process
mpvf_invoc "$2"/*
}
mpvf_main "$@"