Cohesive shell script formatting

- Format all shell scripts using [shfmt]
  (https://github.com/mvdan/sh).

Options used:

* `-bn`: binary ops like && and | may start a line
* `-sr`: redirect operators will be followed by a space
* `-ci`: indent switch cases
* `-i 4`: indent 4 spaces
* `-s`: simplify the code
* `-p`: parse for posix compliance

- Add Github action to lint changes to scripts and enforce formatting
  going forward

Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
This commit is contained in:
vlad doster 2021-03-13 00:13:26 -06:00 committed by Vladislav Doster
parent 87c2950039
commit eed099b954
64 changed files with 878 additions and 769 deletions

View File

@ -2,7 +2,8 @@
set -C -f -u
#IFS=$'\n'
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}"
IFS="$(printf '%b_' '\n')"
IFS="${IFS%_}"
# ANSI color codes are supported.
# STDIN is disabled, so interactive scripts won't work properly
@ -28,31 +29,31 @@ HIGHLIGHT_SIZE_MAX=262143 # 256KiB
HIGHLIGHT_TABWIDTH=8
HIGHLIGHT_STYLE='pablo'
handle_mime() {
local mimetype="${1}"
case "${mimetype}" in
text/html) w3m -dump "${FILE_PATH}" ;;
text/troff) man ./ "${FILE_PATH}" | col -b ;;
text/* | */xml)
if [ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]; then
if [ "$(stat --printf='%s' -- "${FILE_PATH}")" -gt "${HIGHLIGHT_SIZE_MAX}" ]; then
exit 2
fi
if [ "$( tput colors )" -ge 256 ]; then
if [ "$(tput colors)" -ge 256 ]; then
local highlight_format='xterm256'
else
local highlight_format='ansi'
fi
highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \
--style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}" ;;
--style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}"
;;
application/zip) atool --list -- "${FILE_PATH}" ;;
image/*) chafa --fill=block --symbols=block -c 256 -s 80x"${HEIGHT}" "${FILE_PATH}" || exit 1;;
video/* | audio/*|application/octet-stream) mediainfo "${FILE_PATH}" || exit 1;;
image/*) chafa --fill=block --symbols=block -c 256 -s 80x"${HEIGHT}" "${FILE_PATH}" || exit 1 ;;
video/* | audio/* | application/octet-stream) mediainfo "${FILE_PATH}" || exit 1 ;;
*/pdf) pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - ;;
*opendocument*) odt2txt "${FILE_PATH}" ;;
esac
}
MIMETYPE="$( file --dereference --brief --mime-type -- "${FILE_PATH}" )"
MIMETYPE="$(file --dereference --brief --mime-type -- "${FILE_PATH}")"
handle_mime "${MIMETYPE}"
exit 1

View File

@ -7,7 +7,7 @@
[ -f "$XINITRC" ] && alias startx="startx $XINITRC"
# sudo not required for some system commands
for x in mount umount sv pacman updatedb su ; do
for x in mount umount sv pacman updatedb su; do
alias $x="sudo $x"
done
@ -47,4 +47,4 @@ alias \
alias \
magit="nvim -c MagitOnly" \
ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/zshnameddirrc" \
weath="less -S ${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" \
weath="less -S ${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport"

View File

@ -1,6 +1,5 @@
#!/bin/sh
while read file
do
while read file; do
case "$1" in
"w") setbg "$file" & ;;
"c")
@ -14,19 +13,25 @@ do
mv "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file moved to $destdir." &
;;
"r")
convert -rotate 90 "$file" "$file" ;;
convert -rotate 90 "$file" "$file"
;;
"R")
convert -rotate -90 "$file" "$file" ;;
convert -rotate -90 "$file" "$file"
;;
"f")
convert -flop "$file" "$file" ;;
convert -flop "$file" "$file"
;;
"y")
echo -n "$file" | tr -d '\n' | xclip -selection clipboard &&
notify-send "$file copied to clipboard" & ;;
echo -n "$file" | tr -d '\n' | xclip -selection clipboard \
&& notify-send "$file copied to clipboard" &
;;
"Y")
readlink -f "$file" | tr -d '\n' | xclip -selection clipboard &&
notify-send "$(readlink -f "$file") copied to clipboard" & ;;
readlink -f "$file" | tr -d '\n' | xclip -selection clipboard \
&& notify-send "$(readlink -f "$file") copied to clipboard" &
;;
"d")
[ "$(printf "No\\nYes" | dmenu -i -p "Really delete $file?")" = "Yes" ] && rm "$file" && notify-send "$file deleted." ;;
[ "$(printf 'No\nYes' | dmenu -i -p "Really delete $file?")" = "Yes" ] && rm "$file" && notify-send "$file deleted."
;;
"g") ifinstalled gimp && setsid -f gimp "$file" ;;
"i") notify-send "File information" "$(mediainfo "$file")" ;;
esac

View File

