summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/common/gt24
-rwxr-xr-xbin/common/gt-st8
-rwxr-xr-xbin/extra/trl33
-rwxr-xr-xbin/guiscripts/dmfm22
-rwxr-xr-xbin/menuscripts/mmedia91
-rwxr-xr-xbin/menuscripts/tsh275
-rw-r--r--config/essentials/vis/backup.lua6
-rw-r--r--config/essentials/vis/format.lua18
-rw-r--r--config/essentials/vis/fzf-mru.lua2
-rw-r--r--config/essentials/vis/visrc.lua8
-rw-r--r--config/extra/zathura/zathurarc36
-rwxr-xr-xshare/tsh/1337x.sh41
-rwxr-xr-xshare/tsh/nyaa.sh32
-rwxr-xr-xshare/tsh/rarbg.sh18
-rwxr-xr-xshare/tsh/rutracker.sh43
-rw-r--r--share/tsh/tgx.sh26
-rwxr-xr-xshare/tsh/torrentgalaxy.sh24
-rwxr-xr-xstowdots38
18 files changed, 441 insertions, 304 deletions
diff --git a/bin/common/gt b/bin/common/gt
index 48321af..477adfc 100755
--- a/bin/common/gt
+++ b/bin/common/gt
@@ -6,6 +6,7 @@
# - git
# - $EDITOR: -e
# - parallel: optional, if installed will run the commands on all repos with parallel
+# - gt-[cmd,st,sync]
repos=$HOME/sync/share/git-track.txt
# prevent file not found errors
@@ -36,17 +37,6 @@ fetch() {
done
}
-sync_status() {
- if [ "$parallel" ]; then
- parallel --colsep ' ' gt-sync {1} {2} <"$repos"
- else
- IFS=' '
- while read -r repo remote_url; do
- gt-sync "$repo" "$remote_url"
- done <"$repos"
- fi
-}
-
# no options
if [ -z "$1" ]; then
help
@@ -55,7 +45,7 @@ fi
[ "$(wc -l <"$repos")" -gt 0 ] || exit 0
-while getopts ":a:c:f:lsheuy" opt; do
+while getopts ":a:c:f:lsheu" opt; do
case "$opt" in
a)
if ! cd "$OPTARG" 2>/dev/null; then
@@ -84,12 +74,18 @@ while getopts ":a:c:f:lsheuy" opt; do
fi
;;
s) cut -f 1 -d ' ' "$repos" | xargs -I{} gt-st {} ;;
- y) sync_status ;;
l) cut -f 1 -d ' ' "$repos" ;;
e) $EDITOR "$repos" ;;
f) repos="$OPTARG" ;;
u)
- sync_status | awk -F ':' '/x$/ {print $1}' |
+ if [ "$parallel" ]; then
+ parallel --colsep ' ' gt-sync {1} {2} <"$repos"
+ else
+ IFS=' '
+ while read -r repo remote_url; do
+ gt-sync "$repo" "$remote_url"
+ done <"$repos"
+ fi | awk -F ':' '/x$/ {print $1}' |
if [ "$parallel" ]; then
parallel gt-cmd {} pull
else
diff --git a/bin/common/gt-st b/bin/common/gt-st
index 98184b9..43443cd 100755
--- a/bin/common/gt-st
+++ b/bin/common/gt-st
@@ -14,11 +14,15 @@ if [ ! -d "$repo" ]; then
fi
# replace line with status
-status="$(git -C "$repo" status --porcelain 2>/dev/null |
+status="$(git -C "$repo" status --porcelain 2>/dev/null |
awk '{print $1}' |
sort | uniq | tr -s '?' |
tr -d '\n')"
remote="$(git -C "$repo" branch -v 2>/dev/null |
sed '/^*/!d;s/ahead/↑/;s/behind/↓/;s/[^↓↑]*//g')"
-printf '%s %s %s\n' "$repo_pretty" "$status" "$remote"
+if [ "$status" ] || [ "$remote" ]; then
+ printf '%s: \033[0;31m%s %s\033[0m\n' "$repo_pretty" "$status" "$remote"
+else
+ printf '%s\n' "$repo_pretty"
+fi
diff --git a/bin/extra/trl b/bin/extra/trl
index 55d65ee..957d0fb 100755
--- a/bin/extra/trl
+++ b/bin/extra/trl
@@ -5,33 +5,7 @@
# returns available languages
languages () {
- cat <<-EOF
- arabic
- dutch
- french
- german
- polish
- english
- portuguese
- spanish
- romanian
- hebrew
- swedish
- italian
- turkish
- japanese
- ukrainian
- korean
- chinese
- czech
- hungarian
- danish
- persian
- greek
- slovak
- hindi
- thai
- EOF
+ printf 'arabic\nchinese\nczech\ndanish\ndutch\nenglish\nfrench\ngerman\ngreek\nhebrew\nhindi\nhungarian\nitalian\njapanese\nkorean\npersian\npolish\nportuguese\nromanian\nslovak\nspanish\nswedish\nthai\nturkish\nukrainian\n'
}
if [ -z "${word:=$1}" ]
@@ -47,11 +21,12 @@ primary="$(languages | fzf --prompt="from:")"
secondary="$(languages | fzf --prompt="to:")"
[ "$secondary" ] || exit 1
-curl -s "https://context.reverso.net/translation/$primary-$secondary/$word" \
+# url="https://www.reverso.net/text-translation#sl=$primary&tl=$secondary&text=$word"
+url="https://context.reverso.net/translation/$primary-$secondary/$word"
+curl -s "$url" \
--compressed \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' \
- -H 'Accept-Language: en-US,en;q=0.5' \
-H 'Accept-Encoding: gzip, deflate, br' |
pup 'a.link_highlighted em text{}' |
sed 's/.*/\L&/' |
diff --git a/bin/guiscripts/dmfm b/bin/guiscripts/dmfm
index 9485469..b7a68d2 100755
--- a/bin/guiscripts/dmfm
+++ b/bin/guiscripts/dmfm
@@ -1,20 +1,20 @@
#!/bin/sh
-while true
-do
- dir="$(printf '%s' "$PWD" | sed "s#^$HOME#\~#;s#\([^/]\)[^/]*/#\1/#g")"
- file=$(find . -maxdepth 1 -mindepth 1 -not -name '.*' -printf '%y\t%f\n' |
+[ -d "$1" ] && cd "$1"
+
+while true; do
+ choice=$(find . -maxdepth 1 -mindepth 1 -not -name '.*' -printf '%y\t%f\n' |
sort -k 1 -k 2 | cut -f 2- |
- commander -xc -p "$dir")
+ dmenu -x -c -i -p "$(pwd)")
- [ "$file" ] || break
- [ ! -e "$file" ] && continue
+ [ "$choice" ] || break
+ [ -e "$choice" ] || continue
- if [ -d "$file" ]
- then
- cd "$file" || continue
+ if [ -d "$choice" ]; then
+ cd "$choice" || continue
else
- setsid xdg-open "$PWD/$file" &
+ setsid xdg-open "$choice" &
+ exit
fi
done
diff --git a/bin/menuscripts/mmedia b/bin/menuscripts/mmedia
index 3141c3b..f4e6e3c 100755
--- a/bin/menuscripts/mmedia
+++ b/bin/menuscripts/mmedia
@@ -6,52 +6,65 @@ dirs="$HOME/dl"
concat_path() { sed "s#^$HOME#\~#;s#\([^/]\)[^/]*/#\1/#g"; }
-case "$1" in
- "video")
- regex='^.\+\.\(webm\|mp4\|mpeg\|mkv\)$'
- dirs="$dirs $HOME/vids"
- viewer() { $PLAYER "$1"; } ;;
- "pdf")
- regex='^.\+\.\(pdf\)$'
- dirs="$dirs $HOME/docs"
- viewer() { $VIEWER "$1"; } ;;
- "image")
- regex='^.\+\.\(png\|avif\|jpg\)$'
- dirs="$dirs $HOME/pics"
- viewer() { $IMAGE "$1"; } ;;
- "cursus")
- regex='^.*/[cC]ursus/index.html$'
- dirs="$HOME/docs/school/Vakken"
- concat_path() { sed "s#$dirs/##;s#/[cC]ursus/index.html##"; }
- viewer() { $BROWSER "$1"; } ;;
- "schoolpdf")
- regex='^.\+\.\(pdf\)$'
- dirs="$HOME/docs/school/Vakken"
- concat_path() { sed "s#$dirs/##;s#/[cC]ursus/index.html##;s#/Cursus/viewer/files/#: #"; }
- viewer() { $VIEWER "$1"; } ;;
- *)
- choice="$(cat <<-EOF | dmenu -g 5 -l 1 -c
- video
- pdf
- image
- cursus
- schoolpdf
+case "$1" in
+"video")
+ regex='^.\+\.\(webm\|mp4\|mpeg\|mkv\)$'
+ dirs="$dirs $HOME/vids"
+ viewer() { $PLAYER "$1"; }
+ ;;
+"pdf")
+ regex='^.\+\.\(pdf\)$'
+ dirs="$dirs $HOME/docs"
+ viewer() { $VIEWER "$1"; }
+ ;;
+"image")
+ regex='^.\+\.\(png\|avif\|jpg\)$'
+ dirs="$dirs $HOME/pics"
+ viewer() { $IMAGE "$1"; }
+ ;;
+"cursus")
+ regex='^.*/[cC]ursus/index.html$'
+ dirs="$HOME/docs/school/Vakken"
+ concat_path() { sed "s#$dirs/##;s#/[cC]ursus/index.html##"; }
+ viewer() { $BROWSER "$1"; }
+ ;;
+"schoolpdf")
+ regex='^.\+\.\(pdf\)$'
+ dirs="$HOME/docs/school/Vakken"
+ concat_path() { sed "s#$dirs/##;s#/[cC]ursus/index.html##;s#/Cursus/viewer/files/#: #"; }
+ viewer() { $VIEWER "$1"; }
+ ;;
+"lecture")
+ dmfm $HOME/docs/lecture
+ exit
+ ;;
+*)
+ choice="$(
+ cat <<-EOF | dmenu -g 6 -l 1 -c
+ video
+ pdf
+ image
+ cursus
+ schoolpdf
+ lecture
EOF
- )"
- [ "$choice" ] || exit 1
- "$0" "$choice"
- exit ;;
+ )"
+ [ "$choice" ] || exit 1
+ "$0" "$choice"
+ exit
+ ;;
esac
shift
[ "$1" ] && dirs="$1"
choice="$(
- find -L $dirs 2> /dev/null |
- grep "$regex" |
- sort | tee "$tmp" |
- concat_path |
- dmenu -px -c -i -l 10 -g 1 -x)"
+ find -L $dirs 2>/dev/null |
+ grep -i "$regex" |
+ sort | tee "$tmp" |
+ concat_path |
+ dmenu -px -c -i -l 10 -g 1 -x
+)"
file="$(sed -n "${choice}p" "$tmp")"
[ -r "$file" ] || exit 1
diff --git a/bin/menuscripts/tsh b/bin/menuscripts/tsh
index 0c57ee0..ea582d8 100755
--- a/bin/menuscripts/tsh
+++ b/bin/menuscripts/tsh
@@ -3,206 +3,169 @@
PROG="$(basename "$0")"
## VARIABLES
# copy command and deps variable
-deps="pup curl $MENUCMD"
+deps="pup curl clipp transmission-cli"
MODULES_PATH=$HOME/.local/share/tsh
module='nyaa.sh' # default module
# Files
export tmp="/tmp/$PROG"
+
files="seeds sizes names html tmp_types"
# Use export so that these variables can be used inside of modules
-for file in $files
-do eval "export $file=$tmp/$file"
+for file in $files; do
+ eval "export $file=$tmp/$file"
done
+
# Files not in $files won't be deleted
export results="$tmp/results"
export links="$tmp/links"
categories="music anime movies shows other software games isos books"
-if [ "$WAYLAND_DISPLAY" ]
-then
- clipp() { wl-copy -n; }
- deps="$deps wl-copy"
-else
- clipp() { xclip -selection clipboard -r; }
- deps="$deps xclip"
-fi
-## FUNCTIONS
-
-help ()
-{
- >&2 cat <<-EOF
- Usage: $PROG [options] query
- Options:
- -h Show this help message and exit
- -r Skip getting pages and use last results
- -s OPTION Sort results based on the specified OPTION
- Available options: seeds, size, name
- -m MODULE Select a module, if MODULE is 'list',
- lists out available modules
- -c CATEGORY Select category
- -f Do not list files
- -d Download without confirming
- EOF
+logn() { >&2 printf '%s\n' "$*"; }
+die() {
+ logn "$@"
+ exit 1
}
-
-log () { >&2 printf '%s' "$*"; }
-logn () { >&2 printf '%s\n' "$*"; }
-die () { logn "$@"; exit 1; }
-
-confirm()
-{
- log "$1"
+confirm() {
+ >&2 printf '%s' "$1"
head -n 1 | grep -q "[yY]"
}
-dependencies ()
-{
- for p in $deps
- do
- if ! command -v "$p" > /dev/null
- then
- logn "E: Program '$p' not found."
- error=1
- fi
- done
- [ "${error:-0}" -eq 1 ] && exit 1
-}
-
-# shellcheck disable=SC2046
-# (we use word splitting on purpose)
-isOnline () { grep -q '1' $(echo /sys/class/net/*/carrier | sed 's#/sys/class/net/lo/carrier ##'); }
-
# Remove temp files and quit
-cleanup ()
-{
- for file in $files
- do eval "rm -f \$$file"
+cleanup() {
+ for file in $files; do
+ eval "rm -f \$$file"
done
}
-list_modules () { find -L "$MODULES_PATH" -type f -printf "%f\n"; }
-
-# get a query from user based on MENUCMD
-get_query ()
-{
- isOnline || exit 1
- if [ "${query:="$*"}" ]
- then
- printf "%s" "$query"
- else
- log ' > '
- head -n 1
- fi | tr ' ' '+'
-}
-
-# Select a result from the result file sorterd with sort_results
-# and select with fzf
-select_result ()
-{
- command -v sort_results > /dev/null || sort_results() { sort -k3 -n -r; }
- awk '{print NR, $0}' "$results" |
- sort_results |
- column -t -l 3 |
- fzf -m --with-nth 2.. |
- awk '{print $1}'
-}
-
-show_files()
-{
- hash="${1##*btih:}"
- hash="${hash%%&*}"
-
- # Download the torrent file from a torrent website
- curl -s "https://itorrents.org/torrent/${hash}.torrent" > "$tmp"/.torrent
- transmission-show "$tmp"/.torrent | sed -n '/^FILES/,$p' | head -n -1 | tail -n +3 >&2
- rm -f "$tmp"/.torrent
-}
+list_modules() { find -L "$MODULES_PATH" -type f -printf "%f\n"; }
-trap "exit 1" INT
+trap "exit 2" INT
trap "cleanup" EXIT
## OPTIONS
-skip=0
-while getopts ":hm:rs:c:fd" opt
-do
+while getopts ":hm:rs:c:fd" opt; do
case $opt in
- h) help && exit ;;
- c)
- [ "$OPTARG" = "list" ] && >&2 printf '%s\n' "$categories" && exit
- category="$(printf '%s\n' "$categories" | tr ' ' '\n' | grep -m 1 "^$OPTARG")"
- [ -z "$category" ] && die "No valid category for '$OPTARG'"
- logn "category: $category" ;;
- f) noaskfiles="1" ;;
- d) noaskdownload="1" ;;
- m)
- [ "$OPTARG" = "list" ] && list_modules && exit
- module="$(list_modules | grep -m 1 "^$OPTARG")"
- [ -z "$module" ] && die "No valid module for '$OPTARG'"
- logn "module: $module" ;;
- r)
- [ ! -r "$results" ] && die "No previous results found."
- skip=1 ;;
- s)
- case $OPTARG in
- "seeds") sort_results() { sort -k3 -n -r; } ;;
- "size") sort_results() { sort -k2 -h -r; } ;;
- "name") sort_results() { sort -k4; } ;;
- *) die "argument '$OPTARG' not seeds,size,name" ;;
- esac ;;
- :) die "Option -$OPTARG requires an argument" ;;
- ?) die "Invalid option: -$OPTARG" ;;
+ h)
+ >&2 cat <<-EOF
+ Usage: $PROG [options] query
+ Options:
+ -h Show this help message and exit
+ -r Skip getting pages and use last results
+ -s OPTION Sort results based on the specified OPTION
+ Available options: seeds, size, name
+ -m MODULE Select a module, if MODULE is 'list',
+ lists out available modules
+ -c CATEGORY Select category
+ -f Do not list files
+ -d Download without confirming
+ EOF
+
+ exit
+ ;;
+ c)
+ [ "$OPTARG" = "list" ] && >&2 printf '%s\n' "$categories" && exit
+ category="$(printf '%s\n' "$categories" | tr ' ' '\n' | grep -m 1 "^$OPTARG")"
+ [ -z "$category" ] && die "No valid category for '$OPTARG'"
+ logn "category: $category"
+ ;;
+ f) noaskfiles="1" ;;
+ d) noaskdownload="1" ;;
+ m)
+ [ "$OPTARG" = "list" ] && list_modules && exit
+ module="$(list_modules | grep -m 1 "^$OPTARG")"
+ [ -z "$module" ] && die "No valid module for '$OPTARG'"
+ logn "module: $module"
+ ;;
+ r)
+ [ ! -r "$results" ] && die "No previous results found."
+ skip=1
+ ;;
+ s)
+ case $OPTARG in
+ "seeds") sort_results() { sort -k3 -n -r; } ;;
+ "size") sort_results() { sort -k2 -h -r; } ;;
+ "name") sort_results() { sort -k4; } ;;
+ *) die "argument '$OPTARG' not seeds,size,name" ;;
+ esac
+ ;;
+ :) die "Option -$OPTARG requires an argument" ;;
+ ?) die "Invalid option: -$OPTARG" ;;
esac
done
shift $((OPTIND - 1))
-dependencies
+for p in $deps; do
+ if ! command -v "$p" >/dev/null; then
+ logn "E: Program '$p' not found."
+ error=1
+ fi
+done
+[ "${error:-0}" -eq 1 ] && exit 3
# Get the torrents with module
-if [ $skip -ne 1 ]
-then
+if [ "${skip:-0}" -eq 1 ]; then
+ module="$(tail -n 1 "$links")"
+else
mkdir -p "$tmp"
- query="$(get_query "$*")"
- [ "$query" ] || exit 1
+ query="$(
+ if [ "${query:="$*"}" ]; then
+ printf "%s" "$query"
+ else
+ >&2 printf ' > '
+ head -n 1
+ fi | tr ' ' '+'
+ )"
+ [ "$query" ] || exit 4
- # Get results
- rm -f "$results" "$links"
# shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091
. "$MODULES_PATH/$module"
+ rm -f "$results" "$links"
+ get_torrents
+
[ -f "$results" ] || die "No results."
- # Save which module was used
- printf "%s\n" "$module" >> "$links"
-else
- module="$(tail -n 1 "$links")"
+ # Save which module was used (hack)
+ printf "%s\n" "$module" >>"$links"
fi
-# acquire get_magnet function
-# shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091
-getfunctions=1 . "$MODULES_PATH/$module"
+# Default sorting if unset
+command -v sort_results >/dev/null || sort_results() { sort -k3 -n -r; }
# select result from "$results"
-for choice in $(select_result | xargs)
-do
- printf 'choice: %s\n' "$(sed -n "${choice}p" "$results" | cut -f 3-)"
- magnet="$(get_magnet "$choice")"
- [ "$magnet" ] || exit 1
-
- if [ -z "$noaskfiles" ] && confirm 'files?'; then
- show_files "$magnet"
- fi
-
- if [ "$noaskdownload" ] || confirm 'download?'
- then
- [ "$category" ] || category="$(printf '%s' "$categories" | tr ' ' '\n' | fzf)"
- [ "$category" ] || exit 2
- transmission-remote debuc.com -a "$magnet" -w "/downloads/$category"
- elif confirm "copy?"
- then
- echo "$magnet" | clipp
- fi
+for choice in $(
+ # Select result(s) from the result file sorted with sort_results
+ # with fzf
+ awk '{print NR, $0}' "$results" |
+ sort_results |
+ column -t -l 3 |
+ fzf -m --with-nth 2.. |
+ awk 'BEGIN{OFS=" "} {print $1}'
+); do
+
+ printf 'choice: %s\n' "$(sed -n "${choice}p" "$results" | cut -f 3-)"
+ magnet="$(get_magnet "$choice")"
+ [ "$magnet" ] || exit 5
+
+ if [ -z "$noaskfiles" ] && confirm 'files?'; then
+ hash="${1##*btih:}"
+ hash="${hash%%&*}"
+
+ # Download the torrent file from a torrent website
+ curl -s "https://itorrents.org/torrent/${hash}.torrent" >"$tmp"/.torrent
+ transmission-show "$tmp"/.torrent | sed -n '/^FILES/,$p' | head -n -1 | tail -n +3 >&2
+ rm -f "$tmp"/.torrent
+ fi
+
+ if [ -z "$noaskdownload" ] && confirm 'download?'; then
+ [ "$category" ] || category="$(printf '%s' "$categories" | tr ' ' '\n' | fzf)"
+ [ "$category" ] || exit 6
+ transmission-remote debuc.com -a "$magnet" -w "/downloads/$category"
+ elif confirm "copy?"; then
+ echo "$magnet" | clipp
+ fi
done
diff --git a/config/essentials/vis/backup.lua b/config/essentials/vis/backup.lua
index 7c44c60..2c8f0b8 100644
--- a/config/essentials/vis/backup.lua
+++ b/config/essentials/vis/backup.lua
@@ -20,6 +20,10 @@ end
-- Before saving the file, copy the current contents of the file to a backup file
vis.events.subscribe(vis.events.FILE_SAVE_PRE, function(file, path)
+ if file == nil then
+ return
+ end
+
if file.size > backup.byte_limit then
return
end
@@ -46,7 +50,7 @@ vis.events.subscribe(vis.events.FILE_SAVE_PRE, function(file, path)
end)
-- Set defaults
-backup.directory = os.getenv("XDG_DATA_HOME") .. "/Trash/vis-backups"
+backup.directory = (os.getenv("XDG_DATA_HOME") or (os.getenv("HOME") .. "/.local/share")) .. "/Trash/vis-backups"
backup.get_fname = backup.entire_path_with_double_percentage_signs
diff --git a/config/essentials/vis/format.lua b/config/essentials/vis/format.lua
index 67613a6..eefdc77 100644
--- a/config/essentials/vis/format.lua
+++ b/config/essentials/vis/format.lua
@@ -63,15 +63,15 @@ M.formatters = {
end,
},
luaformatter = M.stdio_formatter("lua-format"),
- markdown = M.stdio_formatter(function(win)
- if win.options and M.wrapwidth ~= 0 then
- return "prettier --parser markdown --prose-wrap always "
- .. ("--print-width " .. (M.wrapwidth - 1) .. " ")
- .. M.with_filename(win, "--stdin-filepath ")
- else
- return "prettier --parser markdown " .. M.with_filename(win, "--stdin-filepath ")
- end
- end, { ranged = false }),
+ -- markdown = M.stdio_formatter(function(win)
+ -- if win.options and M.wrapwidth ~= 0 then
+ -- return "prettier --parser markdown --prose-wrap always "
+ -- .. ("--print-width " .. (M.wrapwidth - 1) .. " ")
+ -- .. M.with_filename(win, "--stdin-filepath ")
+ -- else
+ -- return "prettier --parser markdown " .. M.with_filename(win, "--stdin-filepath ")
+ -- end
+ -- end, { ranged = false }),
powershell = M.stdio_formatter([[
"$( (command -v powershell.exe || command -v pwsh) 2>/dev/null )" -c '
Invoke-Formatter -ScriptDefinition `
diff --git a/config/essentials/vis/fzf-mru.lua b/config/essentials/vis/fzf-mru.lua
index 455d083..8408dd7 100644
--- a/config/essentials/vis/fzf-mru.lua
+++ b/config/essentials/vis/fzf-mru.lua
@@ -10,7 +10,7 @@ Changes made:
--]]
local M = {}
-M.fzf_filepath = os.getenv("XDG_CACHE_HOME") .. "/vis-fzf-mru"
+M.fzf_filepath = (os.getenv("XDG_CACHE_HOME") or (os.getenv("HOME") .. "/.local/share")).. "/vis-fzf-mru"
M.fzf_path = "fzf"
M.fzf_args = "--height=40%"
M.fzf_history = 20
diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua
index 577712a..b56b6af 100644
--- a/config/essentials/vis/visrc.lua
+++ b/config/essentials/vis/visrc.lua
@@ -25,7 +25,7 @@ local format = require("format")
-- set height to 40%
local fzfmru = require("fzf-mru")
-fzfmru.fzfmru_path = 'grep "^' .. os.getenv("PWD") .. '" | fzf'
+fzfmru.fzfmru_path = 'grep "^' .. io.popen("pwd"):read("*a"):gsub("\n$", "") .. '" | fzf'
-- todo:
-- c-scope
@@ -120,9 +120,9 @@ end)
vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args
-- automatically cd in parent dir of file
vis:command_register("cdp", function()
- if win.file and win.file.path then
- local dir = win.file.path:match(".*/")
- vis:command("cd " .. dir)
+ if win and win.file and win.file.path then
+ -- local dir = win.file.path:match(".*/")
+ -- vis:info("cd " .. tostring(dir))
end
end, "Cd to parent dir of file")
diff --git a/config/extra/zathura/zathurarc b/config/extra/zathura/zathurarc
index a78ef16..41e1980 100644
--- a/config/extra/zathura/zathurarc
+++ b/config/extra/zathura/zathurarc
@@ -1,23 +1,19 @@
-# fullscreen mappings
-map [fullscreen] r reload
-map [fullscreen] R rotate
-map [fullscreen] i zoom in
-map [fullscreen] o zoom out
-
# normal mappings
-map r reload
-map R rotate
-map i zoom in
-map o zoom out
-map f toggle_fullscreen
-map x toggle_statusbar
-map X toggle_index
+map r reload
+map R rotate
+map i zoom in
+map o zoom out
+map f toggle_fullscreen
+map x toggle_statusbar
+map X toggle_index
-set font "monospace bold 11"
-set adjust-open "best-fit"
-set pages-per-row 1
-set scroll-page-aware "true"
-set scroll-full-overlap 0.01
-set scroll-step 100
+set font "monospace bold 11"
+set adjust-open "best-fit"
+set pages-per-row 1
+set scroll-page-aware "true"
+set scroll-full-overlap 0.01
+set scroll-step 100
-set guioptions " "
+set guioptions " "
+set database "sqlite"
+set continuous-hist-save true
diff --git a/share/tsh/1337x.sh b/share/tsh/1337x.sh
new file mode 100755
index 0000000..630d269
--- /dev/null
+++ b/share/tsh/1337x.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+url="https://www.1337xx.to"
+# shellcheck disable=SC2154
+# (we expect the variables to be set)
+
+# $1: line number used to get link
+get_magnet() {
+ curl -s "$(sed -n "${1}p" "$links")" |
+ pup -p 'a attr{href}' | grep "^magnet:" | head -n 1
+}
+
+get_torrents() {
+ # Get the pages all in one html document
+ next="/search/$query/1/"
+ while [ "$next" ]; do
+ link="$url$next"
+ >&2 printf '%s\n' "$link"
+
+ # Get next link, but also append html
+ next="$(
+ curl -s "$link" |
+ tee -a "$html" |
+ pup -p 'div.pagination li:last-child a attr{href}'
+ )"
+ [ "$next" = 'javascript:void(0)' ] && break
+ done
+ # No results
+
+ # parse html pages and scrape relevant information in seperate files
+ pup -f "$html" -p 'td.seeds text{}' >"$seeds"
+ # No results
+ [ -s "$seeds" ] || return 1
+ pup -f "$html" -p 'td.size text{}' | tr -d ' ' >"$sizes"
+ pup -f "$html" -p 'td.name a:nth-child(2) text{}' >"$names"
+ pup -f "$html" -p 'td.name a:nth-child(2) attr{href}' |
+ awk "{print \"$url\" \$0}" >"$links"
+
+ # concatenating the 3 files into results file
+ paste "$sizes" "$seeds" "$names" >"$results"
+}
diff --git a/share/tsh/nyaa.sh b/share/tsh/nyaa.sh
new file mode 100755
index 0000000..259dabd
--- /dev/null
+++ b/share/tsh/nyaa.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# shellcheck disable=SC2154
+# (we expect the variables to be set)
+
+# $1`: line number used to get link
+get_magnet() { sed -n "${1}p" "$links"; }
+
+get_torrents() {
+ base_url="https://nyaa.si"
+ page="/?q=$query&p=1"
+ i=0
+ while true; do
+ i=$((i + 1))
+ page="$(curl -s "$base_url$page" | tee -a "$html" | pup -p 'li.next a attr{href}')"
+ if [ -z "$page" ]; then
+ printf '%s.\n' "$i"
+ break
+ else
+ >&2 printf '%s ' "$i"
+ fi
+ done
+ # No results
+ [ "$i" -eq 0 ] && return 1
+
+ pup -f "$html" -p 'table.torrent-list tr td:nth-child(2) a:last-child attr{title}' >"$names"
+ pup -f "$html" -p 'table.torrent-list tr td:nth-child(3) a:last-child attr{href}' >"$links"
+ pup -f "$html" -p 'table.torrent-list tr td:nth-child(4) text{}' | tr -d ' ' >"$sizes"
+ pup -f "$html" -p 'table.torrent-list tr td:nth-child(6) text{}' >"$seeds"
+
+ paste "$sizes" "$seeds" "$names" >"$results"
+}
diff --git a/share/tsh/rarbg.sh b/share/tsh/rarbg.sh
new file mode 100755
index 0000000..abb58c8
--- /dev/null
+++ b/share/tsh/rarbg.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+url="https://www2.rarbggo.to"
+
+# $1: line number to get link
+get_magnet() { curl -s "$url/$(sed -n "${1}p" "$links")" | pup -p '#hvicwlo attr{href}'; }
+
+get_torrents() {
+ >&2 printf "$url/search/?search=$query"
+ curl -s "$url/search/?search=$query" >"$html"
+
+ row='table.tablelist2 > tbody > tr.table2ta > td.tlista'
+ pup -p "$row:nth-child(2) > a text{}" <"$html" >"$names"
+ pup -p "$row:nth-child(5) text{}" <"$html" | tr -d ' ' >"$sizes"
+ pup -p "$row:nth-child(6) > font text{}" <"$html" >"$seeds"
+ pup -p "$row:nth-child(2) > a attr{href}" <"$html" >"$links"
+ paste "$sizes" "$seeds" "$names" >"$results"
+}
diff --git a/share/tsh/rutracker.sh b/share/tsh/rutracker.sh
new file mode 100755
index 0000000..9f9c407
--- /dev/null
+++ b/share/tsh/rutracker.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# Note(Author): This fails because the request after solving the captcha is blank.
+
+# shellcheck disable=SC2154
+
+# $1: line number for link that will provide magnet link
+get_magnet() { curl -s "$(sed -n "${1}p" "$links")" | pup 'a.magnet-link attr{href}'; }
+
+get_torrents() {
+ cookies="$tmp"/cookies
+
+ pass="$(find "$PASSWORD_STORE_DIR" -type f | sed -e '/rutracker\.org\//!d' -e "s@$PASSWORD_STORE_DIR/@@;s/\.gpg\$//")"
+ username="${pass#*/}"
+ password="$(pass show "$pass" | head -n 1)"
+
+ curl -sL 'https://rutracker.org/forum/login.php' \
+ -X POST --data-raw "login_username=$username&login_password=$password&login=вход" \
+ -b "$cookies" --cookie-jar "$cookies" >"$html"
+
+ # Check if user was blocked by captcha
+ if pup 'img attr{src}' <"$html" | grep -q 'captcha'; then
+ cap_link="$(pup -f "$html" 'img attr{src}' | grep 'captcha')"
+ cap_code="$(pup -f "$html" 'input.reg-input attr{name}')"
+ cap_sid="$(pup -f "$html" 'input[name="cap_sid"] attr{value}')"
+
+ >&2 printf "cap_link: %s\n" "$cap_link"
+ >&2 printf 'code: '
+ code="$(head -n 1)"
+
+ curl -sL 'https://rutracker.org/forum/login.php' \
+ -X POST --data-raw "login_username=$username&login_password=$password&cap_sid=$cap_sid&$cap_code=$code&login=вход" \
+ --cookie-jar "$cookies" >/dev/null
+ fi
+
+ curl -b "$cookies" -s 'https://rutracker.org/forum/tracker.php' \
+ -X POST --data-raw "nm=$query" >"$html"
+ pup -p -f "$html" 'tr td:nth-child(4) a:first-child text{}' >"$names"
+ pup -f "$html" 'tr td:nth-child(6) a:first-child text{}' | awk '{print $1}' >"$sizes"
+ pup -f "$html" 'tr td:nth-child(7) b text{}' >"$seeds"
+ pup -f "$html" 'tr td:nth-child(4) a:first-child attr{href}' | sed 's#.*#https://rutracker.org/forum/&#' >"$links"
+ paste "$sizes" "$seeds" "$names" >"$results"
+}
diff --git a/share/tsh/tgx.sh b/share/tsh/tgx.sh
new file mode 100644
index 0000000..3b2f34f
--- /dev/null
+++ b/share/tsh/tgx.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+html="tmp.html"
+query="battleblock"
+
+url="https://torrentgalaxy.mx"
+
+curl "$url/galaxyfence.php?f&dropoff=%2Ftorrents.php%3Fsearch%3D$query" > "$html"
+
+captcha_url="$url/$(pup -p '#captcha attr{src}' < "$html")"
+
+if [ "$captcha_url" ]
+then
+ >&2 printf "> "
+ curl "$captcha_url" | imv -
+ captcha_value="$(head -n 1)"
+ >&2 printf "captcha_value: %s\n" "$captcha_value"
+
+ curl -v "$url/galaxyfence.php" \
+ --compressed \
+ -X POST \
+ --data-raw "dropoff=%2Ftorrents.php%3Fsearch%3D$query&captcha=$captcha_value" \
+ > result.html
+fi
+
+$BROWSER result.html
diff --git a/share/tsh/torrentgalaxy.sh b/share/tsh/torrentgalaxy.sh
new file mode 100755
index 0000000..9d13cc9
--- /dev/null
+++ b/share/tsh/torrentgalaxy.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+url="https://torrentgalaxy.to"
+# shellcheck disable=SC2154
+# (we expect the variables to be set)
+
+# $1: line number used to get link
+get_magnet() { sed -n "${1}p" "$links"; }
+
+get_torrents() {
+ next="/torrents.php?search=$query"
+ curl -s "$url$next" >"$html"
+
+ pup -f "$html" -p 'div.tgxtablerow > div:nth-child(11) > span > font:first-child text{}' >"$seeds"
+
+ # No results
+ [ -s "$seeds" ] || return 1
+
+ pup -f "$html" -p 'div.tgxtablerow > div:nth-child(8) > span text{}' | tr -d ' ' >"$sizes"
+ pup -f "$html" -p 'div.tgxtablerow > div:nth-child(4) > div > a attr{title}' >"$names"
+ pup -f "$html" -p 'div.tgxtablerow > div:nth-child(5) > a:nth-child(2) attr{href}' >"$links"
+
+ paste "$sizes" "$seeds" "$names" >"$results"
+}
diff --git a/stowdots b/stowdots
index 918a76c..7fecfde 100755
--- a/stowdots
+++ b/stowdots
@@ -3,12 +3,11 @@
trap "exit 1" EXIT INT
test "$(id -u)" != 0 && sudo=sudo
-die () {
+die() {
echo "$@" 1>&2
}
-if ! stow --version > /dev/null 2>&1
-then
+if ! stow --version >/dev/null 2>&1; then
die "stow not installed or not found."
die "install stow? (arch)"
die -n ">"
@@ -16,8 +15,7 @@ then
$sudo pacman -Sy stow ||
exit 1
fi
-if [ -n "${MACH:=$1}" ]
-then
+if [ -n "${MACH:=$1}" ]; then
die "I: stowing for $MACH"
else
die "E: MACH not set"
@@ -29,20 +27,24 @@ fi
mkdir -p "$HOME/bin"
mkdir -p "$HOME/.config"
+mkdir -p "$HOME/.local/share"
ln -sf "$(realpath "$0")" $HOME/bin/
cd "$(dirname "$(realpath "$0")")" || exit 1
case "$MACH" in
- "desktop" | "d" | "laptop" | "l")
- stow -d bin/ -t "$HOME/bin" -R common guiscripts menuscripts extra
- stow -d config/ -t "$HOME/.config" -R essentials common extra X theme wayland
- stow -d config/ -t "$HOME/" -R home
- ;;
- "server" | "s")
- stow -d bin/ -t "$HOME/bin" -R common serverscripts menuscripts
- stow -d config/ -t "$HOME/.config" -R essentials common
- stow -d config/ -t "$HOME/" -R home
- ;;
- *)
- die "E: invalid value for 'MACH'"
- break
+"desktop" | "d" | "laptop" | "l")
+ stow -d bin/ -t "$HOME/bin" -R common guiscripts menuscripts extra
+ stow -d config/ -t "$HOME/.config" -R essentials common extra X theme wayland
+ stow -d config/ -t "$HOME/" -R home
+ stow share/ -t "$HOME/.local/share"
+ ;;
+"server" | "s")
+ stow -d bin/ -t "$HOME/bin" -R common serverscripts menuscripts
+ stow -d config/ -t "$HOME/.config" -R essentials common
+ stow -d config/ -t "$HOME/" -R home
+ stow share/ -t "$HOME/.local/share"
+ ;;
+*)
+ die "E: invalid value for 'MACH'"
+ break
+ ;;
esac