big overhaul
This commit is contained in:
43
.local/bin/booksplit
Executable file
43
.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"
|
||||
59
.local/bin/compiler
Executable file
59
.local/bin/compiler
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/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() { \
|
||||
textarget="$(getcomproot "$file" || echo "$file")"
|
||||
echo "$textarget"
|
||||
command="pdflatex"
|
||||
( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex"
|
||||
$command --output-directory="${textarget%/*}" "${textarget%.*}"
|
||||
grep -qi addbibresource "$textarget" &&
|
||||
biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
|
||||
$command --output-directory="${textarget%/*}" "${textarget%.*}" &&
|
||||
$command --output-directory="${textarget%/*}" "${textarget%.*}"
|
||||
}
|
||||
|
||||
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
|
||||
83
.local/bin/displayselect
Executable file
83
.local/bin/displayselect
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A UI for detecting and selecting all displays. Probes xrandr for connected
|
||||
# displays and lets user select one to use. User may also select "manual
|
||||
# selection" which opens arandr.
|
||||
|
||||
twoscreen() { # If multi-monitor is selected and there are two screens.
|
||||
|
||||
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_ext_x=$(echo "$res_external" | sed 's/x.*//')
|
||||
res_ext_y=$(echo "$res_external" | sed 's/.*x//')
|
||||
res_int_x=$(echo "$res_internal" | sed 's/x.*//')
|
||||
res_int_y=$(echo "$res_internal" | sed 's/.*x//')
|
||||
|
||||
scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l)
|
||||
scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l)
|
||||
|
||||
xrandr --output "$external" --auto --scale 1.0x1.0 \
|
||||
--output "$internal" --auto --same-as "$external" \
|
||||
--scale "$scale_x"x"$scale_y"
|
||||
else
|
||||
|
||||
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?")
|
||||
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?")
|
||||
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
|
||||
}
|
||||
|
||||
multimon() { # Multi-monitor handler.
|
||||
case "$(echo "$screens" | wc -l)" in
|
||||
2) twoscreen ;;
|
||||
*) morescreen ;;
|
||||
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
|
||||
}
|
||||
|
||||
# Get all possible displays
|
||||
allposs=$(xrandr -q | grep "connected")
|
||||
|
||||
# Get all connected screens.
|
||||
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 ;}
|
||||
|
||||
# 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 ;;
|
||||
"multi-monitor") multimon ;;
|
||||
*) onescreen "$chosen" ;;
|
||||
esac
|
||||
|
||||
postrun
|
||||
21
.local/bin/dmenuhandler
Executable file
21
.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" | 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-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 ;;
|
||||
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
|
||||
67
.local/bin/dmenumount
Executable file
67
.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
.local/bin/dmenumountcifs
Executable file
19
.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
|
||||
6
.local/bin/dmenupass
Executable file
6
.local/bin/dmenupass
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script is the SUDO_ASKPASS variable, meaning that it will be used as a
|
||||
# password prompt if needed.
|
||||
|
||||
dmenu -fn Monospace-18 -P -p "$1" <&- && echo
|
||||
123
.local/bin/dmenurecord
Executable file
123
.local/bin/dmenurecord
Executable file
@@ -0,0 +1,123 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Usage:
|
||||
# `$0`: Ask for recording type via dmenu
|
||||
# `$0 screencast`: Record both audio and screen
|
||||
# `$0 video`: Record only screen
|
||||
# `$0 audio`: Record only audio
|
||||
# `$0 kill`: Kill existing recording
|
||||
#
|
||||
# If there is already a running instance, user will be prompted to end it.
|
||||
|
||||
updateicon() { \
|
||||
echo "$1" > /tmp/recordingicon
|
||||
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
|
||||
}
|
||||
|
||||
killrecording() {
|
||||
recpid="$(cat /tmp/recordingpid)"
|
||||
# kill with SIGTERM, allowing finishing touches.
|
||||
kill -15 "$recpid"
|
||||
rm -f /tmp/recordingpid
|
||||
updateicon ""
|
||||
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
|
||||
# even after SIGTERM, ffmpeg may still run, so SIGKILL it.
|
||||
sleep 3
|
||||
kill -9 "$recpid"
|
||||
exit
|
||||
}
|
||||
|
||||
screencast() { \
|
||||
ffmpeg -y \
|
||||
-f x11grab \
|
||||
-framerate 60 \
|
||||
-s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \
|
||||
-i "$DISPLAY" \
|
||||
-f alsa -i default \
|
||||
-r 30 \
|
||||
-c:v h264 -crf 0 -preset ultrafast -c:a aac \
|
||||
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "⏺️🎙️"
|
||||
}
|
||||
|
||||
video() { ffmpeg \
|
||||
-f x11grab \
|
||||
-s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \
|
||||
-i "$DISPLAY" \
|
||||
-c:v libx264 -qp 0 -r 30 \
|
||||
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "⏺️"
|
||||
}
|
||||
|
||||
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 \
|
||||
-f v4l2 \
|
||||
-i /dev/video0 \
|
||||
-video_size 640x480 \
|
||||
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "🎥"
|
||||
}
|
||||
|
||||
|
||||
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:")
|
||||
case "$choice" in
|
||||
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
|
||||
}
|
||||
|
||||
videoselected()
|
||||
{
|
||||
slop -f "%x %y %w %h" > /tmp/slop
|
||||
read -r X Y W H < /tmp/slop
|
||||
rm /tmp/slop
|
||||
|
||||
ffmpeg \
|
||||
-f x11grab \
|
||||
-framerate 60 \
|
||||
-video_size "$W"x"$H" \
|
||||
-i :0.0+"$X,$Y" \
|
||||
-c:v libx264 -qp 0 -r 30 \
|
||||
"$HOME/box-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "⏺️"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
screencast) screencast;;
|
||||
audio) audio;;
|
||||
video) video;;
|
||||
*selected) videoselected;;
|
||||
kill) killrecording;;
|
||||
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;;
|
||||
esac
|
||||
44
.local/bin/dmenuumount
Executable file
44
.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
|
||||
18
.local/bin/dmenuunicode
Executable file
18
.local/bin/dmenuunicode
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# The famous "get a menu of emojis to copy" script.
|
||||
|
||||
# Get user selection via dmenu from emoji file.
|
||||
chosen=$(cut -d ';' -f1 ~/.local/share/larbs/chars/* | dmenu -i -l 30 | sed "s/ .*//")
|
||||
|
||||
# Exit if none chosen.
|
||||
[ -z "$chosen" ] && exit
|
||||
|
||||
# If you run this command with an argument, it will automatically insert the
|
||||
# character. Otherwise, show a message that the emoji has been copied.
|
||||
if [ -n "$1" ]; then
|
||||
xdotool type "$chosen"
|
||||
else
|
||||
printf "$chosen" | xclip -selection clipboard
|
||||
notify-send "'$chosen' copied to clipboard." &
|
||||
fi
|
||||
14
.local/bin/getbib
Executable file
14
.local/bin/getbib
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit
|
||||
|
||||
if [ -f "$1" ]; then
|
||||
# Try to get DOI from pdfinfo or pdftotext output.
|
||||
doi=$(pdfinfo "$1" | grep -io "doi:.*") ||
|
||||
doi=$(pdftotext "$1" 2>/dev/null - | grep -io "doi:.*" -m 1) ||
|
||||
exit 1
|
||||
else
|
||||
doi="$1"
|
||||
fi
|
||||
|
||||
# Check crossref.org for the bib citation.
|
||||
curl -s "https://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n"
|
||||
12
.local/bin/getcomproot
Executable file
12
.local/bin/getcomproot
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# A helper script for LaTeX/groff files used by `compiler` and `opout`.
|
||||
# The user can add the root file of a larger project as a comment as below:
|
||||
# % root = mainfile.tex
|
||||
# And the compiler script will run on that instead of the opened file.
|
||||
|
||||
texroot="$(grep -i "^.\+\s*root\s*=\s*\S\+" "$1")"
|
||||
texroot="${texroot##*=}"
|
||||
texroot="${texroot//[\"\' ]}"
|
||||
|
||||
[ -f "$texroot" ] && readlink -f "$texroot" || exit 1
|
||||
5
.local/bin/getkeys
Executable file
5
.local/bin/getkeys
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
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
|
||||
12
.local/bin/ifinstalled
Executable file
12
.local/bin/ifinstalled
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Some optional functions in LARBS require programs not installed by default. I
|
||||
# use this little script to check to see if a command exists and if it doesn't
|
||||
# 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
|
||||
if ! which "$x" >/dev/null 2>&1 && ! pacman -Qq "$x" >/dev/null 2>&1; then
|
||||
notify-send "📦 $x" "must be installed for this function." && exit 1 ;
|
||||
fi
|
||||
done
|
||||
3
.local/bin/ipadd
Executable file
3
.local/bin/ipadd
Executable file
@@ -0,0 +1,3 @@
|
||||
#! /bin/bash
|
||||
|
||||
ip a | grep metric | awk '{print $2}'
|
||||
24
.local/bin/lfub
Executable file
24
.local/bin/lfub
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This is a wrapper script for lb that allows it to create image previews with
|
||||
# ueberzug. This works in concert with the lf configuration file and the
|
||||
# lf-cleaner script.
|
||||
|
||||
set -e
|
||||
|
||||
cleanup() {
|
||||
exec 3>&-
|
||||
rm "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||
lf "$@"
|
||||
else
|
||||
[ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
|
||||
export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
|
||||
mkfifo "$FIFO_UEBERZUG"
|
||||
ueberzug layer -s <"$FIFO_UEBERZUG" -p json &
|
||||
exec 3>"$FIFO_UEBERZUG"
|
||||
trap cleanup HUP INT QUIT TERM PWR EXIT
|
||||
lf "$@" 3>&-
|
||||
fi
|
||||
26
.local/bin/linkhandler
Executable file
26
.local/bin/linkhandler
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/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="$(xclip -o)"
|
||||
else
|
||||
url="$1"
|
||||
fi
|
||||
|
||||
case "$url" in
|
||||
*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*)
|
||||
setsid -f mpv -quiet "$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
|
||||
18
.local/bin/maimpick
Executable file
18
.local/bin/maimpick
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This is bound to Shift+PrintScreen by default, requires maim. It lets you
|
||||
# choose the kind of screenshot to take, including copying the image or even
|
||||
# highlighting an area to copy. scrotcucks on suicidewatch right now.
|
||||
|
||||
# variables
|
||||
output="$(date '+%y%m%d-%H%M-%S').png"
|
||||
xclip_cmd="xclip -sel clip -t image/png"
|
||||
|
||||
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-"${output}" ;;
|
||||
"current window") maim -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;;
|
||||
"full screen") maim -q -d 0.2 pic-full-"${output}" ;;
|
||||
"a selected area (copy)") maim -s | ${xclip_cmd} ;;
|
||||
"current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;;
|
||||
"full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;;
|
||||
esac
|
||||
3
.local/bin/mountt
Executable file
3
.local/bin/mountt
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/env bash
|
||||
|
||||
sudo -A chown dorian:wheel $HOME/docs ;
|
||||
81
.local/bin/noisereduce
Executable file
81
.local/bin/noisereduce
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/sh
|
||||
|
||||
usage ()
|
||||
{
|
||||
printf "Usage : noisereduce <input video file> <output video file>\n"
|
||||
exit
|
||||
}
|
||||
|
||||
# Tests for requirements
|
||||
ifinstalled ffmpeg || { echo >&2 "We require 'ffmpeg' but it's not installed."; exit 1; }
|
||||
ifinstalled sox || { echo >&2 "We require 'ffmpeg' but it's not installed."; exit 1; }
|
||||
|
||||
if [ "$#" -ne 2 ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ ! -e "$1" ]
|
||||
then
|
||||
printf "File not found: %s\n" "$1"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -e "$2" ]
|
||||
then
|
||||
printf "File %s already exists, overwrite? [y/N]\n: " "$2"
|
||||
read -r yn
|
||||
case $yn in
|
||||
[Yy]* ) ;;
|
||||
* ) exit;;
|
||||
esac
|
||||
fi
|
||||
|
||||
inBasename=$(basename "$1")
|
||||
inExt="${inBasename##*.}"
|
||||
|
||||
isVideoStr=$(ffprobe -v warning -show_streams "$1" | grep codec_type=video)
|
||||
if [ -n "$isVideoStr" ]
|
||||
then
|
||||
isVideo=1
|
||||
printf "Detected %s as a video file\n" "$inBasename"
|
||||
else
|
||||
isVideo=0
|
||||
printf "Detected %s as an audio file\n" "$inBasename"
|
||||
fi
|
||||
|
||||
printf "Sample noise start time [00:00:00]: "
|
||||
read -r sampleStart
|
||||
if [ -z "$sampleStart" ] ; then sampleStart="00:00:00"; fi
|
||||
printf "Sample noise end time [00:00:00.900]: "
|
||||
read -r sampleEnd
|
||||
if [ -z "$sampleEnd" ] ; then sampleEnd="00:00:00.900"; fi
|
||||
printf "Noise reduction amount [0.21]: "
|
||||
read -r sensitivity
|
||||
if [ -z "$sensitivity" ] ; then sensitivity="0.21"; fi
|
||||
|
||||
|
||||
tmpVidFile="/tmp/noiseclean_tmpvid.$inExt"
|
||||
tmpAudFile="/tmp/noiseclean_tmpaud.wav"
|
||||
noiseAudFile="/tmp/noiseclean_noiseaud.wav"
|
||||
noiseProfFile="/tmp/noiseclean_noise.prof"
|
||||
tmpAudCleanFile="/tmp/noiseclean_tmpaud-clean.wav"
|
||||
|
||||
printf "Cleaning noise on %s...\n" "$1"
|
||||
|
||||
if [ $isVideo -eq "1" ]; then
|
||||
ffmpeg -v warning -y -i "$1" -qscale:v 0 -vcodec copy -an "$tmpVidFile"
|
||||
ffmpeg -v warning -y -i "$1" -qscale:a 0 "$tmpAudFile"
|
||||
else
|
||||
cp "$1" "$tmpAudFile"
|
||||
fi
|
||||
ffmpeg -v warning -y -i "$1" -vn -ss "$sampleStart" -t "$sampleEnd" "$noiseAudFile"
|
||||
sox "$noiseAudFile" -n noiseprof "$noiseProfFile"
|
||||
sox "$tmpAudFile" "$tmpAudCleanFile" noisered "$noiseProfFile" "$sensitivity"
|
||||
if [ $isVideo -eq "1" ]; then
|
||||
ffmpeg -v warning -y -i "$tmpAudCleanFile" -i "$tmpVidFile" -vcodec copy -qscale:v 0 -qscale:a 0 "$2"
|
||||
else
|
||||
cp "$tmpAudCleanFile" "$2"
|
||||
fi
|
||||
|
||||
printf "Done"
|
||||
13
.local/bin/opout
Executable file
13
.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|*.sil|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) target="$(getcomproot "$1" || echo "$1")" ; setsid -f xdg-open "${target%.*}".pdf >/dev/null 2>&1 ;;
|
||||
*.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;;
|
||||
*.sent) setsid -f sent "$1" >/dev/null 2>&1 ;;
|
||||
esac
|
||||
53
.local/bin/otp
Executable file
53
.local/bin/otp
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Get a one-time password, or add a OTP secret to your pass-otp store.
|
||||
|
||||
# The assumption of this script is that all otp passwords are stored with the
|
||||
# suffix `-otp`. This script automatically appends newly added otps as such.
|
||||
|
||||
# For OTP passwords to be generated properly, it is important for the local
|
||||
# computer to have its time properly synced. This can be done with the command
|
||||
# below which requires the package `ntp`.
|
||||
|
||||
ifinstalled pass pass-otp
|
||||
|
||||
dir="${PASSWORD_STORE_DIR}"
|
||||
|
||||
choice="$({ echo "🆕add" ; echo "🕙sync-time" ; ls ${dir}/*-otp.gpg ;} | sed "s/.*\///;s/-otp.gpg//" | dmenu -p "Pick a 2FA:")"
|
||||
|
||||
case $choice in
|
||||
🆕add )
|
||||
ifinstalled maim zbar xclip || exit 1
|
||||
|
||||
temp="$dir/temp.png"
|
||||
otp="otp-test-script"
|
||||
trap 'shred -fu $temp; pass rm $otp' HUP INT QUIT TERM PWR EXIT
|
||||
|
||||
notify-send "Scan the image." "Scan the OTP QR code."
|
||||
|
||||
maim -s "$temp" || exit 1
|
||||
info="$(zbarimg -q "$temp")"
|
||||
info="${info#QR-Code:}"
|
||||
issuer="$(echo "$info" | grep -o "issuer=[A-z0-9]\+")"
|
||||
name="${issuer#issuer=}"
|
||||
|
||||
if echo "$info" | pass otp insert "$otp"; then
|
||||
while true ; do
|
||||
export name="$(dmenu -p "Give this One Time Password a one-word name:")"
|
||||
echo "$name" | grep -q -- "^[A-z0-9-]\+$" && break
|
||||
done
|
||||
pass mv "$otp" "$name-otp"
|
||||
notify-send "Successfully added." "$name-otp has been created."
|
||||
else
|
||||
notify-send "No OTP data found." "Try to scan the image again more precisely."
|
||||
fi
|
||||
|
||||
;;
|
||||
🕙sync-time )
|
||||
ifinstalled ntp || exit 1
|
||||
notify-send -u low "🕙 Synchronizing Time..." "Synching time with remote NTP servers..."
|
||||
updatedata="$(sudo ntpdate pool.ntp.org)" &&
|
||||
notify-send -u low "🕙 Synchronizing Time..." "Done. Time changed by ${updatedata#*offset }"
|
||||
;;
|
||||
*) pass otp -c ${choice}-otp ;;
|
||||
esac
|
||||
10
.local/bin/pauseallmpv
Executable file
10
.local/bin/pauseallmpv
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# You might notice all mpv commands are aliased to have this input-ipc-server
|
||||
# thing. That's just for this particular command, which allows us to pause
|
||||
# every single one of them with one command! This is bound to super + shift + p
|
||||
# (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";
|
||||
done
|
||||
9
.local/bin/peertubetorrent
Executable file
9
.local/bin/peertubetorrent
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
# torrent peertube videos, requires the transadd script
|
||||
# first argument is the video link, second is the quality (360, 480 or 1080)
|
||||
# 13/07/20 - Arthur Bais
|
||||
|
||||
instance=$(echo "$1" | sed "s|/w.\+||")
|
||||
vidid=$(echo "$1" | sed "s|.\+/||")
|
||||
link=$(curl -s "$instance/api/v1/videos/$vidid" | grep -o "$instance/download/torrents/.\{37\}$2.torrent")
|
||||
transadd "$link"
|
||||
7
.local/bin/podentr
Executable file
7
.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
.local/bin/prompt
Executable file
8
.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
.local/bin/qndl
Executable file
12
.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
.local/bin/queueandnotify
Executable file
14
.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"
|
||||
11
.local/bin/remaps
Executable file
11
.local/bin/remaps
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script is called on startup to remap keys.
|
||||
# Decrease key repeat delay to 300ms and increase key repeat rate to 50 per second.
|
||||
xset r rate 300 50
|
||||
# Map the caps lock key to super, and map the menu key to right super.
|
||||
setxkbmap -option caps:super,altwin:menu_win
|
||||
# When caps lock is pressed only once, treat it as escape.
|
||||
killall xcape 2>/dev/null ; xcape -e 'Super_L=Escape'
|
||||
# Turn off caps lock if on since there is no longer a key for it.
|
||||
xset -q | grep "Caps Lock:\s*on" && xdotool key Caps_Lock
|
||||
12
.local/bin/rotdir
Executable file
12
.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
.local/bin/rssadd
Executable file
18
.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
|
||||
10
.local/bin/sd
Executable file
10
.local/bin/sd
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Open a terminal window in the same directory as the currently active window.
|
||||
|
||||
PID=$(xprop -id "$(xprop -root | xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p")
|
||||
PID="$(pstree -lpA "$PID")"
|
||||
PID="${PID##*"${SHELL##*/}"(}"
|
||||
PID="${PID%%)*}"
|
||||
cd "$(readlink /proc/"$PID"/cwd)" || return 1
|
||||
"$TERMINAL"
|
||||
34
.local/bin/setbg
Executable file
34
.local/bin/setbg
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script does the following:
|
||||
# Run by itself, set the wallpaper (at X start).
|
||||
# If given a file, set that as the new wallpaper.
|
||||
# If given a directory, choose random file in it.
|
||||
# If wal is installed, also generates a colorscheme.
|
||||
|
||||
# Location of link to wallpaper link.
|
||||
bgloc="${XDG_DATA_HOME:-$HOME/.local/share}/bg"
|
||||
|
||||
# Configuration files of applications that have their themes changed by pywal.
|
||||
dunstconf="${XDG_CONFIG_HOME:-$HOME/.config}/dunst/dunstrc"
|
||||
zathuraconf="${XDG_CONFIG_HOME:-$HOME/.config}/zathura/zathurarc"
|
||||
|
||||
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 or directory." ; exit 1;;
|
||||
esac
|
||||
|
||||
# If pywal is installed, use it.
|
||||
if command -v wal >/dev/null 2>&1 ; then
|
||||
wal -n -i "$(readlink -f $bgloc)" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1
|
||||
# If pywal is removed, return config files to normal.
|
||||
else
|
||||
[ -f "$dunstconf.bak" ] && unlink "$dunstconf" && mv "$dunstconf.bak" "$dunstconf"
|
||||
[ -f "$zathuraconf.bak" ] && unlink "$zathuraconf" && mv "$zathuraconf.bak" "$zathuraconf"
|
||||
fi
|
||||
|
||||
xwallpaper --zoom "$bgloc"
|
||||
# If running, dwm hit the key to refresh the color scheme.
|
||||
pidof dwm >/dev/null && xdotool key super+F5
|
||||
43
.local/bin/shortcuts
Executable file
43
.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
.local/bin/slider
Executable file
126
.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.
|
||||
@@ -3,7 +3,8 @@
|
||||
exec sudo timedatectl set-ntp true &
|
||||
exec xset s off &
|
||||
exec xset -dpms &
|
||||
exec xwallpaper --daemon --maximize files/pics/walls/wall.jpg &
|
||||
exec feh --no-fehbg --bg-scale --randomize '/home/dorian/files/pics/walls'
|
||||
#exec xwallpaper --daemon --maximize files/pics/walls/wall.jpg &
|
||||
exec /usr/bin/unclutter &
|
||||
exec /usr/bin/xcompmgr &
|
||||
exec /usr/bin/dunst &
|
||||
|
||||
37
.local/bin/statusbar/sb-battery
Executable file
37
.local/bin/statusbar/sb-battery
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Prints all batteries, their percentage remaining and an emoji corresponding
|
||||
# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.).
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
3) notify-send "🔋 Battery module" "🔋: discharging
|
||||
🛑: not charging
|
||||
♻: stagnant charge
|
||||
🔌: charging
|
||||
⚡: charged
|
||||
❗: battery very low!
|
||||
- Scroll to change adjust xbacklight." ;;
|
||||
4) xbacklight -inc 10 ;;
|
||||
5) xbacklight -dec 10 ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
# Loop through all attached batteries and format the info
|
||||
for battery in /sys/class/power_supply/BAT?*; do
|
||||
# If non-first battery, print a space separator.
|
||||
[ -n "${capacity+x}" ] && printf " "
|
||||
# Sets up the status and capacity
|
||||
case "$(cat "$battery/status" 2>&1)" in
|
||||
"Full") status="⚡" ;;
|
||||
"Discharging") status="🔋" ;;
|
||||
"Charging") status="🔌" ;;
|
||||
"Not charging") status="🛑" ;;
|
||||
"Unknown") status="♻️" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
capacity="$(cat "$battery/capacity" 2>&1)"
|
||||
# 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
|
||||
done && printf "\\n"
|
||||
29
.local/bin/statusbar/sb-clock
Executable file
29
.local/bin/statusbar/sb-clock
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
clock=$(date '+%I')
|
||||
|
||||
case "$clock" in
|
||||
"00") icon="🕛" ;;
|
||||
"01") icon="🕐" ;;
|
||||
"02") icon="🕑" ;;
|
||||
"03") icon="🕒" ;;
|
||||
"04") icon="🕓" ;;
|
||||
"05") icon="🕔" ;;
|
||||
"06") icon="🕕" ;;
|
||||
"07") icon="🕖" ;;
|
||||
"08") icon="🕗" ;;
|
||||
"09") icon="🕘" ;;
|
||||
"10") icon="🕙" ;;
|
||||
"11") icon="🕚" ;;
|
||||
"12") icon="🕛" ;;
|
||||
esac
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s|..27m|</span></b>|")" && notify-send "Appointments" "$(calcurse -d3)" ;;
|
||||
2) setsid -f "$TERMINAL" -e calcurse ;;
|
||||
3) notify-send "📅 Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
|
||||
- Middle click opens calcurse if installed" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
date "+%Y %b %d (%a) $icon%I:%M%p"
|
||||
12
.local/bin/statusbar/sb-cpu
Executable file
12
.local/bin/statusbar/sb-cpu
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "🖥 CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)\\n(100% per core)" ;;
|
||||
2) setsid -f "$TERMINAL" -e htop ;;
|
||||
3) notify-send "🖥 CPU module " "\- Shows CPU temperature.
|
||||
- Click to show intensive processes.
|
||||
- Middle click to open htop." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
sensors | awk '/Core 0/ {print "🌡" $3}'
|
||||
44
.local/bin/statusbar/sb-cpubars
Executable file
44
.local/bin/statusbar/sb-cpubars
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Module showing CPU load as a changing bars.
|
||||
# Just like in polybar.
|
||||
# Each bar represents amount of load on one core since
|
||||
# last run.
|
||||
|
||||
# Cache in tmpfs to improve speed and reduce SSD load
|
||||
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";;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
# id total idle
|
||||
stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat)
|
||||
[ ! -f $cache ] && echo "$stats" > "$cache"
|
||||
old=$(cat "$cache")
|
||||
printf "🪨"
|
||||
echo "$stats" | while read -r row; do
|
||||
id=${row%% *}
|
||||
rest=${row#* }
|
||||
total=${rest%% *}
|
||||
idle=${rest##* }
|
||||
|
||||
case "$(echo "$old" | awk '{if ($1 == id)
|
||||
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 "█";;
|
||||
esac
|
||||
done; printf "\\n"
|
||||
echo "$stats" > "$cache"
|
||||
23
.local/bin/statusbar/sb-disk
Executable file
23
.local/bin/statusbar/sb-disk
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Status bar module for disk space
|
||||
# $1 should be drive mountpoint, otherwise assumed /.
|
||||
|
||||
location=${1:-/}
|
||||
|
||||
[ -d "$location" ] || exit
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;;
|
||||
3) notify-send "💽 Disk module" "\- Shows used hard drive space.
|
||||
- Click to show all disk info." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
case "$location" in
|
||||
"/home"* ) icon="🏠" ;;
|
||||
"/mnt"* ) icon="💾" ;;
|
||||
*) icon="🖥";;
|
||||
esac
|
||||
|
||||
printf "%s: %s\n" "$icon" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')"
|
||||
279
.local/bin/statusbar/sb-doppler
Executable file
279
.local/bin/statusbar/sb-doppler
Executable file
@@ -0,0 +1,279 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Show a Doppler RADAR of a user's preferred location.
|
||||
|
||||
secs=600 # Download a new doppler radar if one hasn't been downloaded in $secs seconds.
|
||||
radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar"
|
||||
doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif"
|
||||
|
||||
pickloc() { chosen="$(echo "US: Northeast
|
||||
US: Southeast
|
||||
US: PacNorthWest
|
||||
US: PacSouthWest
|
||||
US: UpperMissVly
|
||||
US: SouthMissVly
|
||||
US: SouthPlains
|
||||
US: NorthRockies
|
||||
US: SouthRockies
|
||||
US: Alaska
|
||||
US: Carib
|
||||
US: Hawaii
|
||||
US: CentGrLakes
|
||||
US: Conus-Large
|
||||
US: KABR: Aberdeen, SD
|
||||
US: KBIS: Bismarck, ND
|
||||
US: KFTG: Denver/Boulder, CO
|
||||
US: KDMX: Des Moines, IA
|
||||
US: KDTX: Detroit, MI
|
||||
US: KDDC: Dodge City, KS
|
||||
US: KDLH: Duluth, MN
|
||||
US: KCYS: Cheyenne, WY
|
||||
US: KLOT: Chicago, IL
|
||||
US: KGLD: Goodland, KS
|
||||
US: KUEX: Hastings, NE
|
||||
US: KGJX: Grand Junction, CO
|
||||
US: KGRR: Grand Rapids, MI
|
||||
US: KMVX: Fargo/Grand Forks, ND
|
||||
US: KGRB: Green Bay, WI
|
||||
US: KIND: Indianapolis, IN
|
||||
US: KJKL: Jackson, KY
|
||||
US: KARX: La Crosse, WI
|
||||
US: KILX: Lincoln/Central Illinois, IL
|
||||
US: KLVX: Louisville, KY
|
||||
US: KMQT: Marquette
|
||||
US: KMKX: Milwaukee, WI
|
||||
US: KMPX: Minneapolis, MN
|
||||
US: KAPX: Gaylord/Alpena, MI
|
||||
US: KLNX: North Platte, NE
|
||||
US: KIWX: N. Webster/Northern, IN
|
||||
US: KOAX: Omaha, NE
|
||||
US: KPAH: Paducah, KY
|
||||
US: KEAX: Pleasant Hill, MO
|
||||
US: KPUX: Pueblo, CO
|
||||
US: KDVN: Quad Cities, IA
|
||||
US: KUDX: Rapid City, SD
|
||||
US: KRIW: Riverton, WY
|
||||
US: KSGF: Springfield, MO
|
||||
US: KLSX: St. LOUIS, MO
|
||||
US: KFSD: Sioux Falls, IA
|
||||
US: KTWX: Topeka, KS
|
||||
US: KICT: Wichita, KS
|
||||
US: KVWX: Paducah, KY
|
||||
US: ICAO: Responsible Wfo
|
||||
US: KLTX: WILMINGTON, NC
|
||||
US: KCCX: State College/Central, PA
|
||||
US: KLWX: Sterling, VA
|
||||
US: KFCX: Blacksburg/Roanoke, VA
|
||||
US: KRAX: Raleigh/Durham, NC
|
||||
US: KGYX: Portland, ME
|
||||
US: KDIX: Mt Holly/Philadelphia, PA
|
||||
US: KPBZ: Pittsburgh, PA
|
||||
US: KAKQ: Wakefield, VA
|
||||
US: KMHX: Morehead City, NC
|
||||
US: KGSP: Greer/Greenville/Sprtbg, SC
|
||||
US: KILN: Wilmington/Cincinnati, OH
|
||||
US: KCLE: Cleveland, OH
|
||||
US: KCAE: Columbia, SC
|
||||
US: KBGM: Binghamton, NY
|
||||
US: KENX: Albany, NY
|
||||
US: KBUF: Buffalo, NY
|
||||
US: KCXX: Burlington, VT
|
||||
US: KCBW: Caribou, ME
|
||||
US: KBOX: Boston /Taunton, MA
|
||||
US: KOKX: New York City, NY
|
||||
US: KCLX: Charleston, SC
|
||||
US: KRLX: Charleston, WV
|
||||
US: ICAO: Responsible WFO
|
||||
US: KBRO: Brownsville, TX
|
||||
US: KABX: Albuquerque, NM
|
||||
US: KAMA: Amarillo, TX
|
||||
US: KFFC: Peachtree City/Atlanta, GA
|
||||
US: KEWX: Austin/Sanantonio, TX
|
||||
US: KBMX: Birmingham, AL
|
||||
US: KCRP: Corpus Christi, TX
|
||||
US: KFWS: Dallas / Ft. Worth, TX
|
||||
US: KEPZ: El Paso, TX
|
||||
US: KHGX: Houston/ Galveston, TX
|
||||
US: KJAX: Jacksonville, FL
|
||||
US: KBYX: Key West, FL
|
||||
US: KMRX: Morristown/knoxville, TN
|
||||
US: KLBB: Lubbock, TX
|
||||
US: KLZK: Little Rock, AR
|
||||
US: KLCH: Lake Charles, LA
|
||||
US: KOHX: Nashville, TN
|
||||
US: KMLB: Melbourne, FL
|
||||
US: KNQA: Memphis, TN
|
||||
US: KAMX: Miami, FL
|
||||
US: KMAF: Midland/odessa, TX
|
||||
US: KTLX: Norman, OK
|
||||
US: KHTX: Huntsville, AL
|
||||
US: KMOB: Mobile, AL
|
||||
US: KTLH: Tallahassee, FL
|
||||
US: KTBW: Tampa Bay Area, FL
|
||||
US: KSJT: San Angelo, TX
|
||||
US: KINX: Tulsa, OK
|
||||
US: KSRX: Tulsa, OK
|
||||
US: KLIX: New Orleans/slidell, LA
|
||||
US: KDGX: Jackson, MS
|
||||
US: KSHV: Shreveport, LA
|
||||
US: ICAO: Responsible WFO
|
||||
US: KLGX: Seattle / Tacoma, WA
|
||||
US: KOTX: Spokane, WA
|
||||
US: KEMX: Tucson, AZ
|
||||
US: KYUX: Phoenix, AZ
|
||||
US: KNKX: San Diego, CA
|
||||
US: KMUX: Monterey/san Francisco, CA
|
||||
US: KHNX: San Joaquin/hanford, CA
|
||||
US: KSOX: San Diego, CA
|
||||
US: KATX: Seattle / Tacoma, WA
|
||||
US: KIWA: Phoenix, AZ
|
||||
US: KRTX: Portland, OR
|
||||
US: KSFX: Pocatello, ID
|
||||
US: KRGX: Reno, NV
|
||||
US: KDAX: Sacramento, CA
|
||||
US: KMTX: Salt Lake City, UT
|
||||
US: KPDT: Pendleton, OR
|
||||
US: KMSX: Missoula, MT
|
||||
US: KESX: Las Vegas, NV
|
||||
US: KVTX: Los Angeles, CA
|
||||
US: KMAX: Medford, OR
|
||||
US: KFSX: Flagstaff, AZ
|
||||
US: KGGW: Glasgow, MT
|
||||
US: KLRX: Elko, NV
|
||||
US: KBHX: Eureka, CA
|
||||
US: KTFX: Great Falls, MT
|
||||
US: KCBX: Boise, ID
|
||||
US: KBLX: Billings, MT
|
||||
US: KICX: Salt Lake City, UT
|
||||
US: ICAO: Responsible Wfo W/ MSCF
|
||||
US: PABC: Anchorage, AK
|
||||
US: PAPD: Fairbanks, AK
|
||||
US: PHKM: Honolulu, HI
|
||||
US: PAHG: Anchorage, AK
|
||||
US: PAKC: Anchorage, AK
|
||||
US: PAIH: Anchorage, AK
|
||||
US: PHMO: Honolulu, HI
|
||||
US: PAEC: Fairbanks, AK
|
||||
US: TJUA: San Juan, PR
|
||||
US: PACG: Juneau, AK
|
||||
US: PHKI: Honolulu, HI
|
||||
US: PHWA: Honolulu, HI
|
||||
US: ICAO: Responsible Wfo W/ MSCF
|
||||
US: KFDR: Norman, OK
|
||||
US: PGUA: Guam
|
||||
US: KBBX: Sacramento, CA
|
||||
US: KFDX: Albuquerque, NM
|
||||
US: KGWX: Jackson, MS
|
||||
US: KDOX: Wakefield, VA
|
||||
US: KDYX: San Angelo, TX
|
||||
US: KEYX: Las Vegas, NV
|
||||
US: KEVX: Mobile, AL
|
||||
US: KHPX: Paducah, KY
|
||||
US: KTYX: Burlington, VT
|
||||
US: KGRK: Dallas / Ft. Worth, TX
|
||||
US: KPOE: Lake Charles, LA
|
||||
US: KEOX: Tallahassee, FL
|
||||
US: KHDX: El Paso, TX
|
||||
US: KDFX: San Antonio, TX
|
||||
US: KMXX: Birmingham, AL
|
||||
US: KMBX: Bismarck, ND
|
||||
US: KVAX: Jacksonville, FL
|
||||
US: KJGX: Peachtree City/atlanta, GA
|
||||
US: KVNX: Norman, OK
|
||||
US: KVBX: Vandenberg Afb: Orcutt, CA
|
||||
EU: Europe
|
||||
EU: GB: Great Brittain
|
||||
EU: SCAN: Scandinavia
|
||||
EU: ALPS: The Alps
|
||||
EU: NL: The Netherlands
|
||||
EU: DE: Germany
|
||||
EU: SP: Spain
|
||||
EU: FR: France
|
||||
EU: IT: Italy
|
||||
EU: PL: Poland
|
||||
EU: GR: Greece
|
||||
EU: TU: Turkey
|
||||
EU: RU: Russia
|
||||
EU: BA: Bahrain
|
||||
EU: BC: Botswana
|
||||
EU: SE: Republic of Seychelles
|
||||
EU: HU: Hungary
|
||||
EU: UK: Ukraine
|
||||
AF: AF: Africa
|
||||
AF: WA: West Africa
|
||||
AF: ZA: South Africa
|
||||
AF: DZ: Algeria
|
||||
AF: CE: Canary Islands
|
||||
AF: NG: Nigeria
|
||||
AF: TD: Chad
|
||||
AF: CG: Democratic Republic of Congo
|
||||
AF: EG: Egypt
|
||||
AF: ET: Ethiopia
|
||||
AF: CM: Cameroon
|
||||
AF: IS: Israel
|
||||
AF: LY: Libya
|
||||
AF: MG: Madagascar
|
||||
AF: MO: Morocco
|
||||
AF: BW: Namibia
|
||||
AF: SA: Saudi Arabia
|
||||
AF: SO: Somalia
|
||||
AF: SD: Sudan
|
||||
AF: TZ: Tanzania
|
||||
AF: TN: Tunisia
|
||||
AF: ZM: Zambia
|
||||
AF: KE: Kenya
|
||||
AF: AO: Angola
|
||||
DE: BAW: Baden-Württemberg
|
||||
DE: BAY: Bavaria
|
||||
DE: BBB: Berlin
|
||||
DE: BBB: Brandenburg
|
||||
DE: HES: Hesse
|
||||
DE: MVP: Mecklenburg-Western Pomerania
|
||||
DE: NIB: Lower Saxony
|
||||
DE: NIB: Bremen
|
||||
DE: NRW: North Rhine-Westphalia
|
||||
DE: RPS: Rhineland-Palatinate
|
||||
DE: RPS: Saarland
|
||||
DE: SAC: Saxony
|
||||
DE: SAA: Saxony-Anhalt
|
||||
DE: SHH: Schleswig-Holstein
|
||||
DE: SHH: Hamburg
|
||||
DE: THU: Thuringia" | dmenu -r -i -l 50 -p "Select a radar to use as default:" | tr "[:lower:]" "[:upper:]")"
|
||||
|
||||
# Ensure user did not escape.
|
||||
[ -z "$chosen" ] && exit 1
|
||||
|
||||
# Set continent code and radar code.
|
||||
continentcode=${chosen%%:*}
|
||||
radarcode=${chosen#* } radarcode=${radarcode%:*}
|
||||
|
||||
# Print codes to $radarloc file.
|
||||
printf "%s,%s\\n" "$continentcode" "$radarcode" > "$radarloc" ;}
|
||||
|
||||
getdoppler() {
|
||||
cont=$(cut -c -2 "$radarloc")
|
||||
loc=$(cut -c 4- "$radarloc")
|
||||
notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc."
|
||||
case "$cont" in
|
||||
"US") curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;;
|
||||
"EU") curl -sL "https://api.sat24.com/animated/${loc}/rainTMC/2/" > "$doppler" ;;
|
||||
"AF") curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ;;
|
||||
"DE") loc="$(echo "$loc" | tr "[:upper:]" "[:lower:]")"
|
||||
curl -sL "https://www.dwd.de/DWD/wetter/radar/radfilm_${loc}_akt.gif" > "$doppler" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
showdoppler() { setsid -f mpv --no-osc --loop=inf --no-terminal "$doppler" ;}
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) [ ! -f "$radarloc" ] && pickloc && getdoppler
|
||||
[ $(($(date '+%s') - $(stat -c %Y "$doppler"))) -gt "$secs" ] && getdoppler
|
||||
showdoppler ;;
|
||||
2) pickloc && getdoppler && showdoppler ;;
|
||||
3) notify-send "🗺️ Doppler RADAR module" "\- Left click for local Doppler RADAR.
|
||||
- Middle click to update RADAR location.
|
||||
After $secs seconds, new clicks will also automatically update the doppler RADAR." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
echo 🗺️
|
||||
35
.local/bin/statusbar/sb-forecast
Executable file
35
.local/bin/statusbar/sb-forecast
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Displays todays precipication chance (☔) and daily low (🥶) and high (🌞).
|
||||
# Usually intended for the statusbar.
|
||||
|
||||
# If we have internet, get a weather report from wttr.in and store it locally.
|
||||
# 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_CACHE_HOME:-$HOME/.cache}/weatherreport"
|
||||
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 "°"}' ;}
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;;
|
||||
2) getforecast && showweather ;;
|
||||
3) notify-send "🌈 Weather module" "\- Left click for full forecast.
|
||||
- Middle click to update forecast.
|
||||
☔: Chance of rain/snow
|
||||
🥶: Daily low
|
||||
🌞: Daily high" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
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
|
||||
|
||||
showweather
|
||||
17
.local/bin/statusbar/sb-help-icon
Executable file
17
.local/bin/statusbar/sb-help-icon
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 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 ;}
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) groff -mom "${READMEFILE:-${XDG_DATA_HOME:-$HOME/.local/share}/larbs/readme.mom}" -Tpdf | zathura - ;;
|
||||
2) restartwm ;;
|
||||
3) notify-send "❓ Help module" "\- Left click to open LARBS guide.
|
||||
- Middle click to refresh window manager." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac; echo "❓"
|
||||
26
.local/bin/statusbar/sb-internet
Executable file
26
.local/bin/statusbar/sb-internet
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Show wifi 📶 and percent strength or 📡 if none.
|
||||
# Show 🌐 if connected to ethernet or ❎ if none.
|
||||
# Show 🔒 if a vpn connection is active
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;;
|
||||
3) notify-send "🌐 Internet module" "\- Click to connect
|
||||
❌: wifi disabled
|
||||
📡: no wifi connection
|
||||
📶: wifi connection with quality
|
||||
❎: no ethernet
|
||||
🌐: ethernet working
|
||||
🔒: vpn is active
|
||||
" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then
|
||||
wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
|
||||
elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then
|
||||
grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon="📡 " || wifiicon="❌ "
|
||||
fi
|
||||
|
||||
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)"
|
||||
10
.local/bin/statusbar/sb-iplocate
Executable file
10
.local/bin/statusbar/sb-iplocate
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Gets your public ip address checks which country you are in and
|
||||
# displays that information in the statusbar
|
||||
#
|
||||
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
|
||||
|
||||
ifinstalled "geoip" || 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/;.*//"
|
||||
16
.local/bin/statusbar/sb-kbselect
Executable file
16
.local/bin/statusbar/sb-kbselect
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# works on any init system
|
||||
# requirements: dmenu, xorg-setxkbmap
|
||||
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)"
|
||||
kb="$(echo "$kb_choice" | awk '{print $3}')"
|
||||
setxkbmap "$kb"
|
||||
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.";;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
echo "$kb"
|
||||
20
.local/bin/statusbar/sb-mailbox
Executable file
20
.local/bin/statusbar/sb-mailbox
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Displays number of unread mail and an loading icon if updating.
|
||||
# When clicked, brings up `neomutt`.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e neomutt ;;
|
||||
2) setsid -f mw -Y >/dev/null ;;
|
||||
3) notify-send "📬 Mail module" "\- Shows unread mail
|
||||
- Shows 🔃 if syncing mail
|
||||
- Left click opens neomutt
|
||||
- Middle click syncs mail" ;;
|
||||
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)"
|
||||
|
||||
pidof mbsync >/dev/null 2>&1 && icon="🔃"
|
||||
|
||||
[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "📬$unread$icon"
|
||||
12
.local/bin/statusbar/sb-memory
Executable file
12
.local/bin/statusbar/sb-memory
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
|
||||
2) setsid -f "$TERMINAL" -e htop ;;
|
||||
3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
|
||||
- Click to show memory hogs.
|
||||
- Middle click to open htop." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'
|
||||
37
.local/bin/statusbar/sb-moonphase
Executable file
37
.local/bin/statusbar/sb-moonphase
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Shows the current moon phase.
|
||||
|
||||
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 ;}
|
||||
|
||||
icon="$(cat "$moonfile")"
|
||||
|
||||
case "$icon" in
|
||||
🌑) name="New" ;;
|
||||
🌒) name="Waxing Crescent" ;;
|
||||
🌓) name="First Quarter" ;;
|
||||
🌔) name="Waxing Gibbous" ;;
|
||||
🌕) name="Full" ;;
|
||||
🌖) name="Waning Gibbous" ;;
|
||||
🌗) name="Last Quarter" ;;
|
||||
🌘) name="Waning Crescent" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
|
||||
echo "${icon-?}"
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
3) notify-send "🌜 Moon phase module" "Displays current moon phase.
|
||||
- 🌑: New
|
||||
- 🌒: Waxing Crescent
|
||||
- 🌓: First Quarter
|
||||
- 🌔: Waxing Gibbous
|
||||
- 🌕: Full
|
||||
- 🌖: Waning Gibbous
|
||||
- 🌗: Last Quarter
|
||||
- 🌘: Waning Crescent" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
8
.local/bin/statusbar/sb-mpdup
Executable file
8
.local/bin/statusbar/sb-mpdup
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 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
|
||||
done
|
||||
19
.local/bin/statusbar/sb-music
Executable file
19
.local/bin/statusbar/sb-music
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
filter() { mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -;}
|
||||
|
||||
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
|
||||
2) mpc toggle | filter ;; # right click, pause/unpause
|
||||
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
|
||||
4) mpc prev | filter ;; # scroll up, previous
|
||||
5) mpc next | filter ;; # scroll down, next
|
||||
6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
*) mpc status | filter ;;
|
||||
esac
|
||||
29
.local/bin/statusbar/sb-nettraf
Executable file
29
.local/bin/statusbar/sb-nettraf
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Module showing network traffic. Shows how much data has been received (RX) or
|
||||
# transmitted (TX) since the previous time this script ran. So if run every
|
||||
# second, gives network traffic per second.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e bmon ;;
|
||||
3) notify-send "🌐 Network traffic module" "🔻: Traffic received
|
||||
🔺: Traffic transmitted" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
update() {
|
||||
sum=0
|
||||
for arg; do
|
||||
read -r i < "$arg"
|
||||
sum=$(( sum + i ))
|
||||
done
|
||||
cache=/tmp/${1##*/}
|
||||
[ -f "$cache" ] && read -r old < "$cache" || old=0
|
||||
printf %d\\n "$sum" > "$cache"
|
||||
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 $tx)
|
||||
17
.local/bin/statusbar/sb-news
Executable file
17
.local/bin/statusbar/sb-news
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Displays number of unread news items and an loading icon if updating.
|
||||
# When clicked, brings up `newsboat`.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid "$TERMINAL" -e newsboat ;;
|
||||
2) setsid -f newsup >/dev/null exit ;;
|
||||
3) notify-send "📰 News module" "\- Shows unread news items
|
||||
- Shows 🔃 if updating with \`newsup\`
|
||||
- Left click opens newsboat
|
||||
- Middle click syncs RSS feeds
|
||||
<b>Note:</b> Only one instance of newsboat (including updates) may be running at a time." ;;
|
||||
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)"
|
||||
29
.local/bin/statusbar/sb-pacpackages
Executable file
29
.local/bin/statusbar/sb-pacpackages
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Displays number of upgradeable packages.
|
||||
# For this to work, have a `pacman -Sy` command run in the background as a
|
||||
# cronjob every so often as root. This script will then read those packages.
|
||||
# When clicked, it will run an upgrade via pacman.
|
||||
#
|
||||
# Add the following text as a file in /usr/share/libalpm/hooks/statusbar.hook:
|
||||
#
|
||||
# [Trigger]
|
||||
# Operation = Upgrade
|
||||
# Type = Package
|
||||
# Target = *
|
||||
#
|
||||
# [Action]
|
||||
# Description = Updating statusbar...
|
||||
# When = PostTransaction
|
||||
# Exec = /usr/bin/pkill -RTMIN+8 dwmblocks # Or i3blocks if using i3.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e sb-popupgrade ;;
|
||||
2) notify-send "$(/usr/bin/pacman -Qu)" ;;
|
||||
3) notify-send "🎁 Upgrade module" "📦: number of upgradable packages
|
||||
- Left click to upgrade packages
|
||||
- Middle click to show upgradable packages" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
pacman -Qu | grep -Fcv "[ignored]" | sed "s/^/📦/;s/^📦0$//g"
|
||||
9
.local/bin/statusbar/sb-popupgrade
Executable file
9
.local/bin/statusbar/sb-popupgrade
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
printf "Beginning upgrade.\\n"
|
||||
|
||||
yay -Syu
|
||||
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
|
||||
|
||||
printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
|
||||
read -r _
|
||||
50
.local/bin/statusbar/sb-price
Executable file
50
.local/bin/statusbar/sb-price
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Usage:
|
||||
# price <url> <Name of currency> <icon> <Price to show in>
|
||||
# price bat "Basic Attention Token" 🦁
|
||||
# When the name of the currency is multi-word, put it in quotes.
|
||||
|
||||
[ -z "$3" ] && exit 1
|
||||
|
||||
# use $4 as currency, if not passed in use "usd" as default
|
||||
currency="${4:-usd}"
|
||||
interval="@14d" # History contained in chart preceded by '@' (7d = 7 days)
|
||||
dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
|
||||
pricefile="$dir/$1-$currency"
|
||||
chartfile="$dir/$1-$currency-chart"
|
||||
|
||||
updateprice() { temp="$(mktemp)"
|
||||
curl -s "$currency.rate.sx/1$1" > "$temp" &&
|
||||
mv -f "$temp" "$pricefile" &&
|
||||
curl -s "$currency.rate.sx/$1$interval" > "$temp" &&
|
||||
mv -f "$temp" "$chartfile" ;}
|
||||
|
||||
[ -d "$dir" ] || mkdir -p "$dir"
|
||||
|
||||
[ "$(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..."
|
||||
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|")"
|
||||
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>" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
case "$currency" in
|
||||
usd) symb="$" ;;
|
||||
gbp) symb="£" ;;
|
||||
eur) symb="€" ;;
|
||||
btc) symb="₿" ;;
|
||||
esac
|
||||
|
||||
printf "$3$symb%0.2f$after" "$(cat "$pricefile")"
|
||||
20
.local/bin/statusbar/sb-tasks
Executable file
20
.local/bin/statusbar/sb-tasks
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Originally by Andr3as07 <https://github.com/Andr3as07>
|
||||
# Some changes by Luke
|
||||
# Rebuild by Tenyun
|
||||
|
||||
# This block displays the number running background tasks. Requires tsp.
|
||||
|
||||
num=$(tsp -l | awk -v numr=0 -v numq=0 '{if (/running/)numr++; if (/queued/)numq++} END{print numr+numq"("numq")"}')
|
||||
|
||||
# Handle mouse clicks
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e tsp -l ;;
|
||||
3) notify-send "Tasks module" "🤖: number of running/queued background tasks
|
||||
- Left click opens tsp" ;; # Right click
|
||||
2) $EDITOR "$0" ;; # Middle click
|
||||
esac
|
||||
|
||||
[ "$num" != "0(0)" ] &&
|
||||
echo "🤖$num"
|
||||
27
.local/bin/statusbar/sb-torrent
Executable file
27
.local/bin/statusbar/sb-torrent
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
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 ' ' -
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e tremc ;;
|
||||
2) td-toggle ;;
|
||||
3) notify-send "🌱 Torrent module" "\- Left click to open tremc.
|
||||
- Middle click to toggle transmission.
|
||||
- Shift click to edit script.
|
||||
Module shows number of torrents:
|
||||
🛑: paused
|
||||
🕰: idle (seeds needed)
|
||||
🔼: uploading (unfinished)
|
||||
🔽: downloading
|
||||
✅: done
|
||||
🌱: done and seeding" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
30
.local/bin/statusbar/sb-volume
Executable file
30
.local/bin/statusbar/sb-volume
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Prints the current volume or 🔇 if muted.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e pulsemixer ;;
|
||||
2) pamixer -t ;;
|
||||
4) pamixer --allow-boost -i 1 ;;
|
||||
5) pamixer --allow-boost -d 1 ;;
|
||||
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
|
||||
- Middle click to mute.
|
||||
- Scroll to change." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
[ $(pamixer --get-mute) = true ] && echo 🔇 && exit
|
||||
|
||||
vol="$(pamixer --get-volume)"
|
||||
|
||||
if [ "$vol" -gt "70" ]; then
|
||||
icon="🔊"
|
||||
elif [ "$vol" -gt "30" ]; then
|
||||
icon="🔉"
|
||||
elif [ "$vol" -gt "0" ]; then
|
||||
icon="🔈"
|
||||
else
|
||||
echo 🔇 && exit
|
||||
fi
|
||||
|
||||
echo "$icon$vol%"
|
||||
26
.local/bin/sysact
Executable file
26
.local/bin/sysact
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A dmenu wrapper script for system functions.
|
||||
export WM="dwm"
|
||||
case "$(readlink -f /sbin/init)" in
|
||||
*systemd*) ctl='systemctl' ;;
|
||||
*) ctl='loginctl' ;;
|
||||
esac
|
||||
|
||||
wmpid(){ # This function is needed if there are multiple instances of the window manager.
|
||||
tree="$(pstree -ps $$)"
|
||||
tree="${tree#*$WM(}"
|
||||
echo "${tree%%)*}"
|
||||
}
|
||||
|
||||
case "$(printf "🔒 lock\n🚪 leave $WM\n♻️ renew $WM\n🐻 hibernate\n🔃 reboot\n🖥️shutdown\n💤 sleep\n📺 display off" | dmenu -i -p 'Action: ')" in
|
||||
'🔒 lock') slock ;;
|
||||
"🚪 leave $WM") kill -TERM "$(wmpid)" ;;
|
||||
"♻️ renew $WM") kill -HUP "$(wmpid)" ;;
|
||||
'🐻 hibernate') slock $ctl hibernate -i ;;
|
||||
'💤 sleep') slock $ctl suspend -i ;;
|
||||
'🔃 reboot') $ctl reboot -i ;;
|
||||
'🖥️shutdown') $ctl poweroff -i ;;
|
||||
'📺 display off') xset dpms force off ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
67
.local/bin/tag
Executable file
67
.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
|
||||
12
.local/bin/td-toggle
Executable file
12
.local/bin/td-toggle
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 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-daemon && 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 "transmission-daemon enabled."
|
||||
fi
|
||||
sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
|
||||
16
.local/bin/texclear
Executable file
16
.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
|
||||
|
||||
7
.local/bin/torwrap
Executable file
7
.local/bin/torwrap
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
ifinstalled tremc transmission-cli || exit
|
||||
|
||||
! pidof transmission-daemon >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..."
|
||||
|
||||
$TERMINAL -e tremc; pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
|
||||
9
.local/bin/transadd
Executable file
9
.local/bin/transadd
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Mimeapp script for adding torrent to transmission-daemon, but will also start the daemon first if not running.
|
||||
|
||||
# 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}")
|
||||
|
||||
transmission-remote -a "$@" && notify-send "🔽 Torrent added."
|
||||
38
.local/bin/xos
Normal file
38
.local/bin/xos
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage_exit () {
|
||||
local name="${0##*/}"
|
||||
echo "\
|
||||
Usage: $name
|
||||
$name off
|
||||
$name 1.0
|
||||
$name 1.5
|
||||
$name 2.0"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ -n "$2" ]]; then
|
||||
usage_exit
|
||||
fi
|
||||
|
||||
scale_go () {
|
||||
local pointer_dev=$(xinput | sed -nr '/Virtual core/d;s/^.*id=([0-9]+).*slave +pointer.*$/\1/p')
|
||||
local output_dev=$(xrandr | sed -nr 's/^(.*) connected primary.*$/\1/p')
|
||||
for x in $output_dev; do
|
||||
xrandr --output $x --scale ${1}x${1}
|
||||
done
|
||||
for x in $pointer_dev ; do
|
||||
xinput set-prop $x 'Coordinate Transformation Matrix' ${1} 0 0 0 ${1} 0 0 0 1
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
(off|1|1.0)
|
||||
scale_go 1 ;;
|
||||
(1.5)
|
||||
scale_go 1.5 ;;
|
||||
(2|2.0)
|
||||
scale_go 2 ;;
|
||||
(*)
|
||||
usage_exit ;;
|
||||
esac
|
||||
Reference in New Issue
Block a user