Merge branch 'LukeSmithxyz:master' into profile-cleanup

This commit is contained in:
i13e 2022-10-30 08:53:50 -04:00 committed by GitHub
commit aa92a85126
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 63 additions and 76 deletions

View File

@ -24,6 +24,7 @@ set period 1
set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml" set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml"
set cleaner '~/.config/lf/cleaner' set cleaner '~/.config/lf/cleaner'
set previewer '~/.config/lf/scope' set previewer '~/.config/lf/scope'
set autoquit on
# cmds/functions # cmds/functions
cmd open ${{ cmd open ${{

View File

@ -38,6 +38,11 @@ case "$(file --dereference --brief --mime-type -- "$1")" in
[ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE" [ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
;; ;;
*/epub+zip|*/mobi*)
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
[ ! -f "$CACHE.jpg" ] && gnome-epub-thumbnailer "$1" "$CACHE.jpg"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
;;
*opendocument*) odt2txt "$1" ;; *opendocument*) odt2txt "$1" ;;
application/pgp-encrypted) gpg -d -- "$1" ;; application/pgp-encrypted) gpg -d -- "$1" ;;
esac esac

View File

@ -32,7 +32,7 @@ color article white default bold
browser linkhandler browser linkhandler
macro , open-in-browser macro , open-in-browser
macro t set browser "qndl" ; open-in-browser ; set browser linkhandler macro t set browser "qndl" ; open-in-browser ; set browser linkhandler
macro a set browser "tsp yt-dlp --embed-metadata -xic -f bestaudio/best" ; open-in-browser ; set browser linkhandler macro a set browser "tsp yt-dlp --embed-metadata -xic -f bestaudio/best --restrict-filenames" ; open-in-browser ; set browser linkhandler
macro v set browser "setsid -f mpv" ; open-in-browser ; set browser linkhandler macro v set browser "setsid -f mpv" ; open-in-browser ; set browser linkhandler
macro w set browser "lynx" ; open-in-browser ; set browser linkhandler macro w set browser "lynx" ; open-in-browser ; set browser linkhandler
macro d set browser "dmenuhandler" ; open-in-browser ; set browser linkhandler macro d set browser "dmenuhandler" ; open-in-browser ; set browser linkhandler

View File

@ -51,4 +51,4 @@ alias \
lf="lfub" \ lf="lfub" \
magit="nvim -c MagitOnly" \ magit="nvim -c MagitOnly" \
ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; 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/zshnameddirrc" \
weath="less -S ${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" \ weath="less -S ${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" \

View File

@ -4,13 +4,13 @@
# some choice programs to use to open it. # some choice programs to use to open it.
feed="${1:-$(printf "%s" | dmenu -p 'Paste URL or file path')}" feed="${1:-$(printf "%s" | dmenu -p 'Paste URL or file path')}"
case "$(printf "Copy URL\\nsxiv\\nsetbg\\nPDF\\nbrowser\\nlynx\\nvim\\nmpv\\nmpv loop\\nmpv float\\nqueue download\\nqueue yt-dlp\\nqueue yt-dlp audio" | dmenu -i -p "Open it with?")" in case "$(printf "copy url\\nsxiv\\nsetbg\\nPDF\\nbrowser\\nlynx\\nvim\\nmpv\\nmpv loop\\nmpv float\\nqueue download\\nqueue yt-dlp\\nqueue yt-dlp audio" | dmenu -i -p "Open it with?")" in
"Copy URL") echo "$feed" | xclip -selection clipboard ;; "copy url") echo "$feed" | xclip -selection clipboard ;;
mpv) setsid -f mpv -quiet "$feed" >/dev/null 2>&1 ;; mpv) setsid -f mpv -quiet "$feed" >/dev/null 2>&1 ;;
"mpv loop") setsid -f mpv -quiet --loop "$feed" >/dev/null 2>&1 ;; "mpv loop") setsid -f mpv -quiet --loop "$feed" >/dev/null 2>&1 ;;
"mpv float") setsid -f "$TERMINAL" -e mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$feed" >/dev/null 2>&1 ;; "mpv float") setsid -f "$TERMINAL" -e mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$feed" >/dev/null 2>&1 ;;
"queue yt-dlp") qndl "$feed" >/dev/null 2>&1 ;; "queue yt-dlp") qndl "$feed" >/dev/null 2>&1 ;;
"queue yt-dlp audio") qndl "$feed" 'yt-dlp --embed-metadata -icx -f bestaudio/best' >/dev/null 2>&1 ;; "queue yt-dlp audio") qndl "$feed" 'yt-dlp -o "%(title)s.%(ext)s" -f bestaudio --embed-metadata --restrict-filenames' ;;
"queue download") qndl "$feed" 'curl -LO' >/dev/null 2>&1 ;; "queue download") qndl "$feed" 'curl -LO' >/dev/null 2>&1 ;;
PDF) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && zathura "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;; PDF) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && zathura "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;;
sxiv) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;; sxiv) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;;

