mirror of
https://github.com/GRFreire/scripts.git
synced 2026-01-10 04:59:38 +00:00
Merge remote-tracking branch 'firefox-quick-keywords/master'
This commit is contained in:
commit
cdc4eb6bcf
22
firefox-quick-keywords/LICENSE
Normal file
22
firefox-quick-keywords/LICENSE
Normal file
@ -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.
|
||||||
23
firefox-quick-keywords/README.md
Normal file
23
firefox-quick-keywords/README.md
Normal file
@ -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
|
||||||
|
```
|
||||||
35
firefox-quick-keywords/firefox-quick-keywords
Executable file
35
firefox-quick-keywords/firefox-quick-keywords
Executable file
@ -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
|
||||||
Loading…
Reference in New Issue
Block a user