add scripts
This commit is contained in:
parent
52a68ee195
commit
27722d1154
10
home/default/.local/bin/bookmark
Executable file
10
home/default/.local/bin/bookmark
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
bookmark="$(wl-paste)"
|
||||||
|
file="$HOME/notebook/bookmarks/bookmarks.md"
|
||||||
|
|
||||||
|
if grep -q "^$bookmark$" "$file"; then
|
||||||
|
notify-send "error." "bookmark \"$bookmark\" exists."
|
||||||
|
else
|
||||||
|
notify-send "bookmark added." "$bookmark is now saved to the file."
|
||||||
|
echo "$bookmark" >> "$file"
|
||||||
|
fi
|
43
home/default/.local/bin/booksplit
Executable file
43
home/default/.local/bin/booksplit
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Requires ffmpeg
|
||||||
|
|
||||||
|
[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit
|
||||||
|
|
||||||
|
echo "Enter the album/book title:"; read -r booktitle
|
||||||
|
echo "Enter the artist/author:"; read -r author
|
||||||
|
echo "Enter the publication year:"; read -r year
|
||||||
|
|
||||||
|
inputaudio="$1"
|
||||||
|
ext="${1##*.}"
|
||||||
|
|
||||||
|
# Get a safe file name from the book.
|
||||||
|
escbook="$(echo "$booktitle" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
|
||||||
|
|
||||||
|
! mkdir -p "$escbook" &&
|
||||||
|
echo "Do you have write access in this directory?" &&
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
# Get the total number of tracks from the number of lines.
|
||||||
|
total="$(wc -l < "$2")"
|
||||||
|
|
||||||
|
cmd="ffmpeg -i \"$inputaudio\" -nostdin -y"
|
||||||
|
|
||||||
|
while read -r x;
|
||||||
|
do
|
||||||
|
end="$(echo "$x" | cut -d' ' -f1)"
|
||||||
|
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
|
||||||
|
if [ -n "$start" ]; then
|
||||||
|
cmd="$cmd -metadata artist=\"$author\" -metadata title=\"$title\" -metadata album=\"$booktitle\" -metadata year=\"$year\" -metadata track=\"$track\" -metadata total=\"$total\" -ss \"$start\" -to \"$end\" -vn -c:a copy \"$file\" "
|
||||||
|
fi
|
||||||
|
title="$(echo "$x" | cut -d' ' -f2-)"
|
||||||
|
esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
|
||||||
|
track="$((track+1))"
|
||||||
|
start="$end"
|
||||||
|
done < "$2"
|
||||||
|
|
||||||
|
# Last track must be added out of the loop.
|
||||||
|
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
|
||||||
|
cmd="$cmd -metadata artist=\"$author\" -metadata title=\"$title\" -metadata album=\"$booktitle\" -metadata year=\"$year\" -metadata track=\"$track\" -ss \"$start\" -vn -c copy \"$file\""
|
||||||
|
|
||||||
|
eval "$cmd"
|
32
home/default/.local/bin/change-background
Executable file
32
home/default/.local/bin/change-background
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Location of link to wallpaper link.
|
||||||
|
bgloc="${XDG_DATA_HOME:-$HOME/.local/share}/bg"
|
||||||
|
bgaloc="${XDG_DATA_HOME:-$HOME/.local/share}/bga"
|
||||||
|
|
||||||
|
|
||||||
|
trueloc="$(readlink -f "$1")" &&
|
||||||
|
case "$(file --mime-type -b "$trueloc")" in
|
||||||
|
video/* ) ifinstalled mpvpaper && ln -sf "$trueloc" "$bgaloc" && notify-send -i "$bgaloc" "Changing wallpaper..." ;;
|
||||||
|
image/gif ) ifinstalled mpvpaper && ln -sf "$trueloc" "$bgaloc" && ln -sf "$trueloc" "$bgloc" && notify-send -i "$bgaloc" "Changing wallpaper..." ;;
|
||||||
|
image/* ) ln -sf "$trueloc" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..."
|
||||||
|
if [[ -f "$bgaloc" ]]; then
|
||||||
|
rm $bgaloc
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
inode/directory ) ln -sf "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen."
|
||||||
|
rm $bgaloc
|
||||||
|
;;
|
||||||
|
*) notify-send "🖼️ Error" "Not a valid image or directory." ; exit 1;;
|
||||||
|
esac
|
||||||
|
if [[ -f "$bgaloc" ]]; then
|
||||||
|
killall swaybg >/dev/null 2>&1
|
||||||
|
killall mpvpaper >/dev/null 2>&1
|
||||||
|
sleep 1 && setsid -f mpvpaper -f -o 'no-audio loop --panscan=1' '*' $bgaloc >/dev/null 2>&1
|
||||||
|
exit 0
|
||||||
|
elif [[ -f "$bgloc" ]]; then
|
||||||
|
killall swaybg >/dev/null 2>&1
|
||||||
|
killall mpvpaper >/dev/null 2>&1
|
||||||
|
sleep 1 && setsid -f swaybg -m fill -i $bgloc >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
exit 0
|
3
home/default/.local/bin/color-picker
Executable file
3
home/default/.local/bin/color-picker
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
grim -g "$(slurp -p)" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt:-
|
||||||
|
|
57
home/default/.local/bin/compiler
Executable file
57
home/default/.local/bin/compiler
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script will compile or run another finishing operation on a document. I
|
||||||
|
# have this script run via vim.
|
||||||
|
#
|
||||||
|
# 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=$(readlink -f "$1")
|
||||||
|
dir=${file%/*}
|
||||||
|
base="${file%.*}"
|
||||||
|
ext="${file##*.}"
|
||||||
|
|
||||||
|
cd "$dir" || exit 1
|
||||||
|
|
||||||
|
textype() { \
|
||||||
|
command="pdflatex"
|
||||||
|
( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex"
|
||||||
|
$command --output-directory="$dir" "$base" &&
|
||||||
|
grep -qi addbibresource "$file" &&
|
||||||
|
biber --input-directory "$dir" "$base" &&
|
||||||
|
$command --output-directory="$dir" "$base" &&
|
||||||
|
$command --output-directory="$dir" "$base"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$ext" in
|
||||||
|
# Try to keep these cases in alphabetical order.
|
||||||
|
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
|
||||||
|
c) cc "$file" -o "$base" && "$base" ;;
|
||||||
|
cpp) g++ "$file" -o "$base" && "$base" ;;
|
||||||
|
cs) mcs "$file" && mono "$base".exe ;;
|
||||||
|
go) go run "$file" ;;
|
||||||
|
h) sudo make install ;;
|
||||||
|
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
|
||||||
|
m) octave "$file" ;;
|
||||||
|
md) if [ -x "$(command -v lowdown)" ]; then
|
||||||
|
lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept > "$base".pdf
|
||||||
|
elif [ -x "$(command -v groffdown)" ]; then
|
||||||
|
groffdown -i "$file" | groff > "$base.pdf"
|
||||||
|
else
|
||||||
|
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
|
||||||
|
fi ; ;;
|
||||||
|
mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;;
|
||||||
|
ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;;
|
||||||
|
org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;;
|
||||||
|
py) python "$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) textype "$file" ;;
|
||||||
|
*) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;;
|
||||||
|
esac
|
21
home/default/.local/bin/dmenuhandler
Executable file
21
home/default/.local/bin/dmenuhandler
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Feed this script a link and it will give dmenu
|
||||||
|
# some choice programs to use to open it.
|
||||||
|
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
|
||||||
|
"Copy URL") echo "$feed" | wl-copy ;;
|
||||||
|
mpv) setsid -f mpv -quiet "$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 ;;
|
||||||
|
"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 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 ;;
|
||||||
|
nsxiv) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && nsxiv -a "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;;
|
||||||
|
vim) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && setsid -f "$TERMINAL" -e "$EDITOR" "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;;
|
||||||
|
setbg) curl -L "$feed" > $XDG_CACHE_HOME/pic ; xwallpaper --zoom $XDG_CACHE_HOME/pic >/dev/null 2>&1 ;;
|
||||||
|
browser) setsid -f "$BROWSER" "$feed" >/dev/null 2>&1 ;;
|
||||||
|
lynx) lynx "$feed" >/dev/null 2>&1 ;;
|
||||||
|
esac
|
67
home/default/.local/bin/dmenumount
Executable file
67
home/default/.local/bin/dmenumount
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Gives a dmenu prompt to mount unmounted drives and Android phones. If
|
||||||
|
# they're in /etc/fstab, they'll be mounted automatically. Otherwise, you'll
|
||||||
|
# be prompted to give a mountpoint from already existsing directories. If you
|
||||||
|
# input a novel directory, it will prompt you to create that directory.
|
||||||
|
|
||||||
|
getmount() { \
|
||||||
|
[ -z "$chosen" ] && exit 1
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
|
||||||
|
test -z "$mp" && exit 1
|
||||||
|
if [ ! -d "$mp" ]; then
|
||||||
|
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
|
||||||
|
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
mountusb() { \
|
||||||
|
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
|
||||||
|
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||||
|
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
||||||
|
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
|
||||||
|
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
|
||||||
|
partitiontype="$(lsblk -no "fstype" "$chosen")"
|
||||||
|
case "$partitiontype" in
|
||||||
|
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
|
||||||
|
"exfat") sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)";;
|
||||||
|
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
|
||||||
|
esac
|
||||||
|
notify-send "💻 USB mounting" "$chosen mounted to $mp."
|
||||||
|
}
|
||||||
|
|
||||||
|
mountandroid() { \
|
||||||
|
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
|
||||||
|
chosen="$(echo "$chosen" | cut -d : -f 1)"
|
||||||
|
getmount "$HOME -maxdepth 3 -type d"
|
||||||
|
simple-mtpfs --device "$chosen" "$mp"
|
||||||
|
echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
|
||||||
|
simple-mtpfs --device "$chosen" "$mp"
|
||||||
|
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
|
||||||
|
}
|
||||||
|
|
||||||
|
asktype() { \
|
||||||
|
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1
|
||||||
|
case $choice in
|
||||||
|
USB) mountusb ;;
|
||||||
|
Android) mountandroid ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
anddrives=$(simple-mtpfs -l 2>/dev/null)
|
||||||
|
usbdrives="$(lsblk -rpo "name,type,size,label,mountpoint,fstype" | grep -v crypto_LUKS | grep 'part\|rom' | sed 's/ /:/g' | awk -F':' '$5==""{printf "%s (%s) %s\n",$1,$3,$4}')"
|
||||||
|
|
||||||
|
if [ -z "$usbdrives" ]; then
|
||||||
|
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
|
||||||
|
echo "Android device(s) detected."
|
||||||
|
mountandroid
|
||||||
|
else
|
||||||
|
if [ -z "$anddrives" ]; then
|
||||||
|
echo "USB drive(s) detected."
|
||||||
|
mountusb
|
||||||
|
else
|
||||||
|
echo "Mountable USB drive(s) and Android device(s) detected."
|
||||||
|
asktype
|
||||||
|
fi
|
||||||
|
fi
|
19
home/default/.local/bin/dmenumountcifs
Executable file
19
home/default/.local/bin/dmenumountcifs
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Gives a dmenu prompt to mount unmounted local NAS shares for read/write.
|
||||||
|
# Requirements - "%wheel ALL=(ALL) NOPASSWD: ALL"
|
||||||
|
#
|
||||||
|
# Browse for mDNS/DNS-SD services using the Avahi daemon...
|
||||||
|
srvname=$(avahi-browse _smb._tcp -t | awk '{print $4}' | dmenu -i -p "Which NAS?") || exit 1
|
||||||
|
notify-send "Searching for network shares..." "Please wait..."
|
||||||
|
# Choose share disk...
|
||||||
|
share=$(smbclient -L "$srvname" -N | grep Disk | awk '{print $1}' | dmenu -i -p "Mount which share?") || exit 1
|
||||||
|
# Format URL...
|
||||||
|
share2mnt=//"$srvname".local/"$share"
|
||||||
|
|
||||||
|
sharemount() {
|
||||||
|
mounted=$(mount -v | grep "$share2mnt") || ([ ! -d /mnt/"$share" ] && sudo mkdir /mnt/"$share")
|
||||||
|
[ -z "$mounted" ] && sudo mount -t cifs "$share2mnt" -o user=nobody,password="",noperm /mnt/"$share" && notify-send "Netshare $share mounted" && exit 0
|
||||||
|
notify-send "Netshare $share already mounted"; exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
sharemount
|
44
home/default/.local/bin/dmenuumount
Executable file
44
home/default/.local/bin/dmenuumount
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# A dmenu prompt to unmount drives.
|
||||||
|
# Provides you with mounted partitions, select one to unmount.
|
||||||
|
# Drives mounted at /, /boot and /home will not be options to unmount.
|
||||||
|
|
||||||
|
unmountusb() {
|
||||||
|
[ -z "$drives" ] && exit
|
||||||
|
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
|
||||||
|
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||||
|
[ -z "$chosen" ] && exit
|
||||||
|
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
|
||||||
|
}
|
||||||
|
|
||||||
|
unmountandroid() { \
|
||||||
|
chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1
|
||||||
|
[ -z "$chosen" ] && exit
|
||||||
|
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
|
||||||
|
}
|
||||||
|
|
||||||
|
asktype() { \
|
||||||
|
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" || exit 1
|
||||||
|
case "$choice" in
|
||||||
|
USB) unmountusb ;;
|
||||||
|
Android) unmountandroid ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
drives=$(lsblk -nrpo "name,type,size,mountpoint,label" | awk -F':' '{gsub(/ /,":")}$4!~/\/boot|\/efi|\/home$|SWAP/&&length($4)>1{printf "%s (%s) %s\n",$4,$3,$5}')
|
||||||
|
|
||||||
|
if ! grep simple-mtpfs /etc/mtab; then
|
||||||
|
[ -z "$drives" ] && echo "No drives to unmount." && exit
|
||||||
|
echo "Unmountable USB drive detected."
|
||||||
|
unmountusb
|
||||||
|
else
|
||||||
|
if [ -z "$drives" ]
|
||||||
|
then
|
||||||
|
echo "Unmountable Android device detected."
|
||||||
|
unmountandroid
|
||||||
|
else
|
||||||
|
echo "Unmountable USB drive(s) and Android device(s) detected."
|
||||||
|
asktype
|
||||||
|
fi
|
||||||
|
fi
|
14
home/default/.local/bin/idle
Executable file
14
home/default/.local/bin/idle
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
swayidle -w \
|
||||||
|
timeout 310 'swaylock' \
|
||||||
|
timeout 300 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
|
||||||
|
before-sleep "swaylock"
|
||||||
|
fi
|
||||||
|
if [[ $1 == "-k" ]]; then
|
||||||
|
killall swayidle
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [[ $1 != "-k" ]]; then
|
||||||
|
echo 'wrong syntax, do idle or idle -k'
|
||||||
|
fi
|
28
home/default/.local/bin/linkhandler
Executable file
28
home/default/.local/bin/linkhandler
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Feed script a url or file location.
|
||||||
|
# If an image, it will view in sxiv,
|
||||||
|
# if a video or gif, it will view in mpv
|
||||||
|
# if a music file or pdf, it will download,
|
||||||
|
# otherwise it opens link in browser.
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
url="$(wl-paste)"
|
||||||
|
else
|
||||||
|
url="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$url" in
|
||||||
|
*mkv|*webm|*mp4|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*)
|
||||||
|
setsid -f mpv -quiet "$url" >/dev/null 2>&1 ;;
|
||||||
|
*youtube.com/watch*|*youtube.com/playlist*|*youtube.com/shorts*|*youtu.be*)
|
||||||
|
setsid -f flatpak run io.freetubeapp.FreeTube "$url" >/dev/null 2>&1 ;;
|
||||||
|
*png|*jpg|*jpe|*jpeg|*gif)
|
||||||
|
curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
|
||||||
|
*pdf|*cbz|*cbr)
|
||||||
|
curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
|
||||||
|
*mp3|*flac|*opus|*mp3?source*)
|
||||||
|
qndl "$url" 'curl -LO' >/dev/null 2>&1 ;;
|
||||||
|
*)
|
||||||
|
[ -f "$url" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$url" >/dev/null 2>&1 || setsid -f "$BROWSER" "$url" >/dev/null 2>&1
|
||||||
|
esac
|
15
home/default/.local/bin/musdl
Executable file
15
home/default/.local/bin/musdl
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
file="$(wl-paste)"
|
||||||
|
directory="$HOME/Music"
|
||||||
|
|
||||||
|
case "$file" in
|
||||||
|
*youtube.com*|*youtu.be*|*bandcamp.com*)
|
||||||
|
notify-send "Downloading" "$file"
|
||||||
|
cd $directory && yt-dlp --embed-metadata --embed-thumbnail -xc -f bestaudio/best --restrict-filenames "$file" && notify-send "Music added!" "$file is now saved to the music directory."
|
||||||
|
;;
|
||||||
|
*mp3|*flac|*opus|*mp3?source*)
|
||||||
|
notify-send "⏳ Queuing $file..."
|
||||||
|
cd $directory && curl -LO $file >/dev/null 2>&1 && notify-send "Music added!" "$file is now saved to the music directory." ;;
|
||||||
|
esac
|
||||||
|
exit 0
|
13
home/default/.local/bin/opout
Executable file
13
home/default/.local/bin/opout
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# opout: "open output": A general handler for opening a file's intended output,
|
||||||
|
# usually the pdf of a compiled document. I find this useful especially
|
||||||
|
# running from vim.
|
||||||
|
|
||||||
|
basename="${1%.*}"
|
||||||
|
|
||||||
|
case "${*}" in
|
||||||
|
*.tex|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) setsid -f xdg-open "$basename".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
|
7
home/default/.local/bin/podentr
Executable file
7
home/default/.local/bin/podentr
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# entr command to run `queueandnotify` when newsboat queue is changed
|
||||||
|
|
||||||
|
[ "$(pgrep -x "$(basename "$0")" | wc -l)" -gt 2 ] && exit
|
||||||
|
|
||||||
|
echo "${XDG_DATA_HOME:-$HOME/.local/share}"/newsboat/queue | entr -p queueandnotify 2>/dev/null
|
8
home/default/.local/bin/prompt
Executable file
8
home/default/.local/bin/prompt
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/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
|
12
home/default/.local/bin/qndl
Executable file
12
home/default/.local/bin/qndl
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# $1 is a url; $2 is a command
|
||||||
|
[ -z "$1" ] && exit
|
||||||
|
base="$(basename "$1")"
|
||||||
|
notify-send "⏳ Queuing $base..."
|
||||||
|
cmd="$2"
|
||||||
|
[ -z "$cmd" ] && cmd="yt-dlp --embed-metadata -ic"
|
||||||
|
idnum="$(tsp $cmd "$1")"
|
||||||
|
realname="$(echo "$base" | sed "s/?\(source\|dest\).*//;s/%20/ /g")"
|
||||||
|
tsp -D "$idnum" mv "$base" "$realname"
|
||||||
|
tsp -D "$idnum" notify-send "👍 $realname done."
|
14
home/default/.local/bin/queueandnotify
Executable file
14
home/default/.local/bin/queueandnotify
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Podboat sucks. This script replaces it.
|
||||||
|
# It reads the newsboat queue, queuing downloads with taskspooler.
|
||||||
|
# It also removes the junk from extensions.
|
||||||
|
queuefile="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/queue"
|
||||||
|
|
||||||
|
while read -r line; do
|
||||||
|
[ -z "$line" ] && continue
|
||||||
|
url="${line%%[ ]*}"
|
||||||
|
qndl "$url" "curl -LO"
|
||||||
|
done < "$queuefile"
|
||||||
|
|
||||||
|
echo > "$queuefile"
|
12
home/default/.local/bin/rotdir
Executable file
12
home/default/.local/bin/rotdir
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# When I open an image from the file manager in sxiv (the image viewer), I want
|
||||||
|
# to be able to press the next/previous keys to key through the rest of the
|
||||||
|
# images in the same directory. This script "rotates" the content of a
|
||||||
|
# directory based on the first chosen file, so that if I open the 15th image,
|
||||||
|
# if I press next, it will go to the 16th etc. Autistic, I know, but this is
|
||||||
|
# one of the reasons that sxiv is great for being able to read standard input.
|
||||||
|
|
||||||
|
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
|
||||||
|
base="$(basename "$1")"
|
||||||
|
ls "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }'
|
18
home/default/.local/bin/rssadd
Executable file
18
home/default/.local/bin/rssadd
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if echo "$1" | grep -q "https*://\S\+\.[A-Za-z]\+\S*" ; then
|
||||||
|
url="$1"
|
||||||
|
else
|
||||||
|
url="$(grep -Eom1 '<[^>]+(rel="self"|application/[a-z]+\+xml)[^>]+>' "$1" |
|
||||||
|
grep -o "https?://[^\" ]")"
|
||||||
|
|
||||||
|
echo "$url" | grep -q "https*://\S\+\.[A-Za-z]\+\S*" ||
|
||||||
|
notify-send "That doesn't look like a full URL." && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls"
|
||||||
|
if awk '{print $1}' "$RSSFILE" | grep "^$url$" >/dev/null; then
|
||||||
|
notify-send "You already have this RSS feed."
|
||||||
|
else
|
||||||
|
echo "$url" >> "$RSSFILE" && notify-send "RSS feed added."
|
||||||
|
fi
|
43
home/default/.local/bin/shortcuts
Executable file
43
home/default/.local/bin/shortcuts
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
bmdirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs"
|
||||||
|
bmfiles="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-files"
|
||||||
|
|
||||||
|
# Output locations. Unactivated progs should go to /dev/null.
|
||||||
|
shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc"
|
||||||
|
zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
|
||||||
|
lf_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc"
|
||||||
|
vim_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/nvim/shortcuts.vim"
|
||||||
|
ranger_shortcuts="/dev/null"
|
||||||
|
qute_shortcuts="/dev/null"
|
||||||
|
fish_shortcuts="/dev/null"
|
||||||
|
vifm_shortcuts="/dev/null"
|
||||||
|
|
||||||
|
# Remove, prepare files
|
||||||
|
rm -f "$lf_shortcuts" "$ranger_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" "$vim_shortcuts" 2>/dev/null
|
||||||
|
printf "# vim: filetype=sh\\n" > "$fish_shortcuts"
|
||||||
|
printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
|
||||||
|
printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts"
|
||||||
|
|
||||||
|
# Format the `directories` file in the correct syntax and sent it to all three configs.
|
||||||
|
eval "echo \"$(cat "$bmdirs")\"" | \
|
||||||
|
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
||||||
|
printf(\"%s=\42cd %s && ls -a\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
||||||
|
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
||||||
|
printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
||||||
|
printf(\"map g%s :cd %s<CR>\nmap t%s <tab>:cd %s<CR><tab>\nmap M%s <tab>:cd %s<CR><tab>:mo<CR>\nmap Y%s <tab>:cd %s<CR><tab>:co<CR> \n\",\$1,\$2, \$1, \$2, \$1, \$2, \$1, \$2) >> \"$vifm_shortcuts\" ;
|
||||||
|
printf(\"config.bind(';%s', \42set downloads.location.directory %s ;; hint links download\42) \n\",\$1,\$2) >> \"$qute_shortcuts\" ;
|
||||||
|
printf(\"map g%s cd %s\nmap t%s tab_new %s\nmap m%s shell mv -v %%s %s\nmap Y%s shell cp -rv %%s %s \n\",\$1,\$2,\$1,\$2, \$1, \$2, \$1, \$2) >> \"$ranger_shortcuts\" ;
|
||||||
|
printf(\"map C%s cd \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" ;
|
||||||
|
printf(\"cmap ;%s %s\n\",\$1,\$2) >> \"$vim_shortcuts\" }"
|
||||||
|
|
||||||
|
# Format the `files` file in the correct syntax and sent it to both configs.
|
||||||
|
eval "echo \"$(cat "$bmfiles")\"" | \
|
||||||
|
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
||||||
|
printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
||||||
|
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
||||||
|
printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
||||||
|
printf(\"map %s :e %s<CR> \n\",\$1,\$2) >> \"$vifm_shortcuts\" ;
|
||||||
|
printf(\"map %s shell \$EDITOR %s \n\",\$1,\$2) >> \"$ranger_shortcuts\" ;
|
||||||
|
printf(\"map E%s \$\$EDITOR \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" ;
|
||||||
|
printf(\"cmap ;%s %s\n\",\$1,\$2) >> \"$vim_shortcuts\" }"
|
126
home/default/.local/bin/slider
Executable file
126
home/default/.local/bin/slider
Executable file
@ -0,0 +1,126 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Give a file with images and timecodes and creates a video slideshow of them.
|
||||||
|
#
|
||||||
|
# Timecodes must be in format 00:00:00.
|
||||||
|
#
|
||||||
|
# Imagemagick and ffmpeg required.
|
||||||
|
|
||||||
|
# Application cache if not stated elsewhere.
|
||||||
|
cache="${XDG_CACHE_HOME:-$HOME/.cache}/slider"
|
||||||
|
|
||||||
|
while getopts "hvrpi:c:a:o:d:f:t:e:x:" o; do case "${o}" in
|
||||||
|
c) bgc="$OPTARG" ;;
|
||||||
|
t) fgc="$OPTARG" ;;
|
||||||
|
f) font="$OPTARG" ;;
|
||||||
|
i) file="$OPTARG" ;;
|
||||||
|
a) audio="$OPTARG" ;;
|
||||||
|
o) outfile="$OPTARG" ;;
|
||||||
|
d) prepdir="$OPTARG" ;;
|
||||||
|
r) redo="$OPTARG" ;;
|
||||||
|
s) ppt="$OPTARG" ;;
|
||||||
|
e) endtime="$OPTARG" ;;
|
||||||
|
x) res="$OPTARG"
|
||||||
|
echo "$res" | grep -qv "^[0-9]\+x[0-9]\+$" &&
|
||||||
|
echo "Resolution must be dimensions separated by a 'x': 1280x720, etc." &&
|
||||||
|
exit 1 ;;
|
||||||
|
p) echo "Purge old build files in $cache? [y/N]"
|
||||||
|
read -r confirm
|
||||||
|
echo "$confirm" | grep -iq "^y$" && rm -rf "$cache" && echo "Done."
|
||||||
|
exit ;;
|
||||||
|
v) verbose=True ;;
|
||||||
|
*) echo "$(basename "$0") usage:
|
||||||
|
-i input timecode list (required)
|
||||||
|
-a audio file
|
||||||
|
-c color of background (use html names, black is default)
|
||||||
|
-t text color for text slides (white is default)
|
||||||
|
-s text font size for text slides (150 is default)
|
||||||
|
-f text font for text slides (sans serif is default)
|
||||||
|
-o output video file
|
||||||
|
-e if no audio given, the time in seconds that the last slide will be shown (5 is default)
|
||||||
|
-x resolution (1920x1080 is default)
|
||||||
|
-d tmp directory
|
||||||
|
-r rerun imagemagick commands even if done previously (in case files or background has changed)
|
||||||
|
-p purge old build files instead of running
|
||||||
|
-v be verbose" && exit 1
|
||||||
|
|
||||||
|
esac done
|
||||||
|
|
||||||
|
# Check that the input file looks like it should.
|
||||||
|
{ head -n 1 "$file" 2>/dev/null | grep -q "^00:00:00 " ;} || {
|
||||||
|
echo "Give an input file with -i." &&
|
||||||
|
echo "The file should look as this example:
|
||||||
|
|
||||||
|
00:00:00 first_image.jpg
|
||||||
|
00:00:03 otherdirectory/next_image.jpg
|
||||||
|
00:00:09 this_image_starts_at_9_seconds.jpg
|
||||||
|
etc...
|
||||||
|
|
||||||
|
Timecodes and filenames must be separated by Tabs." &&
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -n "${audio+x}" ]; then
|
||||||
|
# Check that the audio file looks like an actual audio file.
|
||||||
|
case "$(file --dereference --brief --mime-type -- "$audio")" in
|
||||||
|
audio/*) ;;
|
||||||
|
*) echo "That doesn't look like an audio file."; exit 1 ;;
|
||||||
|
esac
|
||||||
|
totseconds="$(date '+%s' -d $(ffmpeg -i "$audio" 2>&1 | awk '/Duration/ {print $2}' | sed s/,//))"
|
||||||
|
endtime="$((totseconds-seconds))"
|
||||||
|
fi
|
||||||
|
|
||||||
|
prepdir="${prepdir:-$cache/$file}"
|
||||||
|
outfile="${outfile:-$file.mp4}"
|
||||||
|
prepfile="$prepdir/$file.prep"
|
||||||
|
|
||||||
|
[ -n "${verbose+x}" ] && echo "Preparing images... May take a while depending on the number of files."
|
||||||
|
mkdir -p "$prepdir"
|
||||||
|
|
||||||
|
{
|
||||||
|
while read -r x;
|
||||||
|
do
|
||||||
|
# Get the time from the first column.
|
||||||
|
time="${x%% *}"
|
||||||
|
seconds="$(date '+%s' -d "$time")"
|
||||||
|
# Duration is not used on the first looped item.
|
||||||
|
duration="$((seconds - prevseconds))"
|
||||||
|
|
||||||
|
# Get the filename/text content from the rest.
|
||||||
|
content="${x#* }"
|
||||||
|
base="$(basename "$content")"
|
||||||
|
base="${base%.*}.jpg"
|
||||||
|
|
||||||
|
if [ -f "$content" ]; then
|
||||||
|
# If images have already been made in a previous run, do not recreate
|
||||||
|
# them unless -r was given.
|
||||||
|
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ] ;} &&
|
||||||
|
convert -size "${res:-1920x1080}" canvas:"${bgc:-black}" -gravity center "$content" -resize 1920x1080 -composite "$prepdir/$base"
|
||||||
|
else
|
||||||
|
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ] ;} &&
|
||||||
|
convert -size "${res:-1920x1080}" -background "${bgc:-black}" -fill "${fgc:-white}" -font "${font:-Sans}" -pointsize "${ppt:-150}" -gravity center label:"$content" "$prepdir/$base"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the first line, do not write yet.
|
||||||
|
[ "$time" = "00:00:00" ] || echo "file '$prevbase'
|
||||||
|
duration $duration"
|
||||||
|
|
||||||
|
# Keep the information required for the next file.
|
||||||
|
prevbase="$base"
|
||||||
|
prevtime="$time"
|
||||||
|
prevseconds="$(date '+%s' -d "$prevtime")"
|
||||||
|
done < "$file"
|
||||||
|
# Do last file which must be given twice as follows
|
||||||
|
echo "file '$base'
|
||||||
|
duration ${endtime:-5}
|
||||||
|
file '$base'"
|
||||||
|
} > "$prepfile"
|
||||||
|
if [ -n "${audio+x}" ]; then
|
||||||
|
ffmpeg -hide_banner -y -f concat -safe 0 -i "$prepfile" -i "$audio" -c:a aac -vsync vfr -c:v libx264 -pix_fmt yuv420p "$outfile"
|
||||||
|
else
|
||||||
|
ffmpeg -hide_banner -y -f concat -safe 0 -i "$prepfile" -vsync vfr -c:v libx264 -pix_fmt yuv420p "$outfile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Might also try:
|
||||||
|
# -vf "fps=${fps:-24},format=yuv420p" "$outfile"
|
||||||
|
# but has given some problems.
|
28
home/default/.local/bin/sysact
Executable file
28
home/default/.local/bin/sysact
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# A dmenu wrapper script for system functions.
|
||||||
|
export WM=$XDG_CURRENT_DESKTOP
|
||||||
|
case "$(readlink -f /sbin/init)" in
|
||||||
|
*systemd*) ctl='systemctl' ;;
|
||||||
|
*) ctl='loginctl' ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$(printf "🔒 lock\n🚪 leave $WM\n♻️ renew\n🐻 hibernate\n🔃 reboot\n🖥️ shutdown\n💤 sleep\n📺 display off\n set background\n start idle\n kill swayidle\n fcitx5\n kill fcitx5" | dmenu -i -l 12 -p 'Action: ')" in
|
||||||
|
'🔒 lock')
|
||||||
|
setsid -f swaylock
|
||||||
|
setsid -f sleep 2 && swayidle -w timeout 1 'wlopm --off "*"' resume 'wlopm --on "*" && kill $#'
|
||||||
|
;;
|
||||||
|
"🚪 leave $WM") swaymsg exit ;;
|
||||||
|
"♻️ renew") swaymsg reload ;;
|
||||||
|
'🐻 hibernate') $ctl hibernate -i ;;
|
||||||
|
'💤 sleep') $ctl suspend -i ;;
|
||||||
|
'🔃 reboot') $ctl reboot -i ;;
|
||||||
|
'🖥️ shutdown') $ctl poweroff -i ;;
|
||||||
|
'📺 display off') swayidle -w timeout 1 'wlopm --off "*"' resume 'wlopm --on "*" && kill $#' ;;
|
||||||
|
' set background') change-background ;;
|
||||||
|
' start idle') idle ;;
|
||||||
|
' kill swayidle') killall swayidle ;;
|
||||||
|
' fcitx5') fcitx5 ;;
|
||||||
|
' kill fcitx5') killall fcitx5 ;;
|
||||||
|
*) exit 1 ;;
|
||||||
|
esac
|
67
home/default/.local/bin/tag
Executable file
67
home/default/.local/bin/tag
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
err() { echo "Usage:
|
||||||
|
tag [OPTIONS] file
|
||||||
|
Options:
|
||||||
|
-a: artist/author
|
||||||
|
-t: song/chapter title
|
||||||
|
-A: album/book title
|
||||||
|
-n: track/chapter number
|
||||||
|
-N: total number of tracks/chapters
|
||||||
|
-d: year of publication
|
||||||
|
-g: genre
|
||||||
|
-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
|
||||||
|
a) artist="${OPTARG}" ;;
|
||||||
|
t) title="${OPTARG}" ;;
|
||||||
|
A) album="${OPTARG}" ;;
|
||||||
|
n) track="${OPTARG}" ;;
|
||||||
|
N) total="${OPTARG}" ;;
|
||||||
|
d) date="${OPTARG}" ;;
|
||||||
|
g) genre="${OPTARG}" ;;
|
||||||
|
c) comment="${OPTARG}" ;;
|
||||||
|
f) file="${OPTARG}" ;;
|
||||||
|
*) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
|
||||||
|
esac done
|
||||||
|
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
|
file="$1"
|
||||||
|
|
||||||
|
[ ! -f "$file" ] && echo "Provide file to tag." && err
|
||||||
|
|
||||||
|
[ -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
|
||||||
|
|
||||||
|
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" -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
|
16
home/default/.local/bin/texclear
Executable file
16
home/default/.local/bin/texclear
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Clears the build files of a LaTeX/XeLaTeX build.
|
||||||
|
# I have vim run this file whenever I exit a .tex file.
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
*.tex)
|
||||||
|
file=$(readlink -f "$1")
|
||||||
|
dir=$(dirname "$file")
|
||||||
|
base="${file%.*}"
|
||||||
|
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(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
|
||||||
|
rm -rdf "$dir/_minted-$(basename -- $base)"
|
||||||
|
;;
|
||||||
|
*) printf "Give .tex file as argument.\\n" ;;
|
||||||
|
esac
|
||||||
|
|
Loading…
Reference in New Issue
Block a user