@ -14,14 +14,14 @@ fix_sequences() {
background_color="$(echo -e "${sequences}\c" | grep --color=never -Eo "${e}]11[^${e}\\\\]*?${e}\\\\" | grep --color=never -Eo "#[0-9A-Fa-f]{6}")"
cursor_color="$(echo -e "${sequences}\c" | grep --color=never -Eo "${e}]12[^${e}\\\\]*?${e}\\\\" | grep --color=never -Eo "#[0-9A-Fa-f]{6}")"
for term in /dev/pts/{0..9}*
do
echo -e "\e]4;256;${cursor_color}\a\c" > "${term}" 2>/dev/null
echo -e "\e]4;258;${background_color}\a\c" > "${term}" 2>/dev/null
echo -e "\e]4;259;${foreground_color}\a\c" > "${term}" 2>/dev/null
done
for term in /dev/pts/{0..9}*; do
echo -e "\e]4;256;${cursor_color}\a\c" > "${term}" 2> /dev/null
echo -e "\e]4;258;${background_color}\a\c" > "${term}" 2> /dev/null
echo -e "\e]4;259;${foreground_color}\a\c" > "${term}" 2> /dev/null
done
}
fix_sequences <"${HOME}/.cache/wal/sequences"
fix_sequences < "${HOME}/.cache/wal/sequences"
pkill dunst; dunst &
pkill dunst
dunst &

View File

@ -15,6 +15,6 @@ unclutter & # Remove mouse when idle
# This line autostarts an instance of Pulseaudio that does not exit on idle.
# This is "necessary" on Artix due to a current bug between PA and
# Chromium-based browsers where they fail to start PA and use dummy output.
pidof -s runit &&
! pidof -s pulseaudio >/dev/null 2>&1 &&
setsid -f pulseaudio --start --exit-idle-time=-1 >/dev/null 2>&1
pidof -s runit \
&& ! pidof -s pulseaudio > /dev/null 2>&1 \
&& setsid -f pulseaudio --start --exit-idle-time=-1 > /dev/null 2>&1

38
.github/workflows/linter.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: shfmt-linter
on:
pull_request:
branches:
- master
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: update system
run: |
sudo apt-get upgrade --install-suggests --yes
- name: install dependencies
run: |
sudo apt-get install git \
make
- name: apply shfmt fixes
run: |
docker run --volume "$PWD":/mnt \
--rm \
mvdan/shfmt -bn -ci -d -i 4 -p -s -sr -w /mnt
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: (maint) apply shfmt formatting
commit_options: '--cleanup=default --no-verify --signoff'
push_options: '--force'
skip_dirty_check: false

View File

@ -2,13 +2,16 @@
# Requires ffmpeg (audio splitting) and my `tag` wrapper script.
[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit
[ ! -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 album/book title:"
read -r booktitle
echo "Enter the artist/author:"; read -r author
echo "Enter the artist/author:"
read -r author
echo "Enter the publication year:"; read -r year
echo "Enter the publication year:"
read -r year
inputaudio="$1"
@ -24,23 +27,22 @@ ext="opus"
# Get the total number of tracks from the number of lines.
total="$(wc -l < "$2")"
while read -r x;
do
while read -r x; do
end="$(echo "$x" | cut -d' ' -f1)"
[ -n "$start" ] &&
echo "From $start to $end; $track $title"
[ -n "$start" ] \
&& echo "From $start to $end; $track $title"
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
[ -n "$start" ] && echo "Splitting \"$title\"..." &&
ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn -c copy "$file" &&
echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
[ -n "$start" ] && echo "Splitting \"$title\"..." \
&& ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn -c copy "$file" \
&& echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
title="$(echo "$x" | cut -d' ' -f 2-)"
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))"
track="$((track + 1))"
start="$end"
done < "$2"
# The last track must be done outside the loop.
echo "From $start to the end: $title"
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn -c copy "$file" &&
echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn -c copy "$file" \
&& echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"

View File

@ -16,14 +16,14 @@ ext="${file##*.}"
cd "$dir" || exit 1
textype() { \
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"
(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
@ -42,7 +42,7 @@ case "$ext" in
groffdown -i "$file" | groff > "$base.pdf"
else
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
fi ; ;;
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 ;;
@ -51,7 +51,7 @@ case "$ext" in
rs) cargo build ;;
sass) sassc -a "$file" "$base.css" ;;
scad) openscad -o "$base".stl "$file" ;;
sent) setsid -f sent "$file" 2>/dev/null ;;
sent) setsid -f sent "$file" 2> /dev/null ;;
tex) textype "$file" ;;
*) head -n1 "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
esac

View File

@ -11,8 +11,7 @@ sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
Check your internet connection, if pacman is already running, or run update manually to see errors."
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
if pacman -Qu | grep -v "\[ignored\]"
then
if pacman -Qu | grep -v "\[ignored\]"; then
notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update."
else
notify-send "📦 Repository Sync" "Sync complete. No new packages for update."

View File

