diff --git a/firefox-quick-keywords/LICENSE b/firefox-quick-keywords/LICENSE new file mode 100644 index 0000000..d586cfa --- /dev/null +++ b/firefox-quick-keywords/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2021 Guilherme Rugai Freire + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/firefox-quick-keywords/README.md b/firefox-quick-keywords/README.md new file mode 100644 index 0000000..f180ed9 --- /dev/null +++ b/firefox-quick-keywords/README.md @@ -0,0 +1,23 @@ +# Firefox Quick Keywords +dmenu or rofi launcher to open firefox bookmarks with keywords quickly + +## Installing firefox-quick-keywords + +> Requires [rofi](https://github.com/davatorium/rofi) or [dmenu](https://tools.suckless.org/dmenu/) + +```sh +git clone https://github.com/GRFreire/firefox-quick-keywords $HOME/.local/share/firefox-quick-keywords + +ln -s $HOME/.local/share/firefox-quick-keywords/firefox-quick-keywords $HOME/.local/bin/firefox-quick-keywords +``` + +After that, just run ```firefox-quick-keywords``` in your terminal + +## Update + +Go to ```$HOME/.local/share/firefox-quick-keywords``` and update the repo. + +```sh +cd $HOME/.local/share/firefox-quick-keywords +git pull +``` diff --git a/firefox-quick-keywords/firefox-quick-keywords b/firefox-quick-keywords/firefox-quick-keywords new file mode 100755 index 0000000..a48de39 --- /dev/null +++ b/firefox-quick-keywords/firefox-quick-keywords @@ -0,0 +1,35 @@ +#!/bin/sh + +if [ "$(command -v rofi)" ]; then + CMD='rofi -dmenu'; +elif [ "$(command -v dmenu)" ]; then + CMD='dmenu'; +else + echo 'Could not find either dmenu or rofi, exiting' + exit 1; +fi + + +# Copy the firefox database +DB='/tmp/places.sqlite' +cp ~/.mozilla/firefox/*.default-release/places.sqlite $DB + +# SQL +QUERY="SELECT moz_keywords.keyword, moz_places.url FROM moz_keywords left JOIN moz_places ON place_id=moz_places.id WHERE moz_places.url<>'' AND moz_keywords.keyword<>''" +OPTIONS=$(sqlite3 $DB "$QUERY" | awk -F "|" '{print "["$1"] - "$NF}') + +# Clean tmp +rm $DB + +# Prompt: +CHOICE=$(echo "$OPTIONS" | $CMD -p "Firefox quick open:") + +# Check choice +URL=$(echo "$CHOICE" | awk '{print $NF}') || exit 1 +VALID=$(echo "$OPTIONS" | grep "$URL") +if [ -n "$VALID" ] && [ -n "$CHOICE" ]; then + firefox "$URL" + exit 0 +else + exit 1 +fi