-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrofi-firefox
executable file
·45 lines (35 loc) · 1.04 KB
/
rofi-firefox
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
SQL="SELECT b.title || \" | \" || p.url FROM moz_bookmarks b JOIN moz_places p ON b.fk = p.id WHERE b.fk is not null AND b.title <> '' AND url <> '' AND url NOT LIKE 'place:%'"
if [ -z "${FIREFOX_PROFILE+x}" ]; then
echo "FIREFOX_PROFILE not set"
exit 1
fi
PROFILE_DB=~/.mozilla/firefox/${FIREFOX_PROFILE}/places.sqlite
TMP_PLACES=/tmp/places
#avoiding db lock
cp -f ${PROFILE_DB} ${TMP_PLACES}
ENTRIES=$(sqlite3 ${TMP_PLACES} "${SQL}" | rofi -i -dmenu -p "Firefox")
echo "ENTRIES: ${ENTRIES}"
IFS=' | '
read -ra ADDR <<< "$ENTRIES"
for i in "${ADDR[@]}"; do
URL=$i
done
if [[ $URL == http* ]]; then
echo "URL: '$URL'"
else
WORDS=$(echo ${ENTRIES} | wc -w)
# we exit at empty string
if [ $WORDS -eq 0 ]; then
exit 0
fi
echo "${URL} is not url, using google search instead"
URL="https://www.google.com/search?client=firefox-b-d&q=${ENTRIES}"
fi
DEV_EDITION=$(ps aux | grep '[f]irefox-developer-edition' | wc -l)
if [ ${DEV_EDITION} -eq 0 ]; then
firefox "$URL"
else
firefox-developer-edition "$URL"
fi
rm ${TMP_PLACES}