@ -3,4 +3,4 @@
# Toggles all cronjobs off/on.
# Stores disabled crontabs in ~/.consaved until restored.
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.")
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || (crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.")

View File

@ -6,17 +6,17 @@
twoscreen() { # If multi-monitor is selected and there are two screens.
mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?")
mirror=$(printf 'no\nyes' | dmenu -i -p "Mirror displays?")
# Mirror displays using native resolution of external display and a scaled
# version for the internal display
if [ "$mirror" = "yes" ]; then
external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
internal=$(echo "$screens" | grep -v "$external")
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
tail -n 1 | awk '{print $1}')
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
tail -n 1 | awk '{print $1}')
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" \
| tail -n 1 | awk '{print $1}')
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" \
| tail -n 1 | awk '{print $1}')
res_ext_x=$(echo "$res_external" | sed 's/x.*//')
res_ext_y=$(echo "$res_external" | sed 's/.*x//')
@ -33,34 +33,38 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
secondary=$(echo "$screens" | grep -v "$primary")
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
direction=$(printf 'left\nright' | dmenu -i -p "What side of $primary should $secondary be on?")
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
fi
}
}
morescreen() { # If multi-monitor is selected and there are more than two screens.
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
direction=$(printf 'left\nright' | dmenu -i -p "What side of $primary should $secondary be on?")
tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
}
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf 'left\nright' | grep -v "$direction")"-of "$primary" --auto
}
multimon() { # Multi-monitor handler.
case "$(echo "$screens" | wc -l)" in
2) twoscreen ;;
*) morescreen ;;
esac ;}
esac
}
onescreen() { # If only one output available or chosen.
xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -)
}
}
postrun() { # Stuff to run to clean up.
setbg # Fix background if screen size/arangement has changed.
remaps # Re-remap keys if keyboard added (for laptop bases)
{ killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen
}
{
killall dunst
setsid -f dunst
} > /dev/null 2>&1 # Restart dunst to ensure proper location on screen
}
# Get all possible displays
allposs=$(xrandr -q | grep "connected")
@ -69,15 +73,23 @@ allposs=$(xrandr -q | grep "connected")
screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
# If there's only one screen
[ "$(echo "$screens" | wc -l)" -lt 2 ] &&
{ onescreen "$screens"; postrun; notify-send "💻 Only one screen detected." "Using it in its optimal settings..."; exit ;}
[ "$(echo "$screens" | wc -l)" -lt 2 ] \
&& {
onescreen "$screens"
postrun
notify-send "💻 Only one screen detected." "Using it in its optimal settings..."
exit
}
# Get user choice including multi-monitor and manual selection:
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
case "$chosen" in
"manual selection") arandr ; exit ;;
chosen=$(printf '%s\nmulti-monitor\nmanual selection' "$screens" | dmenu -i -p "Select display arangement:") \
&& case "$chosen" in
"manual selection")
arandr
exit
;;
"multi-monitor") multimon ;;
*) onescreen "$chosen" ;;
esac
esac
postrun

View File

@ -4,18 +4,21 @@
# 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-dl\\nqueue yt-dl 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-dl\nqueue yt-dl audio' | dmenu -i -p "Open it with?")" in
"copy url") echo "$feed" | xclip -selection clipboard ;;
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-dl") qndl "$feed" >/dev/null 2>&1 ;;
"queue yt-dl audio") qndl "$feed" 'youtube-dl --add-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 ;;
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 ;;
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 ;;
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-dl") qndl "$feed" > /dev/null 2>&1 ;;
"queue yt-dl audio") qndl "$feed" 'youtube-dl --add-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 ;;
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 ;;
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

View File

@ -5,33 +5,38 @@
# 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() { \
getmount() {
[ -z "$chosen" ] && exit 1
# shellcheck disable=SC2086
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
mp="$(find $1 2> /dev/null | dmenu -i -p "Type in mount point.")" || exit 1
[ "$mp" = "" ] && exit 1
if [ ! -d "$mp" ]; then
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
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() { \
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
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";;
"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() { \
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"
@ -39,17 +44,17 @@ mountandroid() { \
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
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)
anddrives=$(simple-mtpfs -l 2> /dev/null)
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
if [ -z "$usbdrives" ]; then

View File

@ -13,7 +13,8 @@ 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
notify-send "Netshare $share already mounted"
exit 1
}
sharemount

View File

@ -9,10 +9,10 @@
#
# If there is already a running instance, user will be prompted to end it.
updateicon() { \
updateicon() {
echo "$1" > /tmp/recordingicon
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
}
}
killrecording() {
recpid="$(cat /tmp/recordingpid)"
@ -25,9 +25,9 @@ killrecording() {
sleep 3
kill -9 "$recpid"
exit
}
}
screencast() { \
screencast() {
ffmpeg -y \
-f x11grab \
-framerate 60 \
@ -39,9 +39,10 @@ screencast() { \
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
echo $! > /tmp/recordingpid
updateicon "⏺️🎙️"
}
}
video() { ffmpeg \
video() {
ffmpeg \
-f x11grab \
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
-i "$DISPLAY" \
@ -49,55 +50,55 @@ video() { ffmpeg \
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
echo $! > /tmp/recordingpid
updateicon "⏺️"
}
}
webcamhidef() { ffmpeg \
webcamhidef() {
ffmpeg \
-f v4l2 \
-i /dev/video0 \
-video_size 1920x1080 \
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
echo $! > /tmp/recordingpid
updateicon "🎥"
}
}
webcam() { ffmpeg \
webcam() {
ffmpeg \
-f v4l2 \
-i /dev/video0 \
-video_size 640x480 \
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
echo $! > /tmp/recordingpid
updateicon "🎥"
}
}
audio() { \
audio() {
ffmpeg \
-f alsa -i default \
-c:a flac \
"$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" &
echo $! > /tmp/recordingpid
updateicon "🎙️"
}
}
askrecording() { \
choice=$(printf "screencast\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:")
askrecording() {
choice=$(printf 'screencast\nvideo\nvideo selected\naudio\nwebcam\nwebcam (hi-def)' | dmenu -i -p "Select recording style:")
case "$choice" in
screencast) screencast;;
audio) audio;;
video) video;;
*selected) videoselected;;
webcam) webcam;;
"webcam (hi-def)") webcamhidef;;
screencast) screencast ;;
audio) audio ;;
video) video ;;
*selected) videoselected ;;
webcam) webcam ;;
"webcam (hi-def)") webcamhidef ;;
esac
}
}
asktoend() { \
response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
[ "$response" = "Yes" ] && killrecording
}
asktoend() {
response=$(printf 'No\nYes' | dmenu -i -p "Recording still active. End recording?") \
&& [ "$response" = "Yes" ] && killrecording
}
videoselected()
{
videoselected() {
slop -f "%x %y %w %h" > /tmp/slop
read -r X Y W H < /tmp/slop
rm /tmp/slop
@ -114,10 +115,10 @@ videoselected()
}
case "$1" in
screencast) screencast;;
audio) audio;;
video) video;;
*selected) videoselected;;
kill) killrecording;;
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;;
screencast) screencast ;;
audio) audio ;;
video) video ;;
*selected) videoselected ;;
kill) killrecording ;;
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording ;;
esac

