-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathranger-kdialog
executable file
·77 lines (63 loc) · 1.68 KB
/
ranger-kdialog
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
## NOTE: I have stopped developing this script, focusing instead on the `nnn` variant.
## Instructions
# - Place this file as /usr/local/bin/kdialog
# - Set XDG_CURRENT_DESKTOP=KDE
# To pick a directory in ranger, press q.
## Debugging
#args="$@"
#notify-send "kdialog $args"
echo "$@" >> $HOME/ranger-kdialog.log
# $1 is the window title
if [ "$TERMINAL" = "" ]
then
TERMINAL=urxvt
fi
getopenfilename() {
$TERMINAL -t "$1" -e ranger --choosefile=/tmp/fileselect
cat /tmp/fileselect
echo "getopenfilename $(cat /tmp/fileselect)" >> $HOME/ranger-kdialog.log
rm /tmp/fileselect
}
getexistingdirectory() {
$TERMINAL -t "$1" -e ranger --choosedir=/tmp/fileselect
cat /tmp/fileselect
echo "getexisitingdirectory $(cat /tmp/fileselect)" >> $HOME/ranger-kdialog.log
rm /tmp/fileselect
}
getsavefilename() {
dir=$(getexistingdirectory "$1")
echo "$dir/$2"
echo "getsavefilename $dir/$2" >> $HOME/ranger-kdialog.log
nohup $HOME/.xmonad/bin/notify.sh "$dir" "$2" &
}
version() {
# impersonate the latest version
echo "kdialog 21.12.1" >> ~/kdialog-log
echo "kdialog 21.12.1"
}
## Parse options
for (( i=1; i<=$#; i++ ));
do
case ${!i} in
--getopenfilename | --getexistingdirectory | --version )
# get rid of the leading dashes
fun=${!i##--}
;;
--getsavefilename )
fun=${!i##--}
(( i++ ))
save_path="${!i}"
save_file="${save_path##/*/}"
;;
--title )
(( i++ ))
title=${!i}
;;
esac
done 2> /dev/null;
title=${title:-ranger-kdialog}
## Epic functional programming trick
if ! [ -z "$fun" ]; then
echo "$($fun "$title" "$save_file")"
fi