diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc index d03af62c..94eee7cf 100644 --- a/.config/dunst/dunstrc +++ b/.config/dunst/dunstrc @@ -2,8 +2,8 @@ monitor = 0 follow = keyboard width = 370 - height = 350 - offset = 0x19 + height = (0,350) + offset = (0,19) padding = 2 horizontal_padding = 2 transparency = 25 diff --git a/.config/latexmk/latexmkrc b/.config/latexmk/latexmkrc new file mode 100644 index 00000000..b658c5f8 --- /dev/null +++ b/.config/latexmk/latexmkrc @@ -0,0 +1,10 @@ +$bibtex_use = 1.5; +$cleanup_includes_cusdep_generated = 1; +$cleanup_includes_generated = 1; +$out_dir = "out"; +$pdf_mode = 5; +$silent = 1; + +# SyncTeX +push(@generated_exts, ("synctex.*")); +push(@extra_xelatex_options, '-synctex=1') ; diff --git a/.config/lf/lfrc b/.config/lf/lfrc index dad917df..d877ab67 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -92,25 +92,39 @@ cmd delete ${{ }} cmd moveto ${{ - clear; tput cup $(($(tput lines)/3)); tput bold set -f - clear; echo "Move to where?" - dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" && + clear; tput cup $(($(tput lines)/3)) + dest=$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' "${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs" | fzf --layout=reverse --height 40% --prompt 'Move to where? ' | sed 's|~|$HOME|') + [ -z "$dest" ] && exit + destpath=$(eval printf '%s' \"$dest\") + clear; tput cup $(($(tput lines)/3)); tput bold + echo "From:" + echo "$fx" | sed 's/^/ /' + printf "To:\n %s\n\n\tmove?[y/N]" "$destpath" + read -r ans + [ "$ans" != "y" ] && exit for x in $fx; do - eval mv -iv \"$x\" \"$dest\" + mv -iv "$x" "$destpath" done && - notify-send "๐Ÿšš File(s) moved." "File(s) moved to $dest." + notify-send "๐Ÿšš File(s) moved." "File(s) moved to $destpath." }} cmd copyto ${{ - clear; tput cup $(($(tput lines)/3)); tput bold set -f - clear; echo "Copy to where?" - dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" && + clear; tput cup $(($(tput lines)/3)) + dest=$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' "${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs" | fzf --layout=reverse --height 40% --prompt 'Copy to where? ' | sed 's|~|$HOME|') + [ -z "$dest" ] && exit + destpath=$(eval printf '%s' \"$dest\") + clear; tput cup $(($(tput lines)/3)); tput bold + echo "From:" + echo "$fx" | sed 's/^/ /' + printf "To:\n %s\n\n\tcopy?[y/N]" "$destpath" + read -r ans + [ "$ans" != "y" ] && exit for x in $fx; do - eval cp -ivr \"$x\" \"$dest\" + cp -ivr "$x" "$destpath" done && - notify-send "๐Ÿ“‹ File(s) copied." "File(s) copies to $dest." + notify-send "๐Ÿ“‹ File(s) copied." "File(s) copied to $destpath." }} cmd setbg "$1" diff --git a/.config/nsxiv/exec/key-handler b/.config/nsxiv/exec/key-handler index c743be42..fbbf2899 100755 --- a/.config/nsxiv/exec/key-handler +++ b/.config/nsxiv/exec/key-handler @@ -14,11 +14,11 @@ do mv "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file moved to $destdir." & ;; "r") - magick -rotate 90 "$file" "$file" ;; + magick "$file" -rotate 90 "$file" ;; "R") - magick -rotate -90 "$file" "$file" ;; + magick "$file" -rotate -90 "$file" ;; "f") - magick -flop "$file" "$file" ;; + magick "$file" -flop "$file" ;; "y") printf "%s" "$file" | tr -d '\n' | xclip -selection clipboard && notify-send "$file copied to clipboard" & ;; diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 61deed66..a7523062 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -23,7 +23,6 @@ call plug#end() set title set bg=light -set go=a set mouse=a set nohlsearch set clipboard+=unnamedplus @@ -63,7 +62,8 @@ colorscheme vim endif let g:airline_symbols.colnr = ' C:' let g:airline_symbols.linenr = ' L:' - let g:airline_symbols.maxlinenr = 'โ˜ฐ ' + let g:airline_symbols.maxlinenr = ' ' + let g:airline#extensions#whitespace#symbol = '!' " Shortcutting split navigation, saving a keypress: map h @@ -91,7 +91,7 @@ colorscheme vim map p :!opout "%:p" " Runs a script that cleans out tex build files whenever I close out of a .tex file. - autocmd VimLeave *.tex !texclear % + autocmd VimLeave *.tex !latexmk -c % " Ensure files are read as what I want: let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'} @@ -152,4 +152,4 @@ nnoremap h :call ToggleHiddenAll() " Here leader is ";". " So ":vs ;cfz" will expand into ":vs /home//.config/zsh/.zshrc" " if typed fast without the timeout. -silent! source ~/.config/nvim/shortcuts.vim +silent! source ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/shortcuts.vim diff --git a/.config/pipewire/pipewire.conf b/.config/pipewire/pipewire.conf deleted file mode 100644 index b8a36725..00000000 --- a/.config/pipewire/pipewire.conf +++ /dev/null @@ -1,247 +0,0 @@ -# Daemon config file for PipeWire version "0.3.40" # -# -# Copy and edit this file in /etc/pipewire for system-wide changes -# or in ~/.config/pipewire for local changes. - -context.properties = { - ## Configure properties in the system. - #library.name.system = support/libspa-support - #context.data-loop.library.name.system = support/libspa-support - #support.dbus = true - #link.max-buffers = 64 - link.max-buffers = 16 # version < 3 clients can't handle more - #mem.warn-mlock = false - #mem.allow-mlock = true - #mem.mlock-all = false - #clock.power-of-two-quantum = true - #log.level = 2 - #cpu.zero.denormals = true - - core.daemon = true # listening for socket connections - core.name = pipewire-0 # core name and socket name - - ## Properties for the DSP configuration. - #default.clock.rate = 48000 - #default.clock.allowed-rates = [ 48000 ] - #default.clock.quantum = 1024 - #default.clock.min-quantum = 32 - #default.clock.max-quantum = 8192 - #default.video.width = 640 - #default.video.height = 480 - #default.video.rate.num = 25 - #default.video.rate.denom = 1 - # - # These overrides are only applied when running in a vm. - vm.overrides = { - default.clock.min-quantum = 1024 - } -} - -context.spa-libs = { - # = - # - # Used to find spa factory names. It maps an spa factory name - # regular expression to a library name that should contain - # that factory. - # - audio.convert.* = audioconvert/libspa-audioconvert - api.alsa.* = alsa/libspa-alsa - api.v4l2.* = v4l2/libspa-v4l2 - api.libcamera.* = libcamera/libspa-libcamera - api.bluez5.* = bluez5/libspa-bluez5 - api.vulkan.* = vulkan/libspa-vulkan - api.jack.* = jack/libspa-jack - support.* = support/libspa-support - #videotestsrc = videotestsrc/libspa-videotestsrc - #audiotestsrc = audiotestsrc/libspa-audiotestsrc -} - -context.modules = [ - #{ name = - # [ args = { = ... } ] - # [ flags = [ [ ifexists ] [ nofail ] ] - #} - # - # Loads a module with the given parameters. - # If ifexists is given, the module is ignored when it is not found. - # If nofail is given, module initialization failures are ignored. - # - - # Uses RTKit to boost the data thread priority. - { name = libpipewire-module-rtkit - args = { - #nice.level = -11 - #rt.prio = 88 - #rt.time.soft = 2000000 - #rt.time.hard = 2000000 - } - flags = [ ifexists nofail ] - } - - # Set thread priorities without using RTKit. - #{ name = libpipewire-module-rt - # args = { - # nice.level = -11 - # rt.prio = 88 - # rt.time.soft = 2000000 - # rt.time.hard = 2000000 - # } - # flags = [ ifexists nofail ] - #} - - # The native communication protocol. - { name = libpipewire-module-protocol-native } - - # The profile module. Allows application to access profiler - # and performance data. It provides an interface that is used - # by pw-top and pw-profiler. - { name = libpipewire-module-profiler } - - # Allows applications to create metadata objects. It creates - # a factory for Metadata objects. - { name = libpipewire-module-metadata } - - # Creates a factory for making devices that run in the - # context of the PipeWire server. - { name = libpipewire-module-spa-device-factory } - - # Creates a factory for making nodes that run in the - # context of the PipeWire server. - { name = libpipewire-module-spa-node-factory } - - # Allows creating nodes that run in the context of the - # client. Is used by all clients that want to provide - # data to PipeWire. - { name = libpipewire-module-client-node } - - # Allows creating devices that run in the context of the - # client. Is used by the session manager. - { name = libpipewire-module-client-device } - - # The portal module monitors the PID of the portal process - # and tags connections with the same PID as portal - # connections. - { name = libpipewire-module-portal - flags = [ ifexists nofail ] - } - - # The access module can perform access checks and block - # new clients. - { name = libpipewire-module-access - args = { - # access.allowed to list an array of paths of allowed - # apps. - #access.allowed = [ - # /usr/bin/pipewire-media-session - #] - - # An array of rejected paths. - #access.rejected = [ ] - - # An array of paths with restricted access. - #access.restricted = [ ] - - # Anything not in the above lists gets assigned the - # access.force permission. - #access.force = flatpak - } - } - - # Makes a factory for wrapping nodes in an adapter with a - # converter and resampler. - { name = libpipewire-module-adapter } - - # Makes a factory for creating links between ports. - { name = libpipewire-module-link-factory } - - # Provides factories to make session manager objects. - { name = libpipewire-module-session-manager } -] - -context.objects = [ - #{ factory = - # [ args = { = ... } ] - # [ flags = [ [ nofail ] ] - #} - # - # Creates an object from a PipeWire factory with the given parameters. - # If nofail is given, errors are ignored (and no object is created). - # - #{ factory = spa-node-factory args = { factory.name = videotestsrc node.name = videotestsrc Spa:Pod:Object:Param:Props:patternType = 1 } } - #{ factory = spa-device-factory args = { factory.name = api.jack.device foo=bar } flags = [ nofail ] } - #{ factory = spa-device-factory args = { factory.name = api.alsa.enum.udev } } - #{ factory = spa-node-factory args = { factory.name = api.alsa.seq.bridge node.name = Internal-MIDI-Bridge } } - #{ factory = adapter args = { factory.name = audiotestsrc node.name = my-test } } - #{ factory = spa-node-factory args = { factory.name = api.vulkan.compute.source node.name = my-compute-source } } - - # A default dummy driver. This handles nodes marked with the "node.always-driver" - # property when no other driver is currently active. JACK clients need this. - { factory = spa-node-factory - args = { - factory.name = support.node.driver - node.name = Dummy-Driver - node.group = pipewire.dummy - priority.driver = 20000 - } - } - { factory = spa-node-factory - args = { - factory.name = support.node.driver - node.name = Freewheel-Driver - priority.driver = 19000 - node.group = pipewire.freewheel - node.freewheel = true - } - } - # This creates a new Source node. It will have input ports - # that you can link, to provide audio for this source. - #{ factory = adapter - # args = { - # factory.name = support.null-audio-sink - # node.name = "my-mic" - # node.description = "Microphone" - # media.class = "Audio/Source/Virtual" - # audio.position = "FL,FR" - # } - #} - - # This creates a single PCM source device for the given - # alsa device path hw:0. You can change source to sink - # to make a sink in the same way. - #{ factory = adapter - # args = { - # factory.name = api.alsa.pcm.source - # node.name = "alsa-source" - # node.description = "PCM Source" - # media.class = "Audio/Source" - # api.alsa.path = "hw:0" - # api.alsa.period-size = 1024 - # api.alsa.headroom = 0 - # api.alsa.disable-mmap = false - # api.alsa.disable-batch = false - # audio.format = "S16LE" - # audio.rate = 48000 - # audio.channels = 2 - # audio.position = "FL,FR" - # } - #} -] - -context.exec = [ - #{ path = [ args = "" ] } - # - # Execute the given program with arguments. - # - # You can optionally start the session manager here, - # but it is better to start it as a systemd service. - # Run the session manager with -h for options. - # - { path = "/usr/bin/wireplumber" args = "" } - # - # You can optionally start the pulseaudio-server here as well - # but it is better to start it as a systemd service. - # It can be interesting to start another daemon here that listens - # on another address with the -a option (eg. -a tcp:4713). - # - { path = "/usr/bin/pipewire" args = "-c pipewire-pulse.conf" } -] diff --git a/.config/pipewire/pipewire.conf.d/user-session.conf b/.config/pipewire/pipewire.conf.d/user-session.conf new file mode 100644 index 00000000..85b3778a --- /dev/null +++ b/.config/pipewire/pipewire.conf.d/user-session.conf @@ -0,0 +1,4 @@ +context.exec = [ + { path = "/usr/bin/wireplumber" args = "" condition = [ { exec.session-manager = null } { exec.session-manager = true } ] } + { path = "/usr/bin/pipewire" args = "-c pipewire-pulse.conf" condition = [ { exec.pipewire-pulse = null } { exec.pipewire-pulse = true } ] } +] diff --git a/.config/shell/aliasrc b/.config/shell/aliasrc index 75327bf7..35ceae82 100644 --- a/.config/shell/aliasrc +++ b/.config/shell/aliasrc @@ -4,9 +4,9 @@ [ -x "$(command -v nvim)" ] && alias vim="nvim" vimdiff="nvim -d" # Use $XINITRC variable if file exists. -[ -f "$XINITRC" ] && alias startx="startx $XINITRC" +[ -f "$XINITRC" ] && alias startx='startx $XINITRC' -[ -f "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" +[ -f "$MBSYNCRC" ] && alias mbsync='mbsync -c $MBSYNCRC' # sudo not required for some system commands for command in mount umount sv pacman updatedb su shutdown poweroff reboot ; do @@ -46,8 +46,8 @@ alias \ trem="transmission-remote" \ YT="youtube-viewer" \ sdn="shutdown -h now" \ - e="$EDITOR" \ - v="$EDITOR" \ + e='$EDITOR' \ + v='$EDITOR' \ p="pacman" \ xi="sudo xbps-install" \ xr="sudo xbps-remove -R" \ @@ -57,4 +57,4 @@ alias \ alias \ lf="lfub" \ magit="nvim -c MagitOnly" \ - ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" + ref='shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc' diff --git a/.local/bin/arkenfox-auto-update b/.local/bin/arkenfox-auto-update deleted file mode 100755 index 7664a4fc..00000000 --- a/.local/bin/arkenfox-auto-update +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# A wrapper for the arkenfox-updater that runs it on all pre-existing Arkenfox -# user.js files on the machine. - -# On installation of LARBS, this file is copied to /usr/local/lib/ where it is -# run by a pacman hook set up. The user should not have to run this manually. - -# Search for all Firefox and Librewolf profiles using Arkenfox. -profiles="$(grep -sH "arkenfox user.js" \ - /home/*/.librewolf/*.default-release/user.js \ - /home/*/.mozilla/firefox/*.default-release/user.js)" - -IFS=' -' - -# Update each found profile. -for profile in $profiles; do - userjs=${profile%%/user.js*} - user=$(stat -c '%U' "$userjs") || continue - - su -l "$user" -c "arkenfox-updater -c -p $userjs -s" -done diff --git a/.local/bin/compiler b/.local/bin/compiler index 57135906..1c839101 100755 --- a/.local/bin/compiler +++ b/.local/bin/compiler @@ -6,9 +6,6 @@ # Compiles .tex. groff (.mom, .ms), .rmd, .md, .org. Opens .sent files as sent # presentations. Runs scripts based on extension or shebang. -# Note that .tex files which you wish to compile with XeLaTeX should have the -# string "xelatex" somewhere in a comment/command in the first 5 lines. - file="${1}" ext="${file##*.}" dir=${file%/*} @@ -20,6 +17,7 @@ case "${ext}" in [0-9]) preconv "${file}" | refer -PS -e | groff -mandoc -T pdf > "${base}.pdf" ;; mom|ms) preconv "${file}" | refer -PS -e | groff -T pdf -m"${ext}" > "${base}.pdf" ;; c) cc "${file}" -o "${base}" && "./${base}" ;; + cob) cobc -x -o "$base" "$file" && "$base" ;; cpp) g++ "${file}" -o "${base}" && "./${base}" ;; cs) mcs "${file}" && mono "${base}.exe" ;; go) go run "${file}" ;; @@ -33,20 +31,12 @@ case "${ext}" in pandoc -t ms --highlight-style="kate" -s -o "${base}.pdf" "${file}" ;; org) emacs "${file}" --batch -u "${USER}" -f org-latex-export-to-pdf ;; py) python "${file}" ;; + rink) rink -f "${file}" ;; [rR]md) Rscript -e "rmarkdown::render('${file}', quiet=TRUE)" ;; rs) cargo build ;; sass) sassc -a "${file}" "${base}.css" ;; scad) openscad -o "${base}.stl" "${file}" ;; sent) setsid -f sent "${file}" 2> "/dev/null" ;; - tex) - textarget="$(getcomproot "${file}" || echo "${file}")" - command="pdflatex" - head -n5 "${textarget}" | grep -qi "xelatex" && command="xelatex" - ${command} --output-directory="${textarget%/*}" "${textarget%.*}" && - grep -qi addbibresource "${textarget}" && - biber --input-directory "${textarget%/*}" "${textarget%.*}" && - ${command} --output-directory="${textarget%/*}" "${textarget%.*}" && - ${command} --output-directory="${textarget%/*}" "${textarget%.*}" - ;; + tex) latexmk ;; *) sed -n '/^#!/s/^#!//p; q' "${file}" | xargs -r -I % "${file}" ;; esac diff --git a/.local/bin/getbib b/.local/bin/getbib index 121dd6ee..03a50cda 100755 --- a/.local/bin/getbib +++ b/.local/bin/getbib @@ -1,14 +1,71 @@ #!/bin/sh -[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit -if [ -f "$1" ]; then - # Try to get DOI from pdfinfo or pdftotext output. - doi=$(pdfinfo "$1" | grep -io "doi:.*") || - doi=$(pdftotext "$1" 2>/dev/null - | sed -n '/[dD][oO][iI]:/{s/.*[dD][oO][iI]:\s*\(\S\+[[:alnum:]]\).*/\1/p;q}') || - exit 1 -else - doi="$1" -fi +BIB_FILE="${HOME}/latex/uni.bib" +[ -f "${BIB_FILE}" ] || BIB_FILE="${2:-$(find "${HOME}" -path "${HOME}/.*" \ + -prune -o -type "f" -name "*.bib" -print -quit)}" -# Check crossref.org for the bib citation. -curl -s "https://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n" +{ [ -f "${BIB_FILE}" ] || [ "${2}" ]; } || { + printf "%s\n" "Create a .bib file or provide as \$2." && exit "1" +} + +filter() { + sed -n -E 's/.*((DOI|doi)((\.(org))?\/?|:? *))([^: ]+[^ .]).*/\6/p; T; q' +} + +fpdf() { + pdf="${1}" + doi="$(pdfinfo "${pdf}" 2> "/dev/null" | filter)" + + [ "${doi}" ] || doi="$(pdftotext -q -l "2" "${pdf}" - 2> "/dev/null" | filter)" + + [ "${doi}" ] || printf "%s\n" "No DOI found for PDF: ${pdf}" >&2 + + printf "%s\n" "${doi}" +} + +arrange() { + sed 's/\}, /\},\n /g + s/, /,\n / + s/ }/\n}/ + s/,\s*pages=/,\n\tpages=/' | + sed '1s/^ *// + 1s/[0-9]*\([0-9]\{2\}\)/\1/ + 1s/_// + 1s/.*/\L&/ + s/.*=/\L&/ + s/=/ = /' +} + +doi2bib() { + doi="${1#doi:}" + url="https://api.crossref.org/works/${doi}/transform/application/x-bibtex" + entry="$(curl -kLsS --no-fail "${url}" | arrange)" + red='\033[0;31m' + reset='\033[0m' + + printf "${red}%s${reset}\n" "${entry}" + + [ "${entry%"${entry#?}"}" != "@" ] && { + printf "%s\n" "Failed to fetch bibtex entry for DOI: ${doi}" + return "1" + } + + grep -iFq "doi = {${doi}}" "${BIB_FILE}" 2> "/dev/null" && { + printf "%s\n" "Bibtex entry for DOI: ${doi} already exists in the file." + } || { + [ -s "${BIB_FILE}" ] && printf "\n" >> "${BIB_FILE}" + printf "%s\n" "${entry}" >> "${BIB_FILE}" + printf "%s\n" "Added bibtex entry for DOI: ${doi}" + } +} + +[ "${1}" ] || { + printf "%s\n" "Give either a pdf file or a DOI or a directory path that has PDFs as an argument." + exit "1" +} + +[ -f "${1}" ] && doi="$(fpdf "${1}")" && doi2bib "${doi}" && exit "0" + +[ -d "${1}" ] && for i in "${1}"/*.pdf; do doi="$(fpdf "${i}")" && doi2bib "${doi}"; done && exit "0" + +doi="$(printf "%s\n" "${1}" | filter)" && doi2bib "${doi}" diff --git a/.local/bin/rssget b/.local/bin/rssget new file mode 100755 index 00000000..5d470b4f --- /dev/null +++ b/.local/bin/rssget @@ -0,0 +1,115 @@ +#!/bin/bash + +# Searches the website for RSS feeds and adds them to newsboat url list. Can +# also find hidden RSS feeds on various websites, namely Youtube, Reddit, +# Vimeo, Github, Gitlab and Medium. Gets site url as $1 or (if not present) +# from X clipboard. Gets tags as $2. If it finds more than one feed, calls +# dmenu for the user to choose which one to add. I have bound it to a keyboard +# shortcut so i copy a site link and easily add its feed to the reader. + +# Inspired by and based on the logic of this extension: +# https://github.com/shevabam/get-rss-feed-url-extension + +# This script requires rssadd to add feeds to the list. + +getlink () { + local url="$1" + feeds="$(curl -s "$url" | grep -Ex '.*type=.*(rss|rdf|atom).*' | sed 's/ //g')" + url="$(echo $url | sed 's|^\(https://[^/]*/\).*|\1|')" + + for rsspath in $feeds; do + rsspath="$(echo $rsspath | sed -n "s|.*href=['\"]\([^'\"]*\)['\"].*|\1|p")" + if echo "$rsspath" | grep "http" > /dev/null; then + link="$rsspath" + elif echo "$rsspath" | grep -E "^/" > /dev/null; then + link="$url$(echo $rsspath | sed 's|^/||')" + else + link="$url$rsspath" + fi + echo $link + done +} + +getRedditRss() { + echo "${1%/}.rss" +} + +getYoutubeRss() { + local url="$1" + path=$(echo "$url" | sed -e 's|^http[s]*://||') + case "$path" in + *"/channel/"*) channel_id="$(echo $path | sed -r 's|.*channel/([^/]*).*|\1|')" && feed="https://www.youtube.com/feeds/videos.xml?channel_id=${channel_id}" ;; + *"/c/"*|*"/user/"*) + feed=$(wget -q "$url" -O tmp_rssget_yt \ + && sed -n 's|.*\("rssUrl":"[^"]*\).*|\1|; p' tmp_rssget_yt \ + | grep rssUrl \ + | sed 's|"rssUrl":"||') ;; + esac + echo "$feed" +} + +getVimeoRss() { + local url="$1" + if echo "$url" | grep -q "/videos$"; then + feed_url=$(echo "$url" | sed 's/\/videos$//' | sed 's/\/$/\/rss/') + else + feed_url="${url}/videos/rss" + fi + echo "$feed_url" +} + +getGithubRss () { + local url="${1%/}" + if echo $url | grep -E "github.com/[^/]*/[a-zA-Z0-9].*" >/dev/null ; then + echo "${url}/commits.atom" + echo "${url}/releases.atom" + echo "${url}/tags.atom" + elif echo $url | grep -E "github.com/[^/]*(/)" >/dev/null ; then + echo "${url}.atom" + fi +} + +getGitlabRss () { + local url="${1%/}" + echo "${url}.atom" +} + +getMediumRss () { + echo $1 | sed 's|/tag/|/feed/|' +} + + +if [ -n "$1" ] ; then + url="$1" +else + url="$(xclip -selection clipboard -o)" + [ -z "$url" ] && echo "usage: $0 url 'tag1 tag2 tag3'" && exit 1 +fi + +declare -a list=() + +yt_regex="^(http(s)?://)?((w){3}\.)?(youtube\.com|invidio\.us|invidious\.flokinet\.to|invidious\.materialio\.us|iv\.datura\.network|invidious\.perennialte\.ch|invidious\.fdn\.fr|invidious\.private\.coffee|invidious\.protokolla\.fi|invidious\.privacyredirect\.com|yt\.artemislena\.eu|yt\.drgnz\.club|invidious\.incogniweb\.net|yewtu\.be|inv\.tux\.pizza|invidious\.reallyaweso\.me|iv\.melmac\.space|inv\.us\.projectsegfau\.lt|inv\.nadeko\.net|invidious\.darkness\.services|invidious\.jing\.rocks|invidious\.privacydev\.net|inv\.in\.projectsegfau\.lt|invidious\.drgns\.space)/(channel|user|c).+" +reddit_regex="^(http(s)?://)?((w){3}\.)?reddit\.com.*" +vimeo_regex="^(http(s)?://)?((w){3}.)?vimeo\.com.*" +if echo $url | grep -Ex "$yt_regex" >/dev/null ; then + list="$(getYoutubeRss "$url")" +elif echo $url | grep -Ex "$reddit_regex" >/dev/null ; then + list="$(getRedditRss "$url")" +# vimeo actually works with getlink +elif echo $url | grep -E "$vimeo_regex" >/dev/null ; then + list="$(getVimeoRss "$url")" +elif echo $url | grep -E "github.com" >/dev/null ; then + list="$(getGithubRss "$url")" +# gitlab also works with getlink +elif echo $url | grep -E "gitlab.com/[a-zA-Z0-9].*" >/dev/null ; then + list="$(getGitlabRss "$url")" +elif echo $url | grep -E "medium.com/tag" >/dev/null ; then + list="$(getMediumRss "$url")" +else + list="$(getlink "$url")" +fi + +[ "$(echo "$list" | wc -l)" -eq 1 ] && chosen_link="$list" || chosen_link=$(printf '%s\n' "${list[@]}" | dmenu -p "Choose a feed:") +tags="$2" +ifinstalled rssadd && rssadd "$chosen_link" "$tags" +echo "$chosen_link" "$tags" diff --git a/.local/bin/statusbar/sb-cpu b/.local/bin/statusbar/sb-cpu index 5b8fb933..598b04f7 100755 --- a/.local/bin/statusbar/sb-cpu +++ b/.local/bin/statusbar/sb-cpu @@ -1,7 +1,7 @@ #!/bin/sh case $BLOCK_BUTTON in - 1) notify-send "๐Ÿ–ฅ CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)\\n(100% per core)" ;; + 1) notify-send "๐Ÿ–ฅ CPU hogs" "$(ps axch -o cmd,%cpu | awk '{cmd[$1]+=$2} END {for (i in cmd) print i, cmd[i]}' | sort -nrk2 | head)\\n(100% per core)" ;; 2) setsid -f "$TERMINAL" -e htop ;; 3) notify-send "๐Ÿ–ฅ CPU module " "\- Shows CPU temperature. - Click to show intensive processes. diff --git a/.local/bin/statusbar/sb-doppler b/.local/bin/statusbar/sb-doppler index a687c681..58f17a45 100755 --- a/.local/bin/statusbar/sb-doppler +++ b/.local/bin/statusbar/sb-doppler @@ -182,48 +182,6 @@ US: KVAX: Jacksonville, FL US: KJGX: Peachtree City/atlanta, GA US: KVNX: Norman, OK US: KVBX: Vandenberg Afb: Orcutt, CA -EU: Europe -EU: GB: Great Brittain -EU: SCAN: Scandinavia. Norway, Sweden And Denmark -EU: ALPS: The Alps -EU: NL: The Netherlands -EU: DE: Germany -EU: SP: Spain -EU: FR: France -EU: IT: Italy -EU: PL: Poland -EU: GR: Greece -EU: TU: Turkey -EU: RU: Russia -EU: BA: Bahrain -EU: BC: Botswana -EU: SE: Republic of Seychelles -EU: HU: Hungary -EU: UK: Ukraine -AF: AF: Africa -AF: WA: West Africa -AF: ZA: South Africa -AF: DZ: Algeria -AF: CE: Canary Islands -AF: NG: Nigeria -AF: TD: Chad -AF: CG: Democratic Republic of Congo -AF: EG: Egypt -AF: ET: Ethiopia -AF: CM: Cameroon -AF: IS: Israel -AF: LY: Libya -AF: MG: Madagascar -AF: MO: Morocco -AF: BW: Namibia -AF: SA: Saudi Arabia -AF: SO: Somalia -AF: SD: Sudan -AF: TZ: Tanzania -AF: TN: Tunisia -AF: ZM: Zambia -AF: KE: Kenya -AF: AO: Angola DE: BAW: Baden-Wรผrttemberg DE: BAY: Bavaria DE: BBB: Berlin @@ -239,28 +197,29 @@ DE: SAC: Saxony DE: SAA: Saxony-Anhalt DE: SHH: Schleswig-Holstein DE: SHH: Hamburg -DE: THU: Thuringia" | dmenu -r -i -l 50 -p "Select a radar to use as default:" | tr "[:lower:]" "[:upper:]")" +DE: THU: Thuringia +NL: The Netherlands" | dmenu -r -i -l 50 -p "Select a radar to use as default:")" # Ensure user did not escape. [ -z "$chosen" ] && exit 1 -# Set continent code and radar code. -continentcode=${chosen%%:*} +# Set country code and radar code. +countrycode=${chosen%%:*} radarcode=${chosen#* } radarcode=${radarcode%:*} # Print codes to $radarloc file. - printf "%s,%s\\n" "$continentcode" "$radarcode" > "$radarloc" ;} + printf "%s,%s\\n" "$countrycode" "$radarcode" > "$radarloc" ;} getdoppler() { - cont=$(cut -c -2 "$radarloc") - loc=$(cut -c 4- "$radarloc") - notify-send "๐ŸŒฆ๏ธ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc." - case "$cont" in - "US") curl -sL "https://radar.weather.gov/ridge/standard/${loc}_loop.gif" > "$doppler" ;; - "EU") curl -sL "https://api.sat24.com/animated/${loc}/rainTMC/2/" > "$doppler" ;; - "AF") curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ;; - "DE") loc="$(echo "$loc" | tr "[:upper:]" "[:lower:]")" - curl -sL "https://www.dwd.de/DWD/wetter/radar/radfilm_${loc}_akt.gif" > "$doppler" ;; + country=$(cut -c -2 "$radarloc") + province=$(cut -c 4- "$radarloc") + notify-send "๐ŸŒฆ๏ธ Doppler RADAR" "Pulling most recent Doppler RADAR for $province." + case "$country" in + "US") province="$(echo "$province" | tr "[:lower:]" "[:upper:]")" + curl -sL "https://radar.weather.gov/ridge/standard/${province}_loop.gif" > "$doppler" ;; + "DE") province="$(echo "$province" | tr "[:upper:]" "[:lower:]")" + curl -sL "https://www.dwd.de/DWD/wetter/radar/radfilm_${province}_akt.gif" > "$doppler" ;; + "NL") curl -sL "https://cdn.knmi.nl/knmi/map/general/weather-map.gif" > "$doppler" ;; esac } diff --git a/.local/bin/statusbar/sb-memory b/.local/bin/statusbar/sb-memory index 8178b10b..ac0a5bd3 100755 --- a/.local/bin/statusbar/sb-memory +++ b/.local/bin/statusbar/sb-memory @@ -1,7 +1,7 @@ #!/bin/sh case $BLOCK_BUTTON in - 1) notify-send "๐Ÿง  Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;; + 1) notify-send "๐Ÿง  Memory hogs" "$(ps axch -o cmd,%mem | awk '{cmd[$1]+=$2} END {for (i in cmd) print i, cmd[i]}' | sort -nrk2 | head)" ;; 2) setsid -f "$TERMINAL" -e htop ;; 3) notify-send "๐Ÿง  Memory module" "\- Shows Memory Used/Total. - Click to show memory hogs. diff --git a/.local/bin/statusbar/sb-price b/.local/bin/statusbar/sb-price index 611ec36f..6a79f8ab 100755 --- a/.local/bin/statusbar/sb-price +++ b/.local/bin/statusbar/sb-price @@ -28,7 +28,9 @@ filestat="$(stat -c %x "$pricefile" 2>/dev/null)" [ -d "$dir" ] || mkdir -p "$dir" -updateprice() { curl -sf -m 1 --fail-early $denom.$url/{1$target,$target$interval} --output "$pricefile" --output "$chartfile" || +updateprice() { curl -sf \ + --fail-early "${denom}.${url}/1${target}" "${denom}.${url}/${target}${interval}" \ + --output "$pricefile" --output "$chartfile" || rm -f "$pricefile" "$chartfile" ;} [ "${filestat%% *}" != "$(date '+%Y-%m-%d')" ] && diff --git a/.local/bin/statusbar/sb-ticker b/.local/bin/statusbar/sb-ticker new file mode 100755 index 00000000..4042a3d6 --- /dev/null +++ b/.local/bin/statusbar/sb-ticker @@ -0,0 +1,50 @@ +#!/bin/bash + +# Usage +# sb-ticker +# Sample output +# ^DJI: 0.09% +# CL=F: -1.88% +# Description +# displays/retrieves the latest percent-change in stock market quotes listed in $XDG_CONFIG_HOME/tickers. +# defaults to S&P 500, Dow Jones Industrial, and the Nasdaq +# +# intended to be used in the statusbar, which will display the first quote price in the output + +url="terminal-stocks.dev" +pricefile="${XDG_CACHE_HOME:-$HOME/.cache}/stock-prices" +tickerfile="${XDG_CONFIG_HOME:-$HOME/.config}/tickers" + +[ -f "$tickerfile" ] && tickers="$(cat "$tickerfile")" || tickers="^GSPC,^DJI,^IXIC"; + +checkprice() { + [ -s "$pricefile" ] && [ "$(stat -c %y "$pricefile" 2>/dev/null | + cut -d':' -f1)" != "$(date '+%Y-%m-%d %H')" ] +} + +getchange() { + mapfile -t changes < <(sed -e 's/ / /g' "$pricefile" | grep -oe '[m-]\+[0-9]\+\.[0-9]\+' | sed 's/[m ]/;/g') + IFS=',' read -ra TICKER <<< "$tickers" + for idx in "${!TICKER[@]}"; do + printf "%s: %s%%\n" "${TICKER[$idx]}" "${changes[$idx]//;/}" + done +} + +updateprice() { curl -sfm 10 "$url/$tickers" --output "$pricefile" || rm -f "$pricefile" ; } + +case $BLOCK_BUTTON in + 1) setsid "$TERMINAL" -e less -Srf "$pricefile" ;; + 2) notify-send -u low "Updating..." "Updating prices" ; updateme="1" ;; + 3) notify-send "Current prices:" "Current stock prices:\n$(getchange) + +LEFT MOUSE BUTTON: show price file +MIDDLE MOUSE BUTTON: update stock prices +RIGHT MOUSE BUTTON: Get stock overview" ;; + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +[ -n "$updateme" ] && updateprice + +[ -f "$pricefile" ] && getchange + +checkprice && updateprice diff --git a/.local/bin/sysact b/.local/bin/sysact index 64c2f320..85488e5e 100755 --- a/.local/bin/sysact +++ b/.local/bin/sysact @@ -13,8 +13,18 @@ wmpid(){ # This function is needed if there are multiple instances of the window echo "${tree%%)*}" } +lock(){ + mpc pause + pauseallmpv + wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle + kill -44 $(pidof dwmblocks) + slock + wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle + kill -44 $(pidof dwmblocks) +} + case "$(printf "๐Ÿ”’ lock\n๐Ÿšช leave $WM\nโ™ป๏ธ renew $WM\n๐Ÿป hibernate\n๐Ÿ”ƒ reboot\n๐Ÿ–ฅ๏ธshutdown\n๐Ÿ’ค sleep\n๐Ÿ“บ display off" | dmenu -i -p 'Action: ')" in - '๐Ÿ”’ lock') slock ;; + '๐Ÿ”’ lock') lock ;; "๐Ÿšช leave $WM") kill -TERM "$(wmpid)" ;; "โ™ป๏ธ renew $WM") kill -HUP "$(wmpid)" ;; '๐Ÿป hibernate') slock $ctl hibernate -i ;; diff --git a/.local/bin/texclear b/.local/bin/texclear deleted file mode 100755 index 6ad3c12e..00000000 --- a/.local/bin/texclear +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -# Clears the build files of a LaTeX/XeLaTeX build. -# I have vim run this file whenever I exit a .tex file. - -[ "${1##*.}" = "tex" ] && { - find "$(dirname "${1}")" -regex '.*\(_minted.*\|.*\.\(4tc\|xref\|tmp\|pyc\|pyg\|pyo\|fls\|vrb\|fdb_latexmk\|bak\|swp\|aux\|log\|synctex\(busy\)\|lof\|lot\|maf\|idx\|mtc\|mtc0\|nav\|out\|snm\|toc\|bcf\|run\.xml\|synctex\.gz\|blg\|bbl\)\)' -delete -} || printf "Provide a .tex file.\n" -