View File

@ -10,21 +10,21 @@ unmountusb() {
chosen="$(echo "$chosen" | awk '{print $1}')"
[ -z "$chosen" ] && exit
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
}
}
unmountandroid() { \
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
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" | awk '$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
@ -33,8 +33,7 @@ if ! grep simple-mtpfs /etc/mtab; then
echo "Unmountable USB drive detected."
unmountusb
else
if [ -z "$drives" ]
then
if [ -z "$drives" ]; then
echo "Unmountable Android device detected."
unmountandroid
else

View File

@ -8,25 +8,25 @@
while getopts "hc" o; do case "${o}" in
c) extracthere="True" ;;
*) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit 1 ;;
esac done
*) printf 'Options:\n -c: Extract archive into current directory rather than a new one.\n' && exit 1 ;;
esac; done
if [ -z "$extracthere" ]; then
archive="$(readlink -f "$*")" &&
directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" &&
mkdir -p "$directory" &&
cd "$directory" || exit 1
archive="$(readlink -f "$*")" \
&& directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" \
&& mkdir -p "$directory" \
&& cd "$directory" || exit 1
else
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)" 2>/dev/null)"
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)" 2> /dev/null)"
fi
[ -z "$archive" ] && printf "Give archive to extract as argument.\\n" && exit 1
[ -z "$archive" ] && printf 'Give archive to extract as argument.\n' && exit 1
if [ -f "$archive" ] ; then
if [ -f "$archive" ]; then
case "$archive" in
*.tar.bz2|*.tbz2) tar xvjf "$archive" ;;
*.tar.bz2 | *.tbz2) tar xvjf "$archive" ;;
*.tar.xz) tar -xf "$archive" ;;
*.tar.gz|*.tgz) tar xvzf "$archive" ;;
*.tar.gz | *.tgz) tar xvzf "$archive" ;;
*.tar.zst) tar -I zstd -xf "$archive" ;;
*.lzma) unlzma "$archive" ;;
*.bz2) bunzip2 "$archive" ;;
@ -41,5 +41,5 @@ if [ -f "$archive" ] ; then
*) printf "extract: '%s' - unknown archive method\\n" "$archive" ;;
esac
else
printf "File \"%s\" not found.\\n" "$archive"
printf 'File "%s" not found.\n' "$archive"
fi

View File

@ -3,12 +3,12 @@
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 - | grep -io "doi:.*" -m 1) ||
exit 1
doi=$(pdfinfo "$1" | grep -io "doi:.*") \
|| doi=$(pdftotext "$1" - 2> /dev/null | grep -io "doi:.*" -m 1) \
|| exit 1
else
doi="$1"
fi
# Check crossref.org for the bib citation.
curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n"
curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w '\n'

View File

@ -1,5 +1,5 @@
#!/bin/sh
cat "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys/"$1" 2>/dev/null && exit
cat "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys/"$1" 2> /dev/null && exit
echo "Run command with one of the following arguments for info about that program:"
ls "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys

View File

@ -5,7 +5,7 @@
# it informs the user that they need that command to continue. This is used in
# various other scripts for clarity's sake.
for x in "$@";do
pacman -Qq "$x" >/dev/null 2>&1 ||
{ notify-send "📦 $x" "must be installed for this function." && exit 1 ;}
for x in "$@"; do
pacman -Qq "$x" > /dev/null 2>&1 \
|| { notify-send "📦 $x" "must be installed for this function." && exit 1; }
done

View File

