├── README.md ├── boosta ├── config.sample └── tools └── convertFirefox2Boosta /README.md: -------------------------------------------------------------------------------- 1 | ## boosta 2 | 3 | #### Easy bookmark management with rofi 4 | 5 | ### Features 6 | 7 | - Browser independent 8 | - Store your bookmarks in a simple textfile, which can be easily tracked with git 9 | - Use rofi as a convenient interface to search, open and manage bookmarks 10 | - Convert your bookmarks.html file exported from Firefox to a boosta bookmarks file 11 | 12 | ### Requirements 13 | 14 | boosta has the following requirements: 15 | 16 | - Python 2 or 3 (for the convertFirefox2Boosta script) 17 | - rofi 18 | 19 | ### Usage 20 | 21 | To convert your *bookmarks.html* file exported from Firefox to a boosta 22 | bookmarks file, run: 23 | 24 | convertFirefox2Boosta 25 | 26 | The boosta bookmarks file will be created as *bookmarks*. Copy it to *$HOME/.config/boosta/bookmarks* to use it with boosta. 27 | 28 | Copy the *config.sample* file to *$HOME/.config/boosta/config* and customize it as you like. 29 | 30 | Run *boosta*, then you can switch between the following modes: 31 | 32 | * `Alt+o` **open bookmark** (default mode) 33 | * start to type a tag, a title or an url and press `Enter` when you found the bookmark to open. 34 | * `Alt+n` **add bookmark** 35 | * You need to provide tag(s), title and url for a new bookmark. 36 | * For each of tags, title and url, you can also select from the existing ones. 37 | * The title of the previous window (probably the browser window) is inserted as the default value for the title. 38 | * You might want to copy the url to the clipboard before running boosta and insert it then with `Shift+Insert`. 39 | * Press `Ctrl+Enter` to use the entered text and not the selected entry as input. 40 | * `Alt+d` **delete bookmark** 41 | * start to type a tag, a title or an url and press `Enter` when you found the bookmark to delete. 42 | * Confirm the deletion of the selected bookmark by selecting `[Y]es` and pressing `Enter`. 43 | 44 | ### License 45 | 46 | This software is released under the terms of the 47 | GNU General Public License v2: 48 | 49 | [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt](http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt) 50 | 51 | ### TODO 52 | - change delimiter 53 | - edit bookmark 54 | - generate a html file of the bookmarks 55 | -------------------------------------------------------------------------------- /boosta: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # boosta: easy bookmark management 4 | 5 | # variables 6 | USAGE="Boosta keys: Alt+o: open bookmark | Alt+n: add bookmark | Alt+d: delete bookmark" 7 | KEYS="-kb-custom-1 Alt+o -kb-custom-2 Alt+n -kb-custom-3 Alt+d" 8 | 9 | # function definitions 10 | ###################### 11 | function openBookmark() 12 | { 13 | output=$(cat $BOOKMARKS | $LAUNCHER Bookmarks: -mesg "$USAGE" $KEYS) 14 | retval=$? 15 | # return if a special keycombo was pressed 16 | [ $retval -ne 0 ] && return $retval 17 | # extract url and open it in the specified browser 18 | url=$(echo $output | awk -F '|' '{printf("%s ", $NF)}' | tr -d '\r\n') 19 | if [ ${#url} -gt 0 ] 20 | then 21 | $BROWSER $url 22 | fi 23 | } 24 | 25 | function addBookmark() 26 | { 27 | # get window title from xprop, to pre-fill the title dialog 28 | id=$(xprop -root | grep '_NET_ACTIVE_WINDOW(WINDOW)' | awk '{print $NF}') 29 | pretitle=$(xprop -id $id | grep '_NET_WM_NAME(UTF8_STRING)' | awk -F '"' '{print $2}' | awk -F '-' '{print $1}') 30 | # ask for tags, title and url, exit if any response is empty 31 | tags=$(cat $BOOKMARKS | awk -F '|' '{print $1}' | sort -f | uniq | $LAUNCHER Tags: -mesg "$USAGE" $KEYS) 32 | retval=$? 33 | # return if a special keycombo was pressed 34 | [ $retval -ne 0 ] && return $retval 35 | [ -z $tags ] && exit 1 36 | title=$(cat $BOOKMARKS | awk -F '|' '{print $2}' | sort -f | uniq | $LAUNCHER Title: -mesg "$USAGE" $KEYS -filter "$pretitle") 37 | retval=$? 38 | # return if a special keycombo was pressed 39 | [ $retval -ne 0 ] && return $retval 40 | [ -z "$title" ] && exit 1 41 | url=$(cat $BOOKMARKS | awk -F '|' '{print $3}' | sort -f | uniq | $LAUNCHER URL: -mesg "$USAGE" $KEYS) 42 | retval=$? 43 | # return if a special keycombo was pressed 44 | [ $retval -ne 0 ] && return $retval 45 | [ -z "$url" ] && exit 1 46 | # add bookmark to file and sort it 47 | echo "$tags|$title|$url" >> "$BOOKMARKS" 48 | sort -f "$BOOKMARKS" -o /tmp/bookmarks_sorted 49 | mv /tmp/bookmarks_sorted "$BOOKMARKS" 50 | } 51 | 52 | function deleteBookmark() 53 | { 54 | output=$(cat $BOOKMARKS | $LAUNCHER Bookmarks: -mesg "$USAGE" $KEYS) 55 | retval=$? 56 | # return if a special keycombo was pressed 57 | [ $retval -ne 0 ] && return $retval 58 | # ask for confirmation to delete the selected bookmark 59 | confirm=$(echo -e "[Y]es\n[N]o" | $LAUNCHER 'Do you really want to delete the following bookmark:' -mesg "$output" $KEYS) 60 | retval=$? 61 | ( [ $retval -ne 0 ] || [ "$confirm" != "[Y]es" ] ) && return $retval 62 | grep -v -F "$output" "$BOOKMARKS" > /tmp/bookmarks_deleted 63 | mv /tmp/bookmarks_deleted "$BOOKMARKS" 64 | } 65 | 66 | 67 | # script execution starts here 68 | ############################## 69 | 70 | # source configuration or use default values 71 | if [ -f $HOME/.config/boosta/config ]; then 72 | source $HOME/.config/boosta/config 73 | else 74 | # TODO: better make LAUNCHER a function with an argument for -p 75 | # TODO: only _add_ rofi options in config file 76 | LAUNCHER="rofi -dmenu -i -l 40 -p" 77 | BROWSER="firefox" 78 | BOOKMARKS="$HOME/.config/boosta/bookmarks" 79 | fi 80 | 81 | # default: retval=10 -> open bookmark 82 | retval=10 83 | while [ $retval -ne 0 ] 84 | do 85 | case "$retval" in 86 | 1) 87 | # rofi was closed (e.g. by ESC) 88 | exit 0 89 | ;; 90 | 10) 91 | openBookmark 92 | retval=$? 93 | ;; 94 | 11) 95 | addBookmark 96 | retval=$? 97 | ;; 98 | 12) 99 | deleteBookmark 100 | retval=$? 101 | ;; 102 | esac 103 | done 104 | -------------------------------------------------------------------------------- /config.sample: -------------------------------------------------------------------------------- 1 | # configuration for boosta bookmark tool 2 | LAUNCHER="rofi -dmenu -i -l 40 -p" 3 | BROWSER="firefox" 4 | BOOKMARKS="$HOME/.config/boosta/bookmarks" 5 | -------------------------------------------------------------------------------- /tools/convertFirefox2Boosta: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # convert bookmarks.html exported from firefox to boosta bookmarks format 4 | # Author: http://okraits.de okraits@arcor.de 5 | 6 | # SETTINGS 7 | ff_path = 'bookmarks.html' 8 | raw_path = 'bookmarks' 9 | 10 | # global variables 11 | ff_file = None # firefox bookmarks file object 12 | raw_file = None # boosta bookmarks file object 13 | raw_string = "" # the generated html code containing the bookmarks 14 | current_category = "" 15 | 16 | if __name__ == "__main__": 17 | 18 | # open firefox bookmarks file and generate boosta string for all bookmarks 19 | try: 20 | ff_file = open(ff_path, 'r') 21 | except IOError: 22 | print("Error: firefox bookmarks file could not be opened.") 23 | exit(1) 24 | for line in ff_file: 25 | if line.find('')+2:line.find('')] 27 | elif line.find('HREF="') != -1: # line with a bookmark 28 | url = line[line.find('HREF="')+6:line.find('" ADD_DATE')] 29 | title = line[line.rfind('">')+2:line.find('')] 30 | raw_string += current_category + '|' + title + '|' + url + '\n' 31 | ff_file.close() 32 | 33 | try: 34 | raw_file = open(raw_path, 'w') 35 | except IOError: 36 | print("Error: boosta bookmarks file could not be opened.") 37 | exit(1) 38 | raw_file.write(raw_string) 39 | raw_file.flush() 40 | raw_file.close() 41 | exit(0) 42 | --------------------------------------------------------------------------------