From 3e8c05fe3d118b8a7c2df25000a8d5d046812a50 Mon Sep 17 00:00:00 2001 From: Tan Long <71320000+tanloong@users.noreply.github.com> Date: Thu, 25 Aug 2022 21:41:28 +0800 Subject: [PATCH 1/7] add support for SILE (#1175) --- .local/bin/opout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/opout b/.local/bin/opout index 8890861..d2b447a 100755 --- a/.local/bin/opout +++ b/.local/bin/opout @@ -7,7 +7,7 @@ basename="${1%.*}" case "${*}" in - *.tex|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) target="$(getcomproot "$1" || echo "$1")" ; setsid -f xdg-open "${target%.*}".pdf >/dev/null 2>&1 ;; + *.tex|*.sil|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) target="$(getcomproot "$1" || echo "$1")" ; setsid -f xdg-open "${target%.*}".pdf >/dev/null 2>&1 ;; *.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;; *.sent) setsid -f sent "$1" >/dev/null 2>&1 ;; esac From 5d5e3b655ef01973419ac0def58123946b0d569a Mon Sep 17 00:00:00 2001 From: ryan-c-dev Date: Mon, 12 Sep 2022 16:31:07 -0700 Subject: [PATCH 2/7] remove spacing from saved audio for tsp/newsboat (#1184) The --restrict-filenames parameter will automatically replace spaces with underlines. --- .config/newsboat/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/newsboat/config b/.config/newsboat/config index b7a78da..d8dbecd 100644 --- a/.config/newsboat/config +++ b/.config/newsboat/config @@ -32,7 +32,7 @@ color article white default bold browser linkhandler macro , open-in-browser 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 w set browser "lynx" ; open-in-browser ; set browser linkhandler macro d set browser "dmenuhandler" ; open-in-browser ; set browser linkhandler From ae0ad289a10e0cd911489ce08f8d0fed6332d348 Mon Sep 17 00:00:00 2001 From: ryan-c-dev Date: Mon, 19 Sep 2022 16:50:45 -0700 Subject: [PATCH 3/7] underscore vs spaces, and naming convention (#1189) the title then extension format with the --restrict-filenames again for underscores instead of spaces. Works typically well as music will have Artist name first usually followed by song title so no need to format. haven't looked into the --embed-metadata parameter, only imagine it could be useful if it saves the url suffix for youtube link (which you don't want in your filename hopefully) for my video downloads, i just use this. alias ydl='yt-dlp -o '%(title)s.%(ext)s' -f bv+ba/b --restrict-filenames' alias mp3='yt-dlp -o '%(title)s.%(ext)s' -f bestaudio -x --audio-format mp3 --embed-thumbnail --restrict-filenames' Probably bad practice to have single quotes within more single quotes but ran into issues with yt-dlp over using double quotes. -Ryan --- .local/bin/dmenuhandler | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.local/bin/dmenuhandler b/.local/bin/dmenuhandler index 1c48f3a..1cd1b29 100755 --- a/.local/bin/dmenuhandler +++ b/.local/bin/dmenuhandler @@ -10,7 +10,8 @@ case "$(printf "Copy URL\\nsxiv\\nsetbg\\nPDF\\nbrowser\\nlynx\\nvim\\nmpv\\nmpv "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 ;; "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' +' >/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 ;; 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 ;; From 7871fd80b29afa3fbab9bbecd6092b303b07c29f Mon Sep 17 00:00:00 2001 From: appeasementPolitik <108810900+appeasementPolitik@users.noreply.github.com> Date: Tue, 20 Sep 2022 11:42:54 +0000 Subject: [PATCH 4/7] Make otp script more secure + other improvements (#1190) Make a temporary directory in $XDG_RUNTIME_DIR instead of $PASSWORD_STORE_DIR. $XDG_RUNTIME_DIR defaults to /run/user/$uid/. This directory has the security advantage of only being readable and writable by the current user and being mounted in RAM, causing the screenshot to be fully wiped on shutdown and not needing shred, which doesn't work reliably on SSD's. Also quoted $dir, for the off chance someone has spaces in their $PASSWORD_STORE_DIR. Removed the check for xclip and the $issuer and $name variables, as they are unused. If you're wondering why echo is piped into dmenu, on my system dmenu hung when called without the pipe, causing the whole script to freeze. --- .local/bin/otp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.local/bin/otp b/.local/bin/otp index 1726b1a..a40c198 100755 --- a/.local/bin/otp +++ b/.local/bin/otp @@ -13,27 +13,25 @@ ifinstalled pass pass-otp 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 🆕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" - 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." maim -s "$temp" || exit 1 info="$(zbarimg -q "$temp")" info="${info#QR-Code:}" - issuer="$(echo "$info" | grep -o "issuer=[A-z0-9]\+")" - name="${issuer#issuer=}" if echo "$info" | pass otp insert "$otp"; then 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 done pass mv "$otp" "$name-otp" @@ -41,7 +39,6 @@ case $choice in else notify-send "No OTP data found." "Try to scan the image again more precisely." fi - ;; 🕙sync-time ) ifinstalled ntp || exit 1 From 5ff7f70b64214beafc9146717d6a766d721b9786 Mon Sep 17 00:00:00 2001 From: appeasementPolitik <108810900+appeasementPolitik@users.noreply.github.com> Date: Thu, 22 Sep 2022 12:50:58 +0000 Subject: [PATCH 5/7] otp: exit if pass or pass-otp are not installed (#1191) --- .local/bin/otp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/otp b/.local/bin/otp index a40c198..7e471db 100755 --- a/.local/bin/otp +++ b/.local/bin/otp @@ -9,7 +9,7 @@ # computer to have its time properly synced. This can be done with the command # below which requires the package `ntp`. -ifinstalled pass pass-otp +ifinstalled pass pass-otp || exit 1 dir="${PASSWORD_STORE_DIR}" From 41b729acd303ff1180ca2e1a9ab9e0b05a0e4c29 Mon Sep 17 00:00:00 2001 From: appeasementPolitik <108810900+appeasementPolitik@users.noreply.github.com> Date: Thu, 22 Sep 2022 12:52:04 +0000 Subject: [PATCH 6/7] Fix tag script mp3 issue (#1182) * Fix tag script mp3 issue When you don't manually specify $total and $date with an mp3 file the eyeD3 command tries tagging with an empty variable, which causes it to error. This fixes it by only passing the parameter to the command if the variable is set. This pull request also adds support for the $genre and $comment variable. * Remove double backslash --- .local/bin/tag | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.local/bin/tag b/.local/bin/tag index 8462b99..11a5b8e 100755 --- a/.local/bin/tag +++ b/.local/bin/tag @@ -54,7 +54,11 @@ 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" ;; + *.mp3) eyeD3 -Q --remove-all -a "$artist" -t "$title" -A "$album" -n "$track" \ + ${total:+-N "$total"} \ + ${date:+-Y "$date"} \ + ${genre:+-G "$genre"} \ + ${comment:+-c "$comment"} "$file" ;; *.flac) echo "TITLE=$title ARTIST=$artist ALBUM=$album From 21e08299b1709c6051a42560ca89967894d5c962 Mon Sep 17 00:00:00 2001 From: appeasementPolitik <108810900+appeasementPolitik@users.noreply.github.com> Date: Fri, 23 Sep 2022 14:55:42 +0000 Subject: [PATCH 7/7] Use ffmpeg for tag script (#1193) eyeD3 got orphaned in the AUR, so I looked for an alternative. Apparently ffmpeg also supports the ability to tag audio files, so this pull request replaces all the helper applications with ffmpeg --- .local/bin/tag | 56 +++++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/.local/bin/tag b/.local/bin/tag index 11a5b8e..92d6323 100755 --- a/.local/bin/tag +++ b/.local/bin/tag @@ -13,7 +13,7 @@ Options: -c: comment 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}" ;; t) title="${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}" ;; g) genre="${OPTARG}" ;; c) comment="${OPTARG}" ;; - f) file="${OPTARG}" ;; *) printf "Invalid option: -%s\\n" "$OPTARG" && err ;; esac done @@ -30,42 +29,21 @@ shift $((OPTIND - 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 -[ -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 +[ ! -f "$file" ] && echo 'Provide file to tag.' && err -case "$file" in - *.ogg) echo "Title=$title -Artist=$artist -Album=$album -Track=$track -Total=$total -Date=$date -Genre=$genre -Comment=$comment" | vorbiscomment -w "$file" ;; - *.opus) echo "Title=$title -Artist=$artist -Album=$album -Track=$track -Total=$total -Date=$date -Genre=$genre -Comment=$comment" | opustags -i -S "$file" ;; - *.mp3) eyeD3 -Q --remove-all -a "$artist" -t "$title" -A "$album" -n "$track" \ - ${total:+-N "$total"} \ - ${date:+-Y "$date"} \ - ${genre:+-G "$genre"} \ - ${comment:+-c "$comment"} "$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 +[ -z "$title" ] && echo 'Enter a title.' && read -r title +[ -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 + +cp -f "$file" "$temp" && ffmpeg -i "$temp" -map 0 -y -codec copy \ + -metadata title="$title" \ + -metadata album="$album" \ + -metadata artist="$artist" \ + -metadata track="${track}${total:+/"$total"}" \ + ${date:+-metadata date="$date"} \ + ${genre:+-metadata genre="$genre"} \ + ${comment:+-metadata comment="$comment"} "$file"