@ -7,17 +7,25 @@
# otherwise it opens link in browser.
# If no url given. Opens browser. For using script as $BROWSER.
[ -z "$1" ] && { "$BROWSER"; exit; }
[ -z "$1" ] && {
"$BROWSER"
exit
}
case "$1" in
*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*)
setsid -f mpv -quiet "$1" >/dev/null 2>&1 ;;
*png|*jpg|*jpe|*jpeg|*gif)
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
*pdf|*cbz|*cbr)
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
*mp3|*flac|*opus|*mp3?source*)
qndl "$1" 'curl -LO' >/dev/null 2>&1 ;;
*mkv | *webm | *mp4 | *youtube.com/watch* | *youtube.com/playlist* | *youtu.be* | *hooktube.com* | *bitchute.com* | *videos.lukesmith.xyz*)
setsid -f mpv -quiet "$1" > /dev/null 2>&1
;;
*png | *jpg | *jpe | *jpeg | *gif)
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" > /dev/null 2>&1 &
;;
*pdf | *cbz | *cbr)
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" > /dev/null 2>&1 &
;;
*mp3 | *flac | *opus | *mp3?source*)
qndl "$1" 'curl -LO' > /dev/null 2>&1
;;
*)
[ -f "$1" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$1" >/dev/null 2>&1 || setsid -f "$BROWSER" "$1" >/dev/null 2>&1
[ -f "$1" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$1" > /dev/null 2>&1 || setsid -f "$BROWSER" "$1" > /dev/null 2>&1
;;
esac

View File

@ -4,7 +4,7 @@
# choose the kind of screenshot to take, including copying the image or even
# highlighting an area to copy. scrotcucks on suicidewatch right now.
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in
case "$(printf 'a selected area\ncurrent window\nfull screen\na selected area (copy)\ncurrent window (copy)\nfull screen (copy)' | dmenu -l 6 -i -p "Screenshot which area?")" in
"a selected area") maim -s pic-selected-"$(date '+%y%m%d-%H%M-%S').png" ;;
"current window") maim -i "$(xdotool getactivewindow)" pic-window-"$(date '+%y%m%d-%H%M-%S').png" ;;
"full screen") maim pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;;

View File

@ -7,7 +7,7 @@
basename="$(echo "${*}" | sed 's/\.[^\/.]*$//')"
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 ;;
*.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

View File