View File

@ -4,7 +4,7 @@
if [ -f "$1" ]; then if [ -f "$1" ]; then
# Try to get DOI from pdfinfo or pdftotext output. # Try to get DOI from pdfinfo or pdftotext output.
doi=$(pdfinfo "$1" | grep -io "doi:.*") || doi=$(pdfinfo "$1" | grep -io "doi:.*") ||
doi=$(pdftotext "$1" 2>/dev/null - | grep -io "doi:.*" -m 1) || doi=$(pdftotext "$1" 2>/dev/null - | sed -n '/[dD][oO][iI]:/{s/.*[dD][oO][iI]:\s*\(\S\+[[:alnum:]]\).*/\1/p;q}') ||
exit 1 exit 1
else else
doi="$1" doi="$1"

View File

@ -9,31 +9,29 @@
# computer to have its time properly synced. This can be done with the command # computer to have its time properly synced. This can be done with the command
# below which requires the package `ntp`. # below which requires the package `ntp`.
ifinstalled pass pass-otp ifinstalled pass pass-otp || exit 1
dir="${PASSWORD_STORE_DIR}" dir="${PASSWORD_STORE_DIR}"
choice="$({ echo "🆕add" ; echo "🕙sync-time" ; ls ${dir}/*-otp.gpg ;} | sed "s/.*\///;s/-otp.gpg//" | dmenu -p "Pick a 2FA:")" choice="$({ echo "🆕add" ; echo "🕙sync-time" ; ls "$dir"/*-otp.gpg ;} | sed "s/.*\///;s/-otp.gpg//" | dmenu -p "Pick a 2FA:")"
case $choice in case $choice in
🆕add ) 🆕add )
ifinstalled maim zbar xclip || exit 1 ifinstalled maim zbar || exit 1
temp="$dir/temp.png" temp=$(mktemp -p "$XDG_RUNTIME_DIR" --suffix=.png)
otp="otp-test-script" otp="otp-test-script"
trap 'shred -fu $temp; pass rm $otp' HUP INT QUIT TERM PWR EXIT trap 'rm -f $temp; pass rm -f $otp' HUP INT QUIT TERM PWR EXIT
notify-send "Scan the image." "Scan the OTP QR code." notify-send "Scan the image." "Scan the OTP QR code."
maim -s "$temp" || exit 1 maim -s "$temp" || exit 1
info="$(zbarimg -q "$temp")" info="$(zbarimg -q "$temp")"
info="${info#QR-Code:}" info="${info#QR-Code:}"
issuer="$(echo "$info" | grep -o "issuer=[A-z0-9]\+")"
name="${issuer#issuer=}"
if echo "$info" | pass otp insert "$otp"; then if echo "$info" | pass otp insert "$otp"; then
while true ; do while true ; do
export name="$(dmenu -p "Give this One Time Password a one-word name:")" export name="$(echo | dmenu -p "Give this One Time Password a one-word name:")"
echo "$name" | grep -q -- "^[A-z0-9-]\+$" && break echo "$name" | grep -q -- "^[A-z0-9-]\+$" && break
done done
pass mv "$otp" "$name-otp" pass mv "$otp" "$name-otp"
@ -41,7 +39,6 @@ case $choice in
else else
notify-send "No OTP data found." "Try to scan the image again more precisely." notify-send "No OTP data found." "Try to scan the image again more precisely."
fi fi
;; ;;
🕙sync-time ) 🕙sync-time )
ifinstalled ntp || exit 1 ifinstalled ntp || exit 1

View File

