qutebrowser: Fix git tracking, Add translate script
Added script to quickly translate a page or selected text through google translate. Can be invoked through the aliases `:translate-page` or `:translate-selection` respectively, or the shortcuts <leader>bg, <leader>bG. Added some gitignore files in the directory to stop keeping track of non-personal configuration files.
This commit is contained in:
parent
bc534e2026
commit
845b98d22d
5 changed files with 83 additions and 15 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -19,6 +19,9 @@ sponsorblock.txt
|
||||||
|
|
||||||
# ignore any just-in-time settings that took place in qutebrowser
|
# ignore any just-in-time settings that took place in qutebrowser
|
||||||
qutebrowser/.config/qutebrowser/autoconfig.yml
|
qutebrowser/.config/qutebrowser/autoconfig.yml
|
||||||
|
qutebrowser/.config/qutebrowser/qsettings
|
||||||
|
qutebrowser/.config/qutebrowser/bookmarks
|
||||||
|
qutebrowser/.config/qutebrowser/stylesheets
|
||||||
|
|
||||||
# ignore vifm & ueberzug utility files
|
# ignore vifm & ueberzug utility files
|
||||||
vifm-help.txt
|
vifm-help.txt
|
||||||
|
|
|
@ -31,22 +31,23 @@ js_whitelist = [
|
||||||
"*://*.youtube.com/*",
|
"*://*.youtube.com/*",
|
||||||
"*://127.0.0.1/*",
|
"*://127.0.0.1/*",
|
||||||
"*://asciinema.org/*",
|
"*://asciinema.org/*",
|
||||||
|
"*://calendar.google.com/*",
|
||||||
|
"*://clockify.me/tracker*",
|
||||||
"*://darksky.net/*",
|
"*://darksky.net/*",
|
||||||
"*://deepl.com/*",
|
"*://deepl.com/*",
|
||||||
"*://duckduckgo.com/*",
|
"*://duckduckgo.com/*",
|
||||||
|
"*://fosstodon.org/*",
|
||||||
"*://github.com/*",
|
"*://github.com/*",
|
||||||
"*://gitlab.com/*",
|
"*://gitlab.com/*",
|
||||||
"*://localhost/*",
|
"*://localhost/*",
|
||||||
"*://fosstodon.org/*",
|
|
||||||
"*://mail.google.com/*",
|
"*://mail.google.com/*",
|
||||||
"*://maps.google.com/*",
|
"*://maps.google.com/*",
|
||||||
|
"*://*.martyoeh.me/*"
|
||||||
"*://news.ycombinator.com/*",
|
"*://news.ycombinator.com/*",
|
||||||
"*://old.reddit.com/*",
|
"*://old.reddit.com/*",
|
||||||
"*://todoist.com/*",
|
"*://todoist.com/*",
|
||||||
"*://toggl.com/*",
|
"*://toggl.com/*",
|
||||||
"*://clockify.me/tracker*",
|
|
||||||
"*://translate.google.com/*",
|
"*://translate.google.com/*",
|
||||||
"*://calendar.google.com/*",
|
|
||||||
"chrome://*/*",
|
"chrome://*/*",
|
||||||
"file://*",
|
"file://*",
|
||||||
"qute://*/*",
|
"qute://*/*",
|
||||||
|
@ -74,7 +75,7 @@ config.source('colorscheme.py')
|
||||||
# should be visible to prevent 'jumping' bug,
|
# should be visible to prevent 'jumping' bug,
|
||||||
# see https://github.com/qutebrowser/qutebrowser/issues/2236
|
# see https://github.com/qutebrowser/qutebrowser/issues/2236
|
||||||
# TODO think about implementing a simple toggle for the statusbar
|
# TODO think about implementing a simple toggle for the statusbar
|
||||||
c.statusbar.show = "in-mode"
|
c.statusbar.show = "always"
|
||||||
|
|
||||||
c.colors.webpage.bg = "#555555"
|
c.colors.webpage.bg = "#555555"
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@ c.session.lazy_restore = True
|
||||||
leader = "<Space>"
|
leader = "<Space>"
|
||||||
|
|
||||||
# toggles ('cycles') between tabs always showing, or only when switching between them
|
# toggles ('cycles') between tabs always showing, or only when switching between them
|
||||||
config.bind(leader + "tt", "config-cycle -t tabs.show switching always")
|
config.bind(leader + "tt", "config-cycle -t tabs.show always switching;; config-cycle -t statusbar.show always in-mode")
|
||||||
config.bind(leader + "th", "set tabs.position bottom")
|
config.bind(leader + "th", "set tabs.position bottom")
|
||||||
config.bind(leader + "tH", "set tabs.position top")
|
config.bind(leader + "tH", "set tabs.position top")
|
||||||
config.bind(leader + "tv", "set tabs.position right")
|
config.bind(leader + "tv", "set tabs.position right")
|
||||||
|
@ -125,6 +126,11 @@ config.bind(leader + "bs", "add-shaarli", mode="normal")
|
||||||
# re-opens the current page on the web archive overview page
|
# re-opens the current page on the web archive overview page
|
||||||
c.aliases["archive-open"] = "open https://web.archive.org/web/{url}"
|
c.aliases["archive-open"] = "open https://web.archive.org/web/{url}"
|
||||||
config.bind(leader + "ba", "archive-open", mode="normal")
|
config.bind(leader + "ba", "archive-open", mode="normal")
|
||||||
|
# translate current page / selection with google translate
|
||||||
|
c.aliases["translate-page"] = "spawn --userscript translate_google.sh"
|
||||||
|
c.aliases["translate-selection"] = "spawn --userscript translate_google.sh --text"
|
||||||
|
config.bind(leader + "bg", "translate-page", mode="normal")
|
||||||
|
config.bind(leader + "bG", "translate-selection", mode="normal")
|
||||||
|
|
||||||
# save current page to pdf file
|
# save current page to pdf file
|
||||||
c.aliases["printpdf"] = "spawn --userscript pagetopdf.sh"
|
c.aliases["printpdf"] = "spawn --userscript pagetopdf.sh"
|
||||||
|
@ -149,6 +155,7 @@ config.bind(leader + "VV", "config-source")
|
||||||
|
|
||||||
c.url.searchengines = {
|
c.url.searchengines = {
|
||||||
"DEFAULT": "https://search.martyoeh.me/?q={}",
|
"DEFAULT": "https://search.martyoeh.me/?q={}",
|
||||||
|
"l": "https://links.martyoeh.me/?searchterm={}&searchtags=",
|
||||||
"ddg": "https://duckduckgo.com/?q={}",
|
"ddg": "https://duckduckgo.com/?q={}",
|
||||||
"d": "https://www.dict.cc/?s={}",
|
"d": "https://www.dict.cc/?s={}",
|
||||||
"t": "https://www.thesaurus.com/browse/{}",
|
"t": "https://www.thesaurus.com/browse/{}",
|
||||||
|
@ -164,5 +171,7 @@ c.url.searchengines = {
|
||||||
"maps": "https://www.google.fr/maps?q={}",
|
"maps": "https://www.google.fr/maps?q={}",
|
||||||
"gol": "https://golang.org/pkg/{}/",
|
"gol": "https://golang.org/pkg/{}/",
|
||||||
"man": "https://manned.org/browse/search?q={}",
|
"man": "https://manned.org/browse/search?q={}",
|
||||||
"alt": "https://alternativeto.net/software/{}",
|
"lib": "http://libgen.rs/search.php?req={}",
|
||||||
|
"kb": "https://soeg.kb.dk/discovery/search?query=any,contains,{}&tab=Everything&search_scope=MyInst_and_CI&vid=45KBDK_KGL:KGL&offset=0&lang=en",
|
||||||
|
"alt": "https://alternativeto.net/software/{}/?license=opensource",
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
dot https://gitlab.com/marty-oehme/dotfiles
|
|
||||||
l https://links.martyoeh.me/
|
|
||||||
todo https://todoist.com/app?lang=de#start
|
|
||||||
mail https://mail.google.com/mail/u/0/h/1bka5wod4ul0p/?zy=e&f=1
|
|
||||||
rss https://rss.martyoeh.me/
|
|
||||||
files http://files.martyoeh.me/
|
|
||||||
read https://read.martyoeh.me/
|
|
||||||
arch https://wiki.archlinux.org/
|
arch https://wiki.archlinux.org/
|
||||||
toggl https://toggl.com/app/timer
|
|
||||||
clock http://clockify.me/tracker
|
clock http://clockify.me/tracker
|
||||||
cal https://calendar.google.com/calendar/r
|
dot https://gitlab.com/marty-oehme/dotfiles
|
||||||
|
nomie https://v5.nomie.app/
|
||||||
|
todo https://todoist.com/app?lang=de#start
|
||||||
|
toggl https://toggl.com/app/timer
|
||||||
|
# personal
|
||||||
|
blog https://blog.martyoeh.me/
|
||||||
|
cal https://files.martyoeh.me/apps/calendar/timeGridWeek/2020-10-28
|
||||||
|
emgs https://emgs.martyoeh.me/
|
||||||
|
files http://files.martyoeh.me/
|
||||||
|
l https://links.martyoeh.me/
|
||||||
|
mail https://files.martyoeh.me/apps/mail/box/priority
|
||||||
|
photos https://files.martyoeh.me/apps/photos/
|
||||||
|
read https://read.martyoeh.me/
|
||||||
|
rss https://rss.martyoeh.me/
|
||||||
|
|
51
qutebrowser/.local/share/qutebrowser/userscripts/translate_google.sh
Executable file
51
qutebrowser/.local/share/qutebrowser/userscripts/translate_google.sh
Executable file
|
@ -0,0 +1,51 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
#
|
||||||
|
# Translate the page, or if `--text` argument is given the current selection, with google translate.
|
||||||
|
#
|
||||||
|
# Adapted code from https://github.com/AckslD/Qute-Translate, with much gratitude.
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
-s | --source)
|
||||||
|
QUTE_TRANS_SOURCE=$2
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-t | --target)
|
||||||
|
QUTE_TRANS_TARGET=$2
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--url)
|
||||||
|
QUTE_TRANS_URL="true"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--text)
|
||||||
|
QUTE_TRANS_URL="false"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$QUTE_TRANS_SOURCE" ]; then
|
||||||
|
# Default use automatic language for source
|
||||||
|
QUTE_TRANS_SOURCE="auto"
|
||||||
|
fi
|
||||||
|
if [ -z "$QUTE_TRANS_TARGET" ]; then
|
||||||
|
# Default use English for target
|
||||||
|
QUTE_TRANS_TARGET="en"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$QUTE_TRANS_URL" = "false" ]; then
|
||||||
|
# Translate selected text
|
||||||
|
PAGE="https://translate.google.com/#view=home&op=translate&"
|
||||||
|
CONT_KEY="text"
|
||||||
|
CONTENT=$QUTE_SELECTED_TEXT
|
||||||
|
else
|
||||||
|
# Default translate URL
|
||||||
|
PAGE="https://translate.google.com/translate?"
|
||||||
|
CONT_KEY="u"
|
||||||
|
CONTENT=$QUTE_URL
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "open -t ${PAGE}sl=$QUTE_TRANS_SOURCE&tl=$QUTE_TRANS_TARGET&$CONT_KEY=$CONTENT" >>"$QUTE_FIFO"
|
Loading…
Reference in a new issue