@ -6,5 +6,5 @@
# (with other things) by default and is used in some other places.
for i in $(ls /tmp/mpvSockets/*); do
echo '{ "command": ["set_property", "pause", true] }' | socat - "$i";
echo '{ "command": ["set_property", "pause", true] }' | socat - "$i"
done

View File

@ -4,4 +4,4 @@
[ "$(pgrep -x "$(basename "$0")" | wc -l)" -gt 2 ] && exit
echo "${XDG_DATA_HOME:-$HOME/.local/share}"/newsboat/queue | entr -p queueandnotify 2>/dev/null
echo "${XDG_DATA_HOME:-$HOME/.local/share}"/newsboat/queue | entr -p queueandnotify 2> /dev/null

View File

@ -5,4 +5,4 @@
# 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
[ "$(printf 'No\nYes' | dmenu -i -p "$1" -nb darkred -sb red -sf white -nf gray)" = "Yes" ] && $2

View File

@ -6,7 +6,8 @@ xset r rate 300 50
# Map the caps lock key to super...
setxkbmap -option caps:super
# But when it is pressed only once, treat it as escape.
killall xcape 2>/dev/null ; xcape -e 'Super_L=Escape'
killall xcape 2> /dev/null
xcape -e 'Super_L=Escape'
# Map the menu button to right super as well.
xmodmap -e 'keycode 135 = Super_R'
# Turn off the caps lock if on since there is no longer a key for it.

View File

@ -1,9 +1,9 @@
#!/bin/sh
! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null &&
notify-send "That doesn't look like a full URL." && exit
! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" > /dev/null \
&& notify-send "That doesn't look like a full URL." && exit
RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls"
if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then
if awk '{print $1}' "$RSSFILE" | grep "^$1$" > /dev/null; then
notify-send "You already have this RSS feed."
else
echo "$1" >> "$RSSFILE" && notify-send "RSS feed added."

View File

@ -9,16 +9,19 @@
# Location of link to wallpaper link.
bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/bg"
trueloc="$(readlink -f "$1")" &&
case "$(file --mime-type -b "$trueloc")" in
image/* ) ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;;
inode/directory ) ln -sf "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen." ;;
*) notify-send "Error" "Not a valid image." ; exit 1;;
esac
trueloc="$(readlink -f "$1")" \
&& case "$(file --mime-type -b "$trueloc")" in
image/*) ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;;
inode/directory) ln -sf "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen." ;;
*)
notify-send "Error" "Not a valid image."
exit 1
;;
esac
# If pywal is installed, use it.
command -v wal >/dev/null 2>&1 &&
wal -i "$trueloc" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1 &&
pidof dwm >/dev/null && xdotool key super+F12
command -v wal > /dev/null 2>&1 \
&& wal -i "$trueloc" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" > /dev/null 2>&1 \
&& pidof dwm > /dev/null && xdotool key super+F12
xwallpaper --zoom "$bgloc"

View File

@ -12,14 +12,14 @@ fish_shortcuts="/dev/null"
vifm_shortcuts="/dev/null"
# Remove, prepare files
rm -f "$ranger_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" 2>/dev/null
printf "# vim: filetype=sh\\n" > "$fish_shortcuts"
printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts"
rm -f "$ranger_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" 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*#.*$\",\"\");
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\" ;
@ -28,8 +28,8 @@ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
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\" }"
# Format the `files` file in the correct syntax and sent it to both configs.
eval "echo \"$(cat "$bmfiles")\"" | \
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
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\" ;

View File

@ -19,14 +19,18 @@ while getopts "hvrpi:c:a:o:d:f:t:e:x:" o; do case "${o}" in
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]"
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 ;;
exit
;;
v) verbose=True ;;
*) echo "$(basename "$0") usage:
-i input timecode list (required)
@ -40,32 +44,35 @@ while getopts "hvrpi:c:a:o:d:f:t:e:x:" o; do case "${o}" in
-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
-v be verbose" && exit 1 ;;
esac done
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:
{ 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
}
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 ;;
*)
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))"
endtime="$((totseconds - seconds))"
fi
prepdir="${prepdir:-$cache/$file}"
@ -76,8 +83,7 @@ prepfile="$prepdir/$file.prep"
mkdir -p "$prepdir"
{
while read -r x;
do
while read -r x; do
# Get the time from the first column.
time="${x%% *}"
seconds="$(date '+%s' -d "$time")"
@ -92,11 +98,11 @@ do
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"
{ [ ! -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}" -pointsize "${ppt:-150}" -gravity center label:"$content" "$prepdir/$base"
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ]; } \
&& convert -size "${res:-1920x1080}" -background "${bgc:-black}" -fill "${fgc:-white}" -pointsize "${ppt:-150}" -gravity center label:"$content" "$prepdir/$base"
fi
# If the first line, do not write yet.
@ -107,9 +113,9 @@ duration $duration"
prevbase="$base"
prevtime="$time"
prevseconds="$(date '+%s' -d "$prevtime")"
done < "$file"
# Do last file which must be given twice as follows
echo "file '$base'
done < "$file"
# Do last file which must be given twice as follows
echo "file '$base'
duration ${endtime:-5}
file '$base'"
} > "$prepfile"

View File

@ -32,5 +32,6 @@ for battery in /sys/class/power_supply/BAT?*; do
# Will make a warn variable if discharging and low
[ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗"
# Prints the info
printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
printf "%s%s%d%%" "$status" "$warn" "$capacity"
unset warn
done && exit 0

View File

@ -11,7 +11,7 @@ cache=/tmp/cpubarscache
case $BLOCK_BUTTON in
2) setsid -f "$TERMINAL" -e htop ;;
3) notify-send "🪨 CPU load module" "Each bar represents
one CPU core";;
one CPU core" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
@ -30,15 +30,16 @@ echo "$stats" | while read -r row; do
printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
id="$id" total="$total" idle="$idle")" in
"0") printf "▁";;
"1") printf "▂";;
"2") printf "▃";;
"3") printf "▄";;
"4") printf "▅";;
"5") printf "▆";;
"6") printf "▇";;
"7") printf "█";;
"8") printf "█";;
"0") printf "▁" ;;
"1") printf "▂" ;;
"2") printf "▃" ;;
"3") printf "▄" ;;
"4") printf "▅" ;;
"5") printf "▆" ;;
"6") printf "▇" ;;
"7") printf "█" ;;
"8") printf "█" ;;
esac
done; printf "\\n"
done
printf '\n'
echo "$stats" > "$cache"

View File

@ -15,9 +15,9 @@ case $BLOCK_BUTTON in
esac
case "$location" in
"/home"* ) icon="🏠" ;;
"/mnt"* ) icon="💾" ;;
*) icon="🖥";;
"/home"*) icon="🏠" ;;
"/mnt"*) icon="💾" ;;
*) icon="🖥" ;;
esac
printf "%s: %s\n" "$icon" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')"

View File

@ -7,14 +7,16 @@
# You could set up a shell alias to view the full file in a pager in the
# terminal if desired. This function will only be run once a day when needed.
weatherreport="${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport"
getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;}
getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1; }
# Some very particular and terse stream manipulation. We get the maximum
# precipitation chance and the daily high and low from the downloaded file and
# display them with coresponding emojis.
showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" |
grep -wo "[0-9]*%" | sort -rn | sed "s/^/☔/g;1q" | tr -d '\n')"
sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " 🥶" $1 "°","🌞" $2 "°"}' ;}
showweather() {
printf "%s" "$(sed '16q;d' "$weatherreport" \
| grep -wo "[0-9]*%" | sort -rn | sed "s/^/☔/g;1q" | tr -d '\n')"
sed '13q;d' "$weatherreport" | grep -o 'm\([-+]\)*[0-9]\+' | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " 🥶" $1 "°","🌞" $2 "°"}'
}
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;;
@ -29,7 +31,7 @@ esac
# 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.
[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
getforecast
[ "$(stat -c %y "$weatherreport" 2> /dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] \
|| getforecast
showweather

View File

@ -3,10 +3,10 @@
# The clickable help menu. Middle click to restart wm.
# If dwm is running, use dwm's readme and restart.
pidof dwm >/dev/null &&
READMEFILE=/usr/local/share/dwm/larbs.mom
restartwm() { pkill -HUP dwm ;} ||
restartwm() { i3 restart ;}
pidof dwm > /dev/null \
&& READMEFILE=/usr/local/share/dwm/larbs.mom
restartwm() { pkill -HUP dwm; } \
|| restartwm() { i3 restart; }
case $BLOCK_BUTTON in
1) groff -mom "${READMEFILE:-${XDG_DATA_HOME:-$HOME/.local/share}/larbs/readme.mom}" -Tpdf | zathura - ;;
@ -14,4 +14,5 @@ case $BLOCK_BUTTON in
3) notify-send "❓ Help module" "\- Left click to open LARBS guide.
- Middle click to refresh window manager." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac; echo "❓"
esac
echo "❓"

View File

@ -5,7 +5,10 @@
# Show 🔒 if a vpn connection is active
case $BLOCK_BUTTON in
1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;;
1)
"$TERMINAL" -e nmtui
pkill -RTMIN+4 dwmblocks
;;
3) notify-send "🌐 Internet module" "\- Click to connect
📡: no wifi connection
📶: wifi connection with quality
@ -16,9 +19,9 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
case "$(cat /sys/class/net/w*/operstate 2> /dev/null)" in
down) wifiicon="📡 " ;;
up) wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;;
esac
printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2>/dev/null)"
printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2> /dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2> /dev/null)"