@ -1,8 +0,0 @@
#!/bin/sh
# A dmenu binary prompt script.
# Gives a dmenu prompt labeled with $1 to perform command $2.
# For example:
# `./prompt "Do you want to shutdown?" "shutdown -h now"`
[ "$(printf "No\\nYes" | dmenu -i -p "$1" -nb darkred -sb red -sf white -nf gray )" = "Yes" ] && $2

View File

@ -5,6 +5,7 @@
PID=$(xprop -id "$(xprop -root | xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p") PID=$(xprop -id "$(xprop -root | xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p")
PID="$(pstree -lpA "$PID")" PID="$(pstree -lpA "$PID")"
PID="${PID##*"${SHELL##*/}"(}" PID="${PID##*"${SHELL##*/}"(}"
PID="${PID#*lf(}"
PID="${PID%%)*}" PID="${PID%%)*}"
cd "$(readlink /proc/"$PID"/cwd)" || return 1 cd "$(readlink /proc/"$PID"/cwd)" || return 1
"$TERMINAL" "$TERMINAL"

View File

@ -9,7 +9,7 @@
# Application cache if not stated elsewhere. # Application cache if not stated elsewhere.
cache="${XDG_CACHE_HOME:-$HOME/.cache}/slider" cache="${XDG_CACHE_HOME:-$HOME/.cache}/slider"
while getopts "hvrpi:c:a:o:d:f:t:e:x:" o; do case "${o}" in while getopts "hvrpi:c:a:o:d:f:t:e:x:s:" o; do case "${o}" in
c) bgc="$OPTARG" ;; c) bgc="$OPTARG" ;;
t) fgc="$OPTARG" ;; t) fgc="$OPTARG" ;;
f) font="$OPTARG" ;; f) font="$OPTARG" ;;

View File

@ -6,7 +6,8 @@ secs=600 # Download a new doppler radar if one hasn't been downloaded in $secs s
radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar" radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar"
doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif" doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif"
pickloc() { chosen="$(echo "US: Northeast pickloc() { chosen="$(echo "US: CONUS: Continental United States
US: Northeast
US: Southeast US: Southeast
US: PacNorthWest US: PacNorthWest
US: PacSouthWest US: PacSouthWest
@ -55,7 +56,7 @@ US: KUDX: Rapid City, SD
US: KRIW: Riverton, WY US: KRIW: Riverton, WY
US: KSGF: Springfield, MO US: KSGF: Springfield, MO
US: KLSX: St. LOUIS, MO US: KLSX: St. LOUIS, MO
US: KFSD: Sioux Falls, IA US: KFSD: Sioux Falls, SD
US: KTWX: Topeka, KS US: KTWX: Topeka, KS
US: KICT: Wichita, KS US: KICT: Wichita, KS
US: KVWX: Paducah, KY US: KVWX: Paducah, KY
@ -255,7 +256,7 @@ getdoppler() {
loc=$(cut -c 4- "$radarloc") loc=$(cut -c 4- "$radarloc")
notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc." notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc."
case "$cont" in case "$cont" in
"US") curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;; "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" ;; "EU") curl -sL "https://api.sat24.com/animated/${loc}/rainTMC/2/" > "$doppler" ;;
"AF") curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ;; "AF") curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ;;
"DE") loc="$(echo "$loc" | tr "[:upper:]" "[:lower:]")" "DE") loc="$(echo "$loc" | tr "[:upper:]" "[:lower:]")"
@ -276,4 +277,4 @@ After $secs seconds, new clicks will also automatically update the doppler RADAR
6) "$TERMINAL" -e "$EDITOR" "$0" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac esac
echo 🗺️ echo 🌅

View File

