2019-01-31 09:41:03 +01:00
|
|
|
#+TITLE: Qutebrowser Configuration
|
2021-01-01 20:12:34 +01:00
|
|
|
#+SETUPFILE: ./setup/org-setup-file.org
|
2019-01-31 09:41:03 +01:00
|
|
|
#+PROPERTY: header-args+ :comments none
|
|
|
|
#+PROPERTY: header-args+ :mkdirp yes
|
|
|
|
#+PROPERTY: header-args+ :tangle ~/.config/qutebrowser/config.py
|
2019-05-16 21:13:08 +02:00
|
|
|
|
|
|
|
* Import
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
from qutebrowser.config.configfiles import ConfigAPI
|
|
|
|
from qutebrowser.config.config import ConfigContainer
|
2019-05-16 21:13:08 +02:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
import sys, os
|
2019-05-16 21:13:08 +02:00
|
|
|
#+end_src
|
2019-01-31 09:41:03 +01:00
|
|
|
|
2021-02-10 17:59:11 +01:00
|
|
|
* Auto Config
|
|
|
|
Do not load config set with =:set= command in qutebrowser.
|
|
|
|
#+begin_src python
|
|
|
|
config.load_autoconfig(True)
|
|
|
|
#+end_src
|
|
|
|
|
2019-01-31 09:41:03 +01:00
|
|
|
* General config
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
c.aliases = {'w': 'session-save', 'q': 'quit', 'wq': 'quit --save'}
|
|
|
|
c.auto_save.session = False
|
|
|
|
c.backend = 'webengine'
|
|
|
|
c.confirm_quit = ['downloads']
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
2021-04-25 19:10:57 +02:00
|
|
|
#+begin_src python
|
|
|
|
c.aliases['paywall'] = "open https://www.google.com/search?q=cache:{url}"
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* Qt
|
|
|
|
Linked to [[https://github.com/qutebrowser/qutebrowser/issues/6401][issue]].
|
|
|
|
#+begin_src python
|
|
|
|
c.qt.workarounds.remove_service_workers = True
|
|
|
|
#+end_src
|
|
|
|
|
2019-01-31 09:41:03 +01:00
|
|
|
* Content
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
c.content.autoplay = False
|
2021-10-25 14:21:31 +02:00
|
|
|
c.content.notifications.enabled = False
|
2021-01-08 01:26:27 +01:00
|
|
|
c.content.geolocation = 'ask'
|
|
|
|
c.content.javascript.alert = True
|
|
|
|
c.content.javascript.can_access_clipboard = True
|
|
|
|
c.content.pdfjs = False
|
|
|
|
c.content.proxy = 'system'
|
2021-02-10 17:59:11 +01:00
|
|
|
c.content.blocking.method = 'both'
|
2021-04-25 19:10:57 +02:00
|
|
|
c.content.blocking.adblock.lists = ['https://easylist.to/easylist/easylist.txt', 'https://easylist.to/easylist/easyprivacy.txt', 'https://secure.fanboy.co.nz/fanboy-cookiemonster.txt']
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
* Editor
|
|
|
|
#+begin_src python
|
2021-10-25 14:21:31 +02:00
|
|
|
c.editor.command = ['/usr/bin/alacritty', '--class', 'terminal,Floating', '-e', 'nvim', '{}']
|
2020-03-19 10:05:55 +01:00
|
|
|
#+end_src
|
|
|
|
|
2019-01-31 09:41:03 +01:00
|
|
|
* Downloads
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
c.downloads.location.directory = '$HOME/Downloads/'
|
|
|
|
c.downloads.location.prompt = True
|
|
|
|
c.downloads.location.remember = True
|
|
|
|
c.downloads.location.suggestion = 'path'
|
|
|
|
c.downloads.position = 'bottom'
|
|
|
|
c.downloads.remove_finished = 10000
|
2021-05-13 18:55:29 +02:00
|
|
|
# c.downloads.open_dispatcher = 'linkhandler'
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
2021-02-10 17:59:11 +01:00
|
|
|
* File Select
|
|
|
|
#+begin_src python
|
|
|
|
c.fileselect.handler = "default"
|
|
|
|
# c.fileselect.single_file.command = ['termine', '-e', 'ranger', '--choosefile', '{}']
|
2021-05-13 18:55:29 +02:00
|
|
|
# c.fileselect.multiple_files.command = ['alacritty', '-e', 'ranger', '--choosefiles', '{}']
|
2021-02-10 17:59:11 +01:00
|
|
|
#+end_src
|
|
|
|
|
2020-11-25 12:22:10 +01:00
|
|
|
* Colors
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
# c.colors.webpage.darkmode.enabled = True
|
2020-11-25 12:22:10 +01:00
|
|
|
#+end_src
|
|
|
|
|
2019-01-31 09:41:03 +01:00
|
|
|
* Fonts
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
c.fonts.default_family = ["Hack Nerd Font Mono", "DejaVu Sans Mono", "Monaco"]
|
|
|
|
c.fonts.prompts = '10pt monospace'
|
|
|
|
c.fonts.statusbar = '10pt monospace'
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Input
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
c.input.insert_mode.auto_enter = True
|
|
|
|
# Very annoying when automatically leave insert mode
|
|
|
|
c.input.insert_mode.auto_leave = False
|
|
|
|
c.input.insert_mode.auto_load = False
|
|
|
|
c.input.insert_mode.plugins = True
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* New Instance Options
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
c.new_instance_open_target = 'tab'
|
|
|
|
c.new_instance_open_target_window = 'last-focused'
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Spell Check
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
c.spellcheck.languages = ['en-US', 'fr-FR']
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Status Bar
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
# Hide the statusbar unless a message is shown.
|
|
|
|
c.statusbar.position = 'bottom'
|
|
|
|
|
|
|
|
# List of widgets displayed in the statusbar.
|
|
|
|
# Valid values:
|
|
|
|
# - url: Current page URL.
|
|
|
|
# - scroll: Percentage of the current page position like `10%`.
|
|
|
|
# - scroll_raw: Raw percentage of the current page position like `10`.
|
|
|
|
# - history: Display an arrow when possible to go back/forward in history.
|
|
|
|
# - tabs: Current active tab, e.g. `2`.
|
|
|
|
# - keypress: Display pressed keys when composing a vi command.
|
|
|
|
# - progress: Progress bar for the current page loading.
|
|
|
|
c.statusbar.widgets = ['keypress', 'url', 'scroll', 'history', 'progress']
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Tabs
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
# Open new tabs (middleclick/ctrl+click) in the background.
|
|
|
|
c.tabs.background = True
|
2020-03-19 10:05:55 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
# Mouse button with which to close tabs.
|
|
|
|
c.tabs.close_mouse_button = 'right'
|
2020-03-19 10:05:55 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
# How to behave when the last tab is closed.
|
2022-02-06 21:49:13 +01:00
|
|
|
c.tabs.last_close = 'ignore'
|
2020-03-19 10:05:55 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
# Switch between tabs using the mouse wheel.
|
|
|
|
c.tabs.mousewheel_switching = False
|
2020-03-19 10:05:55 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
# Position of new tabs opened from another tab.
|
|
|
|
# Valid values:
|
|
|
|
# - prev: Before the current tab.
|
|
|
|
# - next: After the current tab.
|
|
|
|
# - first: At the beginning.
|
|
|
|
# - last: At the end.
|
|
|
|
c.tabs.new_position.related = 'next'
|
2020-03-19 10:05:55 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
# Position of new tabs which aren't opened from another tab.
|
|
|
|
# Valid values:
|
|
|
|
# - prev: Before the current tab.
|
|
|
|
# - next: After the current tab.
|
|
|
|
# - first: At the beginning.
|
|
|
|
# - last: At the end.
|
|
|
|
c.tabs.new_position.unrelated = 'last'
|
2020-03-19 10:05:55 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
# Position of the tab bar.
|
|
|
|
c.tabs.position = 'left'
|
2020-03-19 10:05:55 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
# Which tab to select when the focused tab is removed.
|
|
|
|
c.tabs.select_on_remove = 'next'
|
2020-03-19 10:05:55 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
# Width (in pixels or as percentage of the window) of the tab bar if it's vertical.
|
|
|
|
c.tabs.width = 30
|
2020-03-19 10:05:55 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
# Wrap when changing tabs.
|
|
|
|
c.tabs.wrap = False
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
* Urls and Search Engines
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
c.url.searchengines = {
|
|
|
|
'DEFAULT': 'https://www.duckduckgo.org/?q={}',
|
|
|
|
'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=',
|
|
|
|
'gm': 'https://www.google.com/maps/search/{}/',
|
|
|
|
'gh': 'https://github.com/search?q={}',
|
2022-02-06 21:49:13 +01:00
|
|
|
'yt': 'https://www.youtube.com/results?search_query={}',
|
2021-01-08 01:26:27 +01:00
|
|
|
're': 'https://www.reddit.com/search?q={}',
|
|
|
|
'lb': 'http://gen.lib.rus.ec/search.php?req={}',
|
|
|
|
'la': 'http://gen.lib.rus.ec/scimag/index.php?s={}',
|
|
|
|
'sm': 'https://www.openstreetmap.org/search?query={}',
|
|
|
|
'am': 'https://www.amazon.fr/s?k={}',
|
|
|
|
'md': 'https://fr.mathworks.com/help/search.html?qdoc={}&submitsearch=',
|
|
|
|
'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={}',
|
2021-10-25 14:21:31 +02:00
|
|
|
'lb': 'https://www.leboncoin.fr/recherche?text={}',
|
2021-01-08 01:26:27 +01:00
|
|
|
}
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src python
|
|
|
|
c.url.start_pages = ['https://homer.tdehaeze.xyz/']
|
|
|
|
c.url.default_page = 'https://homer.tdehaeze.xyz/'
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
* Normal Bindings
|
|
|
|
Zooming
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('+', 'zoom-in')
|
|
|
|
config.bind('-', 'zoom-out')
|
|
|
|
config.bind('=', 'zoom')
|
2020-03-19 10:05:55 +01:00
|
|
|
#+end_src
|
2019-03-05 22:07:30 +01:00
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
Inputs blocks
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind(';t', 'hint inputs')
|
|
|
|
config.bind('gi', 'hint inputs --first')
|
2019-03-05 22:07:30 +01:00
|
|
|
#+end_src
|
2019-01-31 09:41:03 +01:00
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
Opening New Window
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('<Ctrl-N>', 'open -w')
|
2020-03-19 10:05:55 +01:00
|
|
|
#+end_src
|
2019-01-31 09:41:03 +01:00
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
History
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('H', 'back')
|
|
|
|
config.bind('L', 'forward')
|
2020-03-19 10:05:55 +01:00
|
|
|
#+end_src
|
2019-01-31 09:41:03 +01:00
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
Move tabs around
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('d', 'tab-close')
|
|
|
|
config.bind('<', 'tab-move -')
|
|
|
|
config.bind('>', 'tab-move +')
|
|
|
|
config.bind('gO', 'tab-give') # Open current tab in a new window
|
|
|
|
config.bind('J', 'tab-next')
|
|
|
|
config.bind('K', 'tab-prev')
|
2020-03-19 10:05:55 +01:00
|
|
|
#+end_src
|
2019-01-31 09:41:03 +01:00
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
Bookmarks and Quickmark
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('M', 'bookmark-add')
|
|
|
|
config.bind('m', 'quickmark-save')
|
2020-03-19 10:05:55 +01:00
|
|
|
#+end_src
|
2019-01-31 09:41:03 +01:00
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
Open New Pages/Tabs
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('o', 'set-cmd-text -s :open')
|
|
|
|
config.bind('O', 'set-cmd-text -s :open -t')
|
2020-03-19 10:05:55 +01:00
|
|
|
#+end_src
|
2019-01-31 09:41:03 +01:00
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
Open new page/tab with clipboard content
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('pp', 'open -- {clipboard}')
|
|
|
|
config.bind('pP', 'open -t -- {clipboard}')
|
2020-03-19 10:05:55 +01:00
|
|
|
#+end_src
|
2019-01-31 09:41:03 +01:00
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
Link Hinting
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('f', 'hint')
|
|
|
|
config.bind('F', 'hint all tab')
|
2020-03-19 10:05:55 +01:00
|
|
|
#+end_src
|
2019-01-31 09:41:03 +01:00
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
Yanking url
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('yy', 'yank')
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
Go to specific websites
|
|
|
|
#+begin_src python
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('gy', 'open -t https://www.youtube.com/feed/subscriptions')
|
|
|
|
config.bind('gf', 'open -t https://rss.tdehaeze.xyz/')
|
|
|
|
config.bind('gr', 'open -t https://www.reddit.com/')
|
2020-03-19 10:05:55 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('gh', 'open -t https://homer.tdehaeze.xyz/')
|
2022-02-06 21:49:13 +01:00
|
|
|
config.bind('ge', 'open -t http://intranet.esrf.fr/')
|
|
|
|
config.bind('gc', 'open -t https://calendar.esrf.fr/')
|
2020-11-03 11:40:49 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
config.bind('gb', 'open -t qute://bookmarks')
|
|
|
|
config.bind('gH', 'open -t qute://history')
|
|
|
|
config.bind('gs', 'open -t qute://settings')
|
2020-03-19 10:05:55 +01:00
|
|
|
#+end_src
|
|
|
|
|
2022-02-06 21:49:13 +01:00
|
|
|
Quit.
|
|
|
|
#+begin_src python
|
|
|
|
config.bind('D', 'close')
|
|
|
|
#+end_src
|
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
* Custom Bindings
|
|
|
|
Create a Password for the current website
|
|
|
|
#+begin_src python
|
2021-05-13 18:55:29 +02:00
|
|
|
c.aliases['Password_Add'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/add-passowrd.sh'
|
|
|
|
config.bind(',P', 'Password_Add')
|
2020-03-01 18:56:33 +01:00
|
|
|
#+end_src
|
|
|
|
|
2022-02-07 16:15:50 +01:00
|
|
|
#+begin_src python
|
|
|
|
c.aliases['proxy_on'] = 'set content.proxy socks5://localhost:8080'
|
|
|
|
c.aliases['proxy_off'] = 'config-unset content.proxy'
|
|
|
|
#+end_src
|
|
|
|
|
2020-03-22 19:47:54 +01:00
|
|
|
Use Pass to fill password and username (configuration is done in =~/.config/qutebrowser/password_fill_rc=)
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-05-13 18:55:29 +02:00
|
|
|
c.aliases['Password_Fill'] = 'spawn --userscript password_fill'
|
|
|
|
config.bind(',p', 'Password_Fill')
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
2021-10-25 14:21:31 +02:00
|
|
|
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
|
|
|
|
|
2020-03-22 19:47:54 +01:00
|
|
|
Open Youtube video using =mpv=
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-05-13 18:55:29 +02:00
|
|
|
c.aliases['MPV_view'] = 'spawn --detach mpv --force-window yes {url}'
|
|
|
|
config.bind(',m', 'MPV_view')
|
|
|
|
|
|
|
|
c.aliases['MPV_view_hint'] = 'hint links spawn --detach mpv --force-window yes {hint-url}'
|
|
|
|
config.bind(';m', 'MPV_view_hint')
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
|
|
|
|
2020-04-10 16:38:44 +02:00
|
|
|
Download Youtube video / entire playlist
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-05-13 18:55:29 +02:00
|
|
|
c.aliases['Download_Youtube'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/yt-download.sh {url}'
|
|
|
|
config.bind(',v', 'Download_Youtube')
|
|
|
|
|
|
|
|
c.aliases['Download_Youtube_hint'] = 'hint links spawn --userscript ~/.config/qutebrowser/userscripts/yt-download.sh {hint-url}'
|
|
|
|
config.bind(';v', 'Download_Youtube_hint')
|
2019-01-31 09:41:03 +01:00
|
|
|
#+END_SRC
|
2019-01-31 12:05:45 +01:00
|
|
|
|
2021-10-25 14:21:31 +02:00
|
|
|
Add page to Bookmarks using =linkding=
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-10-25 14:21:31 +02:00
|
|
|
c.aliases['Bookmark_Add'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/linkding-add.sh'
|
2021-05-13 18:55:29 +02:00
|
|
|
config.bind(',b', 'Bookmark_Add')
|
2019-03-05 22:07:30 +01:00
|
|
|
#+end_src
|
|
|
|
|
2020-05-05 00:00:45 +02:00
|
|
|
Download with =aria2c=
|
|
|
|
#+begin_src python
|
2021-05-13 18:55:29 +02:00
|
|
|
c.aliases['Download_Local'] = 'hint links spawn --userscript ~/.config/qutebrowser/userscripts/aria2c-add.sh {hint-url}'
|
|
|
|
config.bind(',d', 'Download_Local')
|
|
|
|
|
|
|
|
c.aliases['Download_Homelab'] = 'hint links spawn --userscript ~/.config/qutebrowser/userscripts/aria2c-add-homelab.sh {hint-url}'
|
|
|
|
config.bind(',D', 'Download_Homelab')
|
2020-05-05 00:00:45 +02:00
|
|
|
#+end_src
|
|
|
|
|
2021-10-25 14:21:31 +02:00
|
|
|
Open bookmark using =linkding=
|
2020-03-19 10:05:55 +01:00
|
|
|
#+begin_src python
|
2021-10-25 14:21:31 +02:00
|
|
|
c.aliases['Open_Bookmark'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/linkding-open.sh'
|
2021-05-13 18:55:29 +02:00
|
|
|
config.bind(',o', 'Open_Bookmark')
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Open with =linkhandler=
|
|
|
|
#+begin_src python
|
|
|
|
c.aliases['Open_Default'] = 'hint links spawn --detach linkhandler {hint-url}'
|
|
|
|
config.bind(',O', 'Open_Default')
|
2019-03-05 22:07:30 +01:00
|
|
|
#+end_src
|
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
Org Capture
|
|
|
|
#+begin_src python
|
2021-05-13 18:55:29 +02:00
|
|
|
c.aliases['Org_Capture'] = 'spawn --userscript ~/.config/qutebrowser/userscripts/org-capture.sh'
|
|
|
|
config.bind(',r', 'Org_Capture')
|
|
|
|
|
|
|
|
c.aliases['Org_Capture_hint'] = 'hint links userscript ~/.config/qutebrowser/userscripts/org-capture.sh'
|
|
|
|
config.bind(';R', 'Org_Capture_hint')
|
2019-12-15 10:57:51 +01:00
|
|
|
#+end_src
|
|
|
|
|
2020-06-03 13:41:20 +02:00
|
|
|
Screenshot of webpage to png
|
|
|
|
#+begin_src python
|
2021-10-25 14:21:31 +02:00
|
|
|
c.aliases['Save_PDF'] = 'spawn --userscript html-to-pdf.sh'
|
2021-05-13 18:55:29 +02:00
|
|
|
config.bind(',s', 'Save_PDF')
|
|
|
|
|
2021-10-25 14:21:31 +02:00
|
|
|
c.aliases['Save_PNG'] = 'spawn --userscript html-to-png.sh'
|
2021-05-13 18:55:29 +02:00
|
|
|
config.bind(',S', 'Save_PNG')
|
2020-06-03 13:41:20 +02:00
|
|
|
#+end_src
|
|
|
|
|
2021-01-01 20:12:34 +01:00
|
|
|
Download AES video
|
|
|
|
#+begin_src python
|
2021-10-25 14:21:31 +02:00
|
|
|
c.aliases['Download_AES'] = 'spawn --userscript aes-download.sh'
|
2021-05-13 18:55:29 +02:00
|
|
|
config.bind(',E', 'Download_AES')
|
2021-01-01 20:12:34 +01:00
|
|
|
#+end_src
|
|
|
|
|
2020-03-27 15:38:04 +01:00
|
|
|
Download a torrent
|
|
|
|
#+begin_src python
|
2021-05-13 18:55:29 +02:00
|
|
|
c.aliases['Download_Torrent_Homelab'] = 'hint links spawn torrent-add {hint-url}'
|
|
|
|
config.bind(',t', 'Download_Torrent_Homelab')
|
2019-12-01 17:15:03 +01:00
|
|
|
#+end_src
|
2019-12-15 10:57:51 +01:00
|
|
|
|
2020-03-19 10:05:55 +01:00
|
|
|
See Amazon price history using CamelCamelCamel
|
|
|
|
#+begin_src python
|
2021-05-13 18:55:29 +02:00
|
|
|
c.aliases['CamelCamelCamel'] = 'open -t https://fr.camelcamelcamel.com/search?sq={url}'
|
|
|
|
config.bind(',A', 'CamelCamelCamel')
|
2019-12-29 15:11:49 +01:00
|
|
|
#+end_src
|
|
|
|
|
2020-05-26 08:35:32 +02:00
|
|
|
Org Roam Entry for the current page
|
|
|
|
#+begin_src python
|
2021-05-13 18:55:29 +02:00
|
|
|
c.aliases['Org_Roam_Save'] = "open javascript:void(location.href='org-protocol://roam-ref?template=r&ref='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title))"
|
|
|
|
config.bind(',R', 'Org_Roam_Save')
|
2021-02-10 17:59:11 +01:00
|
|
|
#+end_src
|
|
|
|
|
2021-10-25 14:21:31 +02:00
|
|
|
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
|
|
|
|
|
2019-01-31 12:05:45 +01:00
|
|
|
* Userscripts
|
2020-03-01 18:56:33 +01:00
|
|
|
:PROPERTIES:
|
2020-04-10 16:38:44 +02:00
|
|
|
:header-args:bash: :shebang "#!/usr/bin/env bash"
|
|
|
|
:header-args:bash+: :comments both :mkdirp yes
|
2020-11-25 12:22:10 +01:00
|
|
|
:header-args:python: :shebang "#!/usr/bin/env python3"
|
|
|
|
:header-args:python+: :comments both :mkdirp yes
|
2020-03-01 18:56:33 +01:00
|
|
|
:END:
|
|
|
|
|
2021-05-13 18:55:29 +02:00
|
|
|
[[https://qutebrowser.org/doc/userscripts.html][Here]] is the documentation related to userscripts.
|
|
|
|
|
2020-04-10 16:38:44 +02:00
|
|
|
** Create a new password
|
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/add-passowrd.sh
|
2021-01-08 01:26:27 +01:00
|
|
|
url=$(echo "$QUTE_URL" | awk -F[/:] '{print $4}' | rofi -p "URL" -dmenu -lines 1)
|
|
|
|
username=$(echo -e "dehaeze.thomas@gmail.com\nthomas.dehaeze@esrf.fr\ntdehaeze" | rofi -p "Username" -dmenu -lines 5)
|
|
|
|
password=$(rofi -p "Password" -dmenu -password -lines 1)
|
2020-03-01 18:56:33 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
if [ -z "$url" ] || [ -z "$username" ] || [ -z "$password" ]; then
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:0vRM5AMP --urgency=critical "Pass" "Failed to Add Password"
|
2021-01-08 01:26:27 +01:00
|
|
|
else
|
|
|
|
echo -e "$password\nlogin: $username\nurl: $QUTE_URL" > /tmp/add-password.txt
|
|
|
|
pass insert --multiline "$url/$username" < /tmp/add-password.txt;
|
|
|
|
rm /tmp/add-password.txt
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:0vRM5AMP "Pass " "Password Added"
|
2021-01-08 01:26:27 +01:00
|
|
|
fi
|
2020-03-01 18:56:33 +01:00
|
|
|
#+end_src
|
|
|
|
|
2020-04-10 16:38:44 +02:00
|
|
|
** Download Youtube Video
|
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/yt-download.sh
|
2021-01-08 01:26:27 +01:00
|
|
|
cd ~/Documents/to-watch/ || exit;
|
2020-04-10 16:38:44 +02:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
if [[ "$1" == *"list"* ]]; then
|
|
|
|
choice=$(echo -e "Video\nPlaylist" | rofi -dmenu -only-match -i)
|
|
|
|
fi
|
2020-04-10 16:38:44 +02:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
if [ -n "$choice" ] && [ "$choice" = "Playlist" ]; then
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:iOGRwrDG "Youtube " "Downloading Playlist...";
|
2021-01-08 01:26:27 +01:00
|
|
|
youtube-dl -i -f 'bestvideo[height<=720]+bestaudio/best[height<=720]' "$1" -o "%(playlist_title)s/%(playlist_index)s-%(title)s.%(ext)s" && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:iOGRwrDG "Youtube " "Downloaded" || \
|
|
|
|
notify-send --hint=string:x-dunst-stack-tag:iOGRwrDG --urgency=critical "Youtube " "Failed to download"
|
2021-01-08 01:26:27 +01:00
|
|
|
else
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:iOGRwrDG "Youtube " "Downloading Video...";
|
2021-01-08 01:26:27 +01:00
|
|
|
youtube-dl --no-playlist -f 'bestvideo[height<=720]+bestaudio/best[height<=720]' "$1" && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:iOGRwrDG "Youtube " "Downloaded" || \
|
|
|
|
notify-send --hint=string:x-dunst-stack-tag:iOGRwrDG --urgency=critical "Youtube " "Failed to download"
|
2021-01-08 01:26:27 +01:00
|
|
|
fi
|
2019-05-16 21:13:08 +02:00
|
|
|
#+end_src
|
|
|
|
|
2019-04-08 17:50:44 +02:00
|
|
|
** Password_fill_rc
|
2020-04-10 16:38:44 +02:00
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/password_fill_rc
|
2021-01-08 01:26:27 +01:00
|
|
|
# Show all password fields in the menu
|
|
|
|
query_entries() {
|
|
|
|
# safe queried url for choose_entry
|
|
|
|
# the subdomains are removed
|
|
|
|
export queried_url=$(expr match ".$1" '.*\.\(.*\..*\)')
|
|
|
|
mapfile -t files < <(find -L "$PREFIX" -iname '*.gpg' -printf '%P\n' |sed 's,\.gpg$,,')
|
|
|
|
}
|
|
|
|
|
|
|
|
# Even if there is only one entry, always show a menu
|
|
|
|
# for user confirmation.
|
|
|
|
choose_entry() {
|
|
|
|
MENU_COMMAND=(
|
|
|
|
rofi -dmenu
|
|
|
|
-p "qutebrowser> "
|
|
|
|
-filter "$queried_url"
|
|
|
|
-mesg $'Pick a password entry for <b>'"${QUTE_URL//&/&}"'</b>'
|
|
|
|
)
|
|
|
|
file=$( printf "%s\n" "${files[@]}" | "${MENU_COMMAND[@]}" )
|
|
|
|
}
|
2019-04-08 17:50:44 +02:00
|
|
|
#+end_src
|
2020-03-01 18:56:33 +01:00
|
|
|
|
2019-12-15 10:57:51 +01:00
|
|
|
** Org-Capture
|
2020-04-10 16:38:44 +02:00
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/org-capture.sh
|
2021-01-08 01:26:27 +01:00
|
|
|
readonly CAPTURE_SCRIPT=~/.config/qutebrowser/userscripts/org-protocol-capture-html.sh
|
2019-12-15 10:57:51 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
if [[ "$QUTE_MODE" = "hints" ]]; then
|
|
|
|
# if we start with hints, we juste want to capture the URL
|
|
|
|
$CAPTURE_SCRIPT --template "pu" --url "${QUTE_URL}"
|
|
|
|
elif [[ -n "$QUTE_SELECTED_TEXT" ]]; then
|
|
|
|
# if text is selected, we want to capture the text
|
|
|
|
$CAPTURE_SCRIPT --template "pt" --heading "${QUTE_TITLE}" --url "${QUTE_URL}" "${QUTE_SELECTED_TEXT}"
|
|
|
|
else
|
|
|
|
# if no text is selected, we want to capture the url
|
|
|
|
$CAPTURE_SCRIPT --template "pu" --heading "${QUTE_TITLE}" --url "${QUTE_URL}"
|
|
|
|
fi
|
2019-12-15 10:57:51 +01:00
|
|
|
#+end_src
|
2020-03-01 18:56:33 +01:00
|
|
|
|
2020-04-06 23:56:37 +02:00
|
|
|
** Org-Protocol-Capture-HTML
|
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/qutebrowser/userscripts/org-protocol-capture-html.sh
|
|
|
|
:END:
|
|
|
|
|
|
|
|
Defaults
|
|
|
|
#+begin_src bash
|
2021-01-08 01:26:27 +01:00
|
|
|
heading="link"
|
|
|
|
template="pu"
|
|
|
|
url="https://google.com/"
|
2020-04-06 23:56:37 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Functions
|
|
|
|
#+begin_src bash
|
2021-01-08 01:26:27 +01:00
|
|
|
function debug {
|
|
|
|
if [[ -n $debug ]]
|
|
|
|
then
|
|
|
|
function debug {
|
|
|
|
echo "DEBUG: $@" >&2
|
|
|
|
}
|
|
|
|
debug "$@"
|
|
|
|
else
|
|
|
|
function debug {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
function die {
|
|
|
|
echo "$@" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
function urlencode {
|
|
|
|
python -c "
|
|
|
|
from __future__ import print_function
|
|
|
|
try:
|
|
|
|
from urllib import quote # Python 2
|
|
|
|
except ImportError:
|
|
|
|
from urllib.parse import quote # Python 3
|
|
|
|
import sys
|
|
|
|
print(quote(sys.stdin.read()[:-1], safe=''))"
|
|
|
|
}
|
2020-04-06 23:56:37 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Documentation
|
|
|
|
#+begin_src bash
|
2021-01-08 01:26:27 +01:00
|
|
|
function usage {
|
|
|
|
cat <<EOF
|
|
|
|
$0 [OPTIONS] [HTML]
|
|
|
|
html | $0 [OPTIONS]
|
|
|
|
Send HTML to Emacs through org-protocol, passing it through Pandoc to
|
|
|
|
convert HTML to Org-mode. HTML may be passed as an argument or
|
|
|
|
through STDIN. If only URL is given, it will be downloaded and its
|
|
|
|
contents used.
|
|
|
|
Options:
|
|
|
|
-h, --heading HEADING Heading
|
|
|
|
-t, --template TEMPLATE org-capture template key (default: pu)
|
|
|
|
-u, --url URL URL
|
|
|
|
--debug Print debug info
|
|
|
|
--help I need somebody!
|
|
|
|
EOF
|
|
|
|
}
|
2020-04-06 23:56:37 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Arguments
|
|
|
|
#+begin_src bash
|
2021-01-08 01:26:27 +01:00
|
|
|
args=$(getopt -n "$0" -o dh:rt:u: -l debug,help,heading:,template:,url: -- "$@") \
|
|
|
|
|| die "Unable to parse args. Is getopt installed?"
|
|
|
|
eval set -- "$args"
|
|
|
|
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
-d|--debug)
|
|
|
|
debug=true
|
|
|
|
debug "Debugging on"
|
|
|
|
;;
|
|
|
|
--help)
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
-h|--heading)
|
|
|
|
shift
|
|
|
|
heading="$1"
|
|
|
|
;;
|
|
|
|
-t|--template)
|
|
|
|
shift
|
|
|
|
template="$1"
|
|
|
|
;;
|
|
|
|
-u|--url)
|
|
|
|
shift
|
|
|
|
url="$1"
|
|
|
|
;;
|
|
|
|
--)
|
|
|
|
# Remaining args
|
|
|
|
shift
|
|
|
|
rest=("$@")
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
debug "ARGS: $args"
|
|
|
|
debug "Remaining args: ${rest[@]}"
|
2020-04-06 23:56:37 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Get HTML
|
|
|
|
#+begin_src bash
|
2021-01-08 01:26:27 +01:00
|
|
|
if [[ -n $@ ]]
|
|
|
|
then
|
|
|
|
debug "Text from args"
|
2020-04-06 23:56:37 +02:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
body="$@"
|
|
|
|
fi
|
2020-04-06 23:56:37 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
URL-encode
|
|
|
|
#+begin_src bash
|
2021-01-08 01:26:27 +01:00
|
|
|
heading=$(urlencode <<<"$heading") || die "Unable to urlencode heading."
|
|
|
|
url=$(urlencode <<<"$url") || die "Unable to urlencode URL."
|
|
|
|
body=$(urlencode <<<"$body") || die "Unable to urlencode text."
|
2020-04-06 23:56:37 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Send to Emacs
|
|
|
|
#+begin_src bash
|
2021-01-08 01:26:27 +01:00
|
|
|
emacsclient "org-protocol://capture?template=$template&url=$url&title=$heading&body=$body"
|
2020-04-06 23:56:37 +02:00
|
|
|
#+end_src
|
|
|
|
|
2021-10-25 14:21:31 +02:00
|
|
|
** 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/ && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:l3gV75RD "Linkding" " Bookmark Added" || \
|
|
|
|
notify-send --hint=string:x-dunst-stack-tag:l3gV75RD --urgency=critical "Linkding" "Failed"
|
2021-10-25 14:21:31 +02:00
|
|
|
#+end_src
|
|
|
|
|
2019-12-15 10:57:51 +01:00
|
|
|
** Add Url to Buku using Rofi
|
2020-04-10 16:38:44 +02:00
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/buku-rofi.sh
|
2021-01-08 01:26:27 +01:00
|
|
|
title=$(echo "$QUTE_TITLE" | rofi -p "Title" -dmenu -lines 1)
|
|
|
|
tags=$(buku -t --nc --np | sed -e 's/\s*[[:digit:]]*\.\s*\(.*\)\s*([[:digit:]]*)\s*/\1/' -e '/^\s*$/d' | sort | uniq | rofi -multi-select -p "Tags" -dmenu | tr "\n" "," | sed 's/\s*,\s*$//')
|
2019-12-15 10:57:51 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
buku --add "$QUTE_URL" --tag "$tags" --title "$title" && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:E3TueNZ0 "Buku" "Bookmark Added" || \
|
|
|
|
notify-send --hint=string:x-dunst-stack-tag:E3TueNZ0 --urgency=critical "Buku" " Bookmark Added"
|
2020-03-22 19:47:54 +01:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Add Url to Buku without asking for information
|
2020-04-10 16:38:44 +02:00
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/buku-add.sh
|
2021-01-08 01:26:27 +01:00
|
|
|
buku --add $QUTE_URL --title "$QUTE_TITLE" && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send "Buku" "📑 Bookmark Added"
|
2019-12-15 10:57:51 +01:00
|
|
|
#+end_src
|
2020-06-03 13:41:20 +02:00
|
|
|
|
2020-05-05 00:00:45 +02:00
|
|
|
** Download with aria2c
|
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/aria2c-add.sh
|
2021-01-08 01:26:27 +01:00
|
|
|
aria2p add "$1" && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:2SGClDoI "Aria2" "Download Started" || \
|
|
|
|
notify-send --hint=string:x-dunst-stack-tag:2SGClDoI "Aria2" "Error"
|
2020-11-03 11:40:49 +01:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Download with aria2c on the Homelab
|
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/aria2c-add-homelab.sh
|
2021-01-08 01:26:27 +01:00
|
|
|
dl-add $(echo "$1" | sed 's/\&af=.*$//g') && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:2SGClDoI "Aria2" "Download Started" || \
|
|
|
|
notify-send --hint=string:x-dunst-stack-tag:2SGClDoI "Aria2" "Error"
|
2020-05-05 00:00:45 +02:00
|
|
|
#+end_src
|
2020-06-03 13:41:20 +02:00
|
|
|
|
2021-05-13 18:55:29 +02:00
|
|
|
** Save to PNG
|
2020-06-03 13:41:20 +02:00
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/html-to-png.sh
|
2021-01-08 01:26:27 +01:00
|
|
|
filename=$(rofi -p "filename" -dmenu -lines 1)
|
2020-06-03 13:41:20 +02:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
if [ -n "filename" ]; then
|
|
|
|
cd ~/Pictures/ && \
|
2022-02-20 22:06:42 +01:00
|
|
|
firefox -P default -headless --screenshot "$filename.png" "$QUTE_URL" && \
|
2022-02-06 21:49:13 +01:00
|
|
|
notify-send "Screenshot" "Taken successfully"
|
2021-01-08 01:26:27 +01:00
|
|
|
fi
|
2020-11-03 11:40:49 +01:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Save to PDF
|
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/html-to-pdf.sh
|
2021-01-08 01:26:27 +01:00
|
|
|
filename=$(rofi -p "filename" -dmenu -lines 1)
|
2020-06-03 13:41:20 +02:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
if [ -n "$filename" ]; then
|
|
|
|
cd ~/Pictures/ && \
|
|
|
|
percollate pdf --css "@page { size: A4 portrait }" --output "$filename.pdf" "$QUTE_URL" && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send "Percollate" "Successfully saved to pdf"
|
2021-01-08 01:26:27 +01:00
|
|
|
fi
|
2020-06-03 13:41:20 +02:00
|
|
|
#+end_src
|
2021-01-01 20:12:34 +01:00
|
|
|
|
2021-10-25 14:21:31 +02:00
|
|
|
** 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 && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send 'OTP' 'copied to clipboard.' &
|
2021-10-25 14:21:31 +02:00
|
|
|
fi
|
|
|
|
#+end_src
|
|
|
|
|
2021-01-01 20:12:34 +01:00
|
|
|
** Download AES video
|
|
|
|
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/aes-download.sh
|
2021-01-08 01:26:27 +01:00
|
|
|
m3u8_path=`curl -L -s "$QUTE_URL" | pcregrep -o1 "file = \"\/(.*aes.*mp4)\""`
|
|
|
|
|
|
|
|
if [ -z "$m3u8_path" ]; then
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:ng4iXDxP --urgency=critical "Qutebrowser" "No m3u8 playlist found"
|
2021-01-08 01:26:27 +01:00
|
|
|
else
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:ng4iXDxP "Qutebrowser" "Downloads..." && \
|
2021-01-08 01:26:27 +01:00
|
|
|
cd ~/Downloads/ && \
|
|
|
|
ffmpeg -user_agent "Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0" -referer "$QUTE_URL" -i "https://cdn2.digitellinc.com/play/_definst_/mp4:$m3u8_path/playlist.m3u8" -c copy "$QUTE_TITLE.mp4" && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send --hint=string:x-dunst-stack-tag:ng4iXDxP "Qutebrowser" "$QUTE_TITLE Downloaded"
|
2021-01-08 01:26:27 +01:00
|
|
|
fi
|
2021-01-01 20:12:34 +01:00
|
|
|
#+end_src
|
2021-10-25 14:21:31 +02:00
|
|
|
|
|
|
|
** 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
|