Add bindings to save page as pdf/png

This commit is contained in:
Thomas Dehaeze 2020-11-03 11:40:49 +01:00
parent 4be6dab2cb
commit a42fa4c652

View File

@ -69,7 +69,6 @@
c.fonts.default_family = ["Hack Nerd Font Mono", "DejaVu Sans Mono", "Monaco"]
c.fonts.prompts = '10pt monospace'
c.fonts.statusbar = '10pt monospace'
c.fonts.tabs = '10pt monospace'
#+END_SRC
* Input
@ -94,7 +93,6 @@
* Status Bar
#+begin_src python
# Hide the statusbar unless a message is shown.
c.statusbar.hide = False
c.statusbar.position = 'bottom'
# List of widgets displayed in the statusbar.
@ -176,7 +174,7 @@
#+end_src
#+begin_src python
c.url.start_pages = ['qute://bookmarks']
c.url.start_pages = ['https://homer.tdehaeze.xyz/']
#+END_SRC
* Normal Bindings
@ -246,12 +244,14 @@ Yanking url
Go to specific websites
#+begin_src python
config.bind('gy', 'open -t https://www.youtube.com/feed/subscriptions')
config.bind('gf', 'open -t https://feedly.com/i/my')
config.bind('gf', 'open -t https://rss.tdehaeze.xyz/')
config.bind('gr', 'open -t https://www.reddit.com/')
config.bind('gb', 'open qute://bookmarks')
config.bind('gh', 'open qute://history')
config.bind('gs', 'open qute://settings')
config.bind('gh', 'open -t https://homer.tdehaeze.xyz/')
config.bind('gb', 'open -t qute://bookmarks')
config.bind('gH', 'open -t qute://history')
config.bind('gs', 'open -t qute://settings')
#+end_src
* Custom Bindings
@ -286,6 +286,7 @@ Add page to Bookmarks using =buku=
Download with =aria2c=
#+begin_src python
config.bind(',d', 'hint links spawn --userscript ~/.config/qutebrowser/userscripts/aria2c-add.sh {hint-url}')
config.bind(',D', 'hint links spawn --userscript ~/.config/qutebrowser/userscripts/aria2c-add-homelab.sh {hint-url}')
#+end_src
Open bookmark using =buku=
@ -301,7 +302,8 @@ Org Capture
Screenshot of webpage to png
#+begin_src python
config.bind(',s', 'spawn --userscript ~/.config/qutebrowser/userscripts/html-to-png.sh')
config.bind(',s', 'spawn --userscript ~/.config/qutebrowser/userscripts/html-to-pdf.sh')
config.bind(',S', 'spawn --userscript ~/.config/qutebrowser/userscripts/html-to-png.sh')
#+end_src
Download a torrent
@ -547,19 +549,45 @@ Send to Emacs
** Add Url to Buku without asking for information
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/buku-add.sh
buku --add $QUTE_URL --title "$QUTE_TITLE" && dunstify "Buku" "📑 Bookmark Added"
buku --add $QUTE_URL --title "$QUTE_TITLE" && \
dunstify "Buku" "📑 Bookmark Added"
#+end_src
** Download with aria2c
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/aria2c-add.sh
aria2p add "$1"
aria2p add "$1" && \
dunstify "Aria2" "Download Started" || \
dunstify "Aria2" "Error"
#+end_src
** Download with aria2c on the Homelab
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/aria2c-add-homelab.sh
# Remove the =&af= from 1fichier.
$url=$(echo "$1" | sed 's/\&af=.*$//g')
dlab add "$url" && \
dunstify "Aria2" "Download Started" || \
dunstify "Aria2" "Error"
#+end_src
** Screenshot
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/html-to-png.sh
filename=$(rofi -p "filename" -dmenu -lines 1)
cd ~/Pictures/;
firefox-developer-edition -P default -headless --screenshot "$filename.png" "$QUTE_URL"
if [ -n "filename" ]; then
cd ~/Pictures/ && \
firefox-developer-edition -P default -headless --screenshot "$filename.png" "$QUTE_URL" && \
dunstify "Screenshot" "Taken successfully"
fi
#+end_src
** Save to PDF
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/html-to-pdf.sh
filename=$(rofi -p "filename" -dmenu -lines 1)
if [ -n "filename" ]; then
cd ~/Pictures/ && \
percollate pdf --css "@page { size: A4 portrait }" --output "$filename.pdf" "$QUTE_URL" && \
dunstify "Percollate" "Successfully saved to pdf"
fi
#+end_src