@ -29,7 +29,7 @@ esac
# The test if our forcecast is updated to the day. If it isn't download a new # The test if our forcecast is updated to the day. If it isn't download a new
# weather report from wttr.in with the above function. # weather report from wttr.in with the above function.
[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || [ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
getforecast getforecast
showweather showweather

View File

@ -4,7 +4,7 @@
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase" moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
[ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || [ -s "$moonfile" ] && [ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
{ curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;} { curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;}
icon="$(cat "$moonfile")" icon="$(cat "$moonfile")"

View File

@ -13,18 +13,26 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac esac
[ $(pamixer --get-mute) = true ] && echo 🔇 && exit vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
vol="$(pamixer --get-volume)" # If muted, print 🔇 and exit.
[ "$vol" != "${vol%\[MUTED\]}" ] && echo 🔇 && exit
if [ "$vol" -gt "70" ]; then vol="${vol#Volume: }"
icon="🔊" split() {
elif [ "$vol" -gt "30" ]; then # For ommiting the . without calling and external program.
icon="🔉" IFS=$2
elif [ "$vol" -gt "0" ]; then set -- $1
icon="🔈" printf '%s' "$@"
else }
echo 🔇 && exit vol="$(split "$vol" ".")"
fi vol="${vol##0}"
case 1 in
$((vol >= 70)) ) icon="🔊" ;;
$((vol >= 30)) ) icon="🔉" ;;
$((vol >= 1)) ) icon="🔈" ;;
* ) echo 🔇 && exit ;;
esac
echo "$icon$vol%" echo "$icon$vol%"

View File

@ -13,7 +13,7 @@ Options:
-c: comment -c: comment
You will be prompted for title, artist, album and track if not given." && exit 1 ;} You will be prompted for title, artist, album and track if not given." && exit 1 ;}
while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in while getopts "a:t:A:n:N:d:g:c:" o; do case "${o}" in
a) artist="${OPTARG}" ;; a) artist="${OPTARG}" ;;
t) title="${OPTARG}" ;; t) title="${OPTARG}" ;;
A) album="${OPTARG}" ;; A) album="${OPTARG}" ;;
@ -22,7 +22,6 @@ while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
d) date="${OPTARG}" ;; d) date="${OPTARG}" ;;
g) genre="${OPTARG}" ;; g) genre="${OPTARG}" ;;
c) comment="${OPTARG}" ;; c) comment="${OPTARG}" ;;
f) file="${OPTARG}" ;;
*) printf "Invalid option: -%s\\n" "$OPTARG" && err ;; *) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
esac done esac done
@ -30,38 +29,21 @@ shift $((OPTIND - 1))
file="$1" file="$1"
[ ! -f "$file" ] && echo "Provide file to tag." && err temp="$(mktemp -p "$(dirname "$file")")"
trap 'rm -f $temp' HUP INT QUIT TERM PWR EXIT
[ -z "$title" ] && echo "Enter a title." && read -r title [ ! -f "$file" ] && echo 'Provide file to tag.' && err
[ -z "$artist" ] && echo "Enter an artist." && read -r artist
[ -z "$album" ] && echo "Enter an album." && read -r album
[ -z "$track" ] && echo "Enter a track number." && read -r track
case "$file" in [ -z "$title" ] && echo 'Enter a title.' && read -r title
*.ogg) echo "Title=$title [ -z "$artist" ] && echo 'Enter an artist.' && read -r artist
Artist=$artist [ -z "$album" ] && echo 'Enter an album.' && read -r album
Album=$album [ -z "$track" ] && echo 'Enter a track number.' && read -r track
Track=$track
Total=$total cp -f "$file" "$temp" && ffmpeg -i "$temp" -map 0 -y -codec copy \
Date=$date -metadata title="$title" \
Genre=$genre -metadata album="$album" \
Comment=$comment" | vorbiscomment -w "$file" ;; -metadata artist="$artist" \
*.opus) echo "Title=$title -metadata track="${track}${total:+/"$total"}" \
Artist=$artist ${date:+-metadata date="$date"} \
Album=$album ${genre:+-metadata genre="$genre"} \
Track=$track ${comment:+-metadata comment="$comment"} "$file"
Total=$total
Date=$date
Genre=$genre
Comment=$comment" | opustags -i -S "$file" ;;
*.mp3) eyeD3 -Q --remove-all -a "$artist" -A "$album" -t "$title" -n "$track" -N "$total" -Y "$date" "$file" ;;
*.flac) echo "TITLE=$title
ARTIST=$artist
ALBUM=$album
TRACKNUMBER=$track
TOTALTRACKS=$total
DATE=$date
GENRE=$genre
DESCRIPTION=$comment" | metaflac --remove-all-tags --import-tags-from=- "$file" ;;
*) echo "File type not implemented yet." ;;
esac