View File

@ -6,5 +6,5 @@
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
ifinstalled "geoip" || exit
addr="$(curl ifconfig.me 2>/dev/null)" || exit
addr="$(curl ifconfig.me 2> /dev/null)" || exit
grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//"

View File

@ -4,12 +4,14 @@
kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1
case $BLOCK_BUTTON in
1) kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)"
1)
kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)"
kb="$(echo "$kb_choice" | awk '{print $3}')"
setxkbmap "$kb"
pkill -RTMIN+30 "${STATUSBAR:-dwmblocks}";;
pkill -RTMIN+30 "${STATUSBAR:-dwmblocks}"
;;
3) notify-send "⌨ Keyboard/language module" "$(printf "%s" "\- Current layout: $(setxkbmap -query | grep -oP 'layout:\s*\K\w+')")
- Left click to change keyboard.";;
- Left click to change keyboard." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

View File

@ -5,7 +5,7 @@
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e neomutt ;;
2) setsid -f mw sync >/dev/null ;;
2) setsid -f mw sync > /dev/null ;;
3) notify-send "📬 Mail module" "\- Shows unread mail
- Shows 🔃 if syncing mail
- Left click opens neomutt
@ -13,8 +13,8 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)"
unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2> /dev/null)"
pidof mbsync >/dev/null 2>&1 && icon="🔃"
pidof mbsync > /dev/null 2>&1 && icon="🔃"
[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "📬$unread$icon"

View File

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

View File

@ -3,6 +3,6 @@
# This loop will update the mpd statusbar module whenever a command changes the
# music player's status. mpd must be running on X's start for this to work.
while : ; do
mpc idle >/dev/null && kill -45 "$(pidof "${STATUSBAR:-dwmblocks}")" || break
while :; do
mpc idle > /dev/null && kill -45 "$(pidof "${STATUSBAR:-dwmblocks}")" || break
done

View File

@ -1,19 +1,28 @@
#!/bin/sh
filter() { mpc | sed "/^volume:/d;s/\\&/&amp;/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d" | paste -sd ' ' -;}
filter() { mpc | sed '/^volume:/d;s/\&/&amp;/g;s/\[paused\].*/⏸/g;/\[playing\].*/d' | paste -sd ' ' -; }
pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
pidof -x sb-mpdup > /dev/null 2>&1 || sb-mpdup > /dev/null 2>&1 &
case $BLOCK_BUTTON in
1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause
1)
mpc status | filter
setsid -f "$TERMINAL" -e ncmpcpp
;; # right click, pause/unpause
2) mpc toggle | filter ;; # right click, pause/unpause
3) mpc status | filter ; notify-send "🎵 Music module" "\- Shows mpd song playing.
3)
mpc status | filter
notify-send "🎵 Music module" "\- Shows mpd song playing.
- ⏸ when paused.
- Left click opens ncmpcpp.
- Middle click pauses.
- Scroll changes track.";; # right click, pause/unpause
- Scroll changes track."
;; # right click, pause/unpause
4) mpc prev | filter ;; # scroll up, previous
5) mpc next | filter ;; # scroll down, next
6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;;
6)
mpc status | filter
"$TERMINAL" -e "$EDITOR" "$0"
;;
*) mpc status | filter ;;
esac

View File

@ -15,15 +15,15 @@ update() {
sum=0
for arg; do
read -r i < "$arg"
sum=$(( sum + i ))
sum=$((sum + i))
done
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
[ -f "$cache" ] && read -r old < "$cache" || old=0
printf %d\\n "$sum" > "$cache"
printf %d\\n $(( sum - old ))
printf %d\\n $((sum - old))
}
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
printf "🔻%4sB 🔺%4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx)
printf '🔻%4sB 🔺%4sB\n' $(numfmt --to=iec $rx) $(numfmt --to=iec $tx)

View File

