-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmenu_go
executable file
·53 lines (34 loc) · 1.18 KB
/
dmenu_go
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
#!/bin/bash
export LC_ALL=C
LIST_BOOKMARKS_FILE=~/.config/dmenu_move_bookmarks.set
## ------------------------------------------------------------------------
## GET CONF
DEST=""
ALIAS_LIST=$(awk '{
if (index($0,"#")==1) {}
else if (NF == 0) {}
else {print $1}
}' $LIST_BOOKMARKS_FILE)
## ------------------------------------------------------------------------
## RETRIEVE ASSOCIATED LOCATION
DEST_ALIAS=$(echo "$ALIAS_LIST" | dmenu -i -p "move to>" -nb black -nf white -sf red)
if [[ "$DEST_ALIAS" = "" ]]; then
# interupted by user
exit
fi
## ------------------------------------------------------------------------
## RETRIEVE ASSOCIATED LOCATION
DEST_ALIAS=$(echo "$DEST_ALIAS" | sed -e 's|/|\\/|')
DEST=$(cat $LIST_BOOKMARKS_FILE | sort -u | awk ' $0 ~ /^'$DEST_ALIAS'/ {
if (NF > 1) {$1="";print }
else { print $1 }
}' | head -1 | sed -e 's/^[ \t]*//')
# NB: last sed is for removing leading whitespaces and tabs
DEST=$(echo "$DEST" | sed -e "s|^~|$HOME|")
## ------------------------------------------------------------------------
## GO
if [[ ! -d "$DEST" ]]; then
notify-send 'dmenu_go error' "dest folder $DEST not reachable"
exit 1
fi
nautilus --no-desktop "$DEST"