From 64d9d82afbe9fcdabc9e4b9c5f02bf12c093645c Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 11 Jul 2024 20:42:43 +0200 Subject: checkpoint --- bin/extra/trl | 33 ++------------ bin/extra/ytplay | 7 ++- bin/guiscripts/dmfm | 22 +++++----- bin/menuscripts/mmedia | 91 ++++++++++++++++++++++----------------- bin/menuscripts/tsh | 6 +-- config/essentials/vis/backup.lua | 6 ++- config/essentials/vis/format.lua | 18 ++++---- config/essentials/vis/fzf-mru.lua | 2 +- config/essentials/vis/visrc.lua | 8 ++-- config/extra/zathura/zathurarc | 36 +++++++--------- stowdots | 38 ++++++++-------- 11 files changed, 131 insertions(+), 136 deletions(-) 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/extra/ytplay b/bin/extra/ytplay index 5243364..4b23732 100755 --- a/bin/extra/ytplay +++ b/bin/extra/ytplay @@ -1,4 +1,9 @@ #!/bin/sh url="$(ytlink)" herbe "playing: $url" & -yt-dlp -o - "$url" | mpv - +yt-dlp "$url" \ + --embed-chapters \ + -f "b" \ + -S "res:1080" \ + -o - | + mpv - 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..72670f2 100755 --- a/bin/menuscripts/tsh +++ b/bin/menuscripts/tsh @@ -170,8 +170,11 @@ then # Get results rm -f "$results" "$links" + # shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091 . "$MODULES_PATH/$module" + get_torrents + [ -f "$results" ] || die "No results." # Save which module was used @@ -180,9 +183,6 @@ else module="$(tail -n 1 "$links")" fi -# acquire get_magnet function -# shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091 -getfunctions=1 . "$MODULES_PATH/$module" # select result from "$results" for choice in $(select_result | xargs) 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/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 -- cgit v1.2.3