@ -5,7 +5,7 @@
case $BLOCK_BUTTON in
1) setsid "$TERMINAL" -e newsboat ;;
2) setsid -f newsup >/dev/null exit ;;
2) setsid -f newsup exit > /dev/null ;;
3) notify-send "📰 News module" "\- Shows unread news items
- Shows 🔃 if updating with \`newsup\`
- Left click opens newsboat
@ -14,4 +14,4 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "📰" $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2>/dev/null)"
cat /tmp/newsupdate 2> /dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "📰" $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2> /dev/null)"

View File

@ -1,9 +1,9 @@
#!/bin/sh
printf "Beginning upgrade.\\n"
printf 'Beginning upgrade.\n'
yay -Syu
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
printf '\nUpgrade complete.\nPress <Enter> to exit window.\n\n'
read -r _

View File

@ -11,27 +11,31 @@ dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
pricefile="$dir/$1"
chartfile="$dir/$1-chart"
updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 &&
curl -s "rate.sx/1$1" > "$pricefile" &&
curl -s "rate.sx/$1$interval" > "$chartfile" ;}
updateprice() { ping -q -c 1 example.org > /dev/null 2>&1 \
&& curl -s "rate.sx/1$1" > "$pricefile" \
&& curl -s "rate.sx/$1$interval" > "$chartfile"; }
[ -d "$dir" ] || mkdir -p "$dir"
[ "$(stat -c %x "$pricefile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
updateprice "$1"
[ "$(stat -c %x "$pricefile" 2> /dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] \
&& updateprice "$1"
case $BLOCK_BUTTON in
1) setsid "$TERMINAL" -e less -Srf "$chartfile" ;;
2) notify-send -u low "$3 Updating..." "Updating $2 price..."
2)
notify-send -u low "$3 Updating..." "Updating $2 price..."
updateprice "$1" && notify-send "$3 Update complete." "$2 price is now
\$$(cat "$pricefile")" ;;
3) uptime="$(date -d "$(stat -c %x "$pricefile")" '+%D at %T' | sed "s|$(date '+%D')|Today|")"
\$$(cat "$pricefile")"
;;
3)
uptime="$(date -d "$(stat -c %x "$pricefile")" '+%D at %T' | sed "s|$(date '+%D')|Today|")"
notify-send "$3 $2 module" "\- <b>Exact price: \$$(cat "$pricefile")</b>
- Left click for chart of changes.
- Middle click to update.
- Shows 🔃 if updating prices.
- <b>Last updated:
$uptime</b>" ;;
$uptime</b>"
;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

View File

@ -16,5 +16,5 @@ case $BLOCK_BUTTON in
2) $EDITOR "$0" ;; # Middle click
esac
[ "$num" != "0(0)" ] &&
echo "🤖$num"
[ "$num" != "0(0)" ] \
&& echo "🤖$num"

View File

@ -1,14 +1,14 @@
#!/bin/sh
transmission-remote -l | grep % |
sed " # The letters are for sorting and will not appear.
transmission-remote -l | grep % \
| sed " # The letters are for sorting and will not appear.
s/.*Stopped.*/A 🛑/;
s/.*Seeding.*/Z 🌱/;
s/.*100%.*/N ✅/;
s/.*Idle.*/B 🕰️/;
s/.*Uploading.*/L ⬆️/;
s/.*%.*/M ⬇️/" |
sort -h | uniq -c | awk '{print $3 $1}' | paste -sd ' ' -
s/.*%.*/M ⬇️/" \
| sort -h | uniq -c | awk '{print $3 $1}' | paste -sd ' ' -
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e tremc ;;

View File

@ -5,7 +5,10 @@
# For non-systemd init systems.
case "$(readlink -f /sbin/init)" in
*runit*) hib="sudo -A zzz" ;;
*openrc*) reb="sudo -A openrc-shutdown -r"; shut="sudo -A openrc-shutdown -p" ;;
*openrc*)
reb="sudo -A openrc-shutdown -r"
shut="sudo -A openrc-shutdown -p"
;;
esac
cmds="\
@ -18,4 +21,4 @@ cmds="\
choice="$(echo "$cmds" | cut -d' ' -f 1 | dmenu)" || exit 1
`echo "$cmds" | grep "^$choice " | cut -d ' ' -f2-`
$(echo "$cmds" | grep "^$choice " | cut -d ' ' -f2-)

View File

@ -11,7 +11,7 @@ Options:
-d: year of publication
-g: genre
-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
a) artist="${OPTARG}" ;;
@ -23,8 +23,8 @@ while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
g) genre="${OPTARG}" ;;
c) comment="${OPTARG}" ;;
f) file="${OPTARG}" ;;
*) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
esac done
*) printf 'Invalid option: -%s\n' "$OPTARG" && err ;;
esac; done
shift $((OPTIND - 1))

View File

@ -2,11 +2,10 @@
# If transmission-daemon is running, will ask to kill, else will ask to start.
if pidof transmission-daemon >/dev/null ;
then
[ "$(printf "No\\nYes" | dmenu -i -p "Turn off transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon disabled."
if pidof transmission-daemon > /dev/null; then
[ "$(printf 'No\nYes' | dmenu -i -p "Turn off transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon disabled."
else
ifinstalled transmission-cli || exit
[ "$(printf "No\\nYes" | dmenu -i -p "Turn on transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "tranmission-daemon enabled."
[ "$(printf 'No\nYes' | dmenu -i -p "Turn on transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "tranmission-daemon enabled."
fi
sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"

View File

@ -11,6 +11,5 @@ case "$1" in
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" ;;
*) printf 'Give .tex file as argument.\n' ;;
esac

View File

@ -2,6 +2,7 @@
ifinstalled tremc-git transmission-cli || exit
! pidof transmission-daemon >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..."
! pidof transmission-daemon > /dev/null && transmission-daemon && notify-send "Starting torrent daemon..."
$TERMINAL -e tremc; pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
$TERMINAL -e tremc
pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"

View File

@ -4,6 +4,6 @@
# transmission-daemon sometimes fails to take remote requests in its first moments, hence the sleep.
pidof transmission-daemon >/dev/null || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}")
pidof transmission-daemon > /dev/null || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}")
transmission-remote -a "$@" && notify-send "🔽 Torrent added."