-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookmarks_from_xyz_folders_openbox_menu.sh
executable file
·46 lines (33 loc) · 1.32 KB
/
bookmarks_from_xyz_folders_openbox_menu.sh
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
#!/bin/sh
# Generate "Bookmarks from specified folders" OpenBox dynamic menu
# path to the sqlite3 binary
sqlite_path=`which sqlite3`
# sqlite3 parameters (define separator character)
sqlite_params="-separator ^"
# path to the places.sqlite database
bookmarks_database=`ls ~/.mozilla/firefox/*.default/places.sqlite`
# folders
folders="2,84,86"
# SQL query
sql_query="select b.title, p.url from moz_bookmarks as b left outer join moz_places as p on b.fk=p.id where p.hidden=0 and b.type = 1 and b.title is not null and p.hidden=0 and b.parent in (${folders})"
# browser path
browser_path=`which iceweasel`
# header
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
echo "<openbox_pipe_menu>";
# execute and parse sql query
$sqlite_path $sqlite_params "$bookmarks_database" "$sql_query" | while IFS=^ read title url; do
# special case for empty title
if [ -z "$title" ]; then
title=$url
fi
# escape special characters
title=$(echo $title | sed -e "s/&/\&/g" -e "s/\"/\"/g" -e "s/</\</g" -e "s/>/\>/g")
url=$(echo $url | sed -e "s/&/\&/g" -e "s/\"/\"/g" -e "s/</\</g" -e "s/>/\>/g")
# add missing apostrophes
title="\"$title\""
#item
echo "<item label=$title><action name=\"Execute\"><execute>$browser_path $url</execute></action></item>"
done
# footer
echo "</openbox_pipe_menu>"