Change from buku to linkding

This commit is contained in:
Thomas Dehaeze 2021-10-25 14:21:31 +02:00
parent 1de05dd3e2
commit 34656a5ee9
2 changed files with 73 additions and 14 deletions

View File

@ -39,7 +39,7 @@ c.qt.workarounds.remove_service_workers = True
* Content
#+begin_src python
c.content.autoplay = False
c.content.notifications = False
c.content.notifications.enabled = False
c.content.geolocation = 'ask'
c.content.javascript.alert = True
c.content.javascript.can_access_clipboard = True
@ -51,7 +51,7 @@ c.content.blocking.adblock.lists = ['https://easylist.to/easylist/easylist.txt',
* Editor
#+begin_src python
c.editor.command = ['/usr/bin/alacritty', '--class="Floating"', '-e', 'nvim {}']
c.editor.command = ['/usr/bin/alacritty', '--class', 'terminal,Floating', '-e', 'nvim', '{}']
#+end_src
* Downloads
@ -168,7 +168,6 @@ c.tabs.wrap = False
#+begin_src python
c.url.searchengines = {
'DEFAULT': 'https://www.duckduckgo.org/?q={}',
'aw': 'https://wiki.archlinux.org/?search={}',
'wi': 'https://en.wikipedia.org/wiki/Special:Search?search={}',
'go': 'https://www.google.com/search?q={}',
'gc': 'https://scholar.google.fr/scholar?hl=fr&as_sdt=0%2C5&q={}&btnG=',
@ -181,9 +180,9 @@ c.url.searchengines = {
'sm': 'https://www.openstreetmap.org/search?query={}',
'am': 'https://www.amazon.fr/s?k={}',
'md': 'https://fr.mathworks.com/help/search.html?qdoc={}&submitsearch=',
'js': 'https://developer.mozilla.org/en-US/search?q={}',
'tf': 'https://translate.google.com/#view=home&op=translate&sl=en&tl=fr&text={}',
'te': 'https://translate.google.com/#view=home&op=translate&sl=fr&tl=en&text={}',
'lb': 'https://www.leboncoin.fr/recherche?text={}',
}
#+end_src
@ -282,6 +281,12 @@ c.aliases['Password_Fill'] = 'spawn --userscript password_fill'
config.bind(',p', 'Password_Fill')
#+END_SRC
Get Two Factor Authentication number.
#+begin_src python
c.aliases['OTP'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/get-otp.sh'
config.bind(',2', 'OTP')
#+END_SRC
Open Youtube video using =mpv=
#+begin_src python
c.aliases['MPV_view'] = 'spawn --detach mpv --force-window yes {url}'
@ -300,13 +305,10 @@ c.aliases['Download_Youtube_hint'] = 'hint links spawn --userscript ~/.config/qu
config.bind(';v', 'Download_Youtube_hint')
#+END_SRC
Add page to Bookmarks using =buku=
Add page to Bookmarks using =linkding=
#+begin_src python
c.aliases['Bookmark_Add'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/buku-add.sh'
c.aliases['Bookmark_Add'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/linkding-add.sh'
config.bind(',b', 'Bookmark_Add')
c.aliases['Bookmark_Add_Custom'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/buku-rofi.sh'
config.bind(',B', 'Bookmark_Add_Custom')
#+end_src
Download with =aria2c=
@ -318,9 +320,9 @@ c.aliases['Download_Homelab'] = 'hint links spawn --userscript ~/.config/qutebro
config.bind(',D', 'Download_Homelab')
#+end_src
Open bookmark using =buku=
Open bookmark using =linkding=
#+begin_src python
c.aliases['Open_Bookmark'] = 'spawn ~/.local/bin/bukurun'
c.aliases['Open_Bookmark'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/linkding-open.sh'
config.bind(',o', 'Open_Bookmark')
#+end_src
@ -341,16 +343,16 @@ config.bind(';R', 'Org_Capture_hint')
Screenshot of webpage to png
#+begin_src python
c.aliases['Save_PDF'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/html-to-pdf.sh'
c.aliases['Save_PDF'] = 'spawn --userscript html-to-pdf.sh'
config.bind(',s', 'Save_PDF')
c.aliases['Save_PNG'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/html-to-png.sh'
c.aliases['Save_PNG'] = 'spawn --userscript html-to-png.sh'
config.bind(',S', 'Save_PNG')
#+end_src
Download AES video
#+begin_src python
c.aliases['Download_AES'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/aes-download.sh'
c.aliases['Download_AES'] = 'spawn --userscript aes-download.sh'
config.bind(',E', 'Download_AES')
#+end_src
@ -372,6 +374,12 @@ c.aliases['Org_Roam_Save'] = "open javascript:void(location.href='org-protocol:/
config.bind(',R', 'Org_Roam_Save')
#+end_src
Display Current URL as a QRcode (useful to open in on a phone).
#+begin_src python
c.aliases['QRcode'] = "spawn --userscript ~/.config/qutebrowser/userscripts/url-to-qrcode.sh {url}"
config.bind(',q', 'QRcode')
#+end_src
* Userscripts
:PROPERTIES:
:header-args:bash: :shebang "#!/usr/bin/env bash"
@ -587,6 +595,42 @@ Send to Emacs
emacsclient "org-protocol://capture?template=$template&url=$url&title=$heading&body=$body"
#+end_src
** Open Bookmark with Linkding
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/linkding-open.sh
# Verify that environment variable are set
if [[ -z "${LINKDING_URL}" ]]; then
LINKDING_URL=$(pass nas/linkding_url)
fi
if [[ -z "${LINKDING_TOKEN}" ]]; then
LINKDING_TOKEN=$(pass nas/linkding_token)
fi
curl -H "Authorization: Token ${LINKDING_TOKEN}" ${LINKDING_URL}/api/bookmarks/ | jq '.results[] | "\(.title) - \(.url) - [#\((.tag_names | join(", #")))]"' -r | rofi -dmenu -no-custom | grep -Eo 'https?://[^ ]+' | head -1 | xargs -I {} echo "open -t {}" >> "$QUTE_FIFO"
#+end_src
** Add Url to Linkding
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/linkding-add.sh
# Verify that environment variable are set
if [[ -z "${LINKDING_URL}" ]]; then
LINKDING_URL=$(pass nas/linkding_url)
fi
if [[ -z "${LINKDING_TOKEN}" ]]; then
LINKDING_TOKEN=$(pass nas/linkding_token)
fi
title=$(echo "$QUTE_TITLE" | rofi -p "Title" -dmenu -lines 1)
existing_tags=$(curl -H "Authorization: Token ${LINKDING_TOKEN}" ${LINKDING_URL}/api/tags/ | jq '.results[].name' -r | rofi -multi-select -p "Existing tags" -dmenu)
new_tags=$(rofi -p "New tags" -dmenu)
formated_tags=$(echo $existing_tags $new_tags | sed -E 's/(\w+)/"\1"/g;s/\s/,/g')
curl -H "Authorization: Token ${LINKDING_TOKEN}" -H "Content-Type: application/json" -d "{\"url\": \"$QUTE_URL\", \"title\": \"$title\", \"tag_names\": [$formated_tags]}" ${LINKDING_URL}/api/bookmarks/ && \
dunstify "Linkding" " Bookmark Added" || \
dunstify --urgency=critical "Linkding" "Failed"
#+end_src
** Add Url to Buku using Rofi
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/buku-rofi.sh
title=$(echo "$QUTE_TITLE" | rofi -p "Title" -dmenu -lines 1)
@ -639,6 +683,16 @@ if [ -n "$filename" ]; then
fi
#+end_src
** Get OTP number
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/get-otp.sh
passname=$(ls ~/.password-store/totp-* | xargs -n 1 basename | sed -e 's/\..*$//' | rofi -p "TOPT" -dmenu)
if [ -n "$passname" ]; then
pass otp $passname | xsel -ib && \
dunstify 'OTP' 'copied to clipboard.' &
fi
#+end_src
** Download AES video
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/aes-download.sh
m3u8_path=`curl -L -s "$QUTE_URL" | pcregrep -o1 "file = \"\/(.*aes.*mp4)\""`
@ -652,3 +706,8 @@ else
dunstify "Qutebrowser" "$QUTE_TITLE Downloaded"
fi
#+end_src
** Display URL as a QRcode
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/url-to-qrcode.sh
qrencode -o /tmp/qrcode.png "$1" && sxiv /tmp/qrcode.png
#+end_src