add scripts, mostly taken from LARBS
This commit is contained in:
@@ -38,7 +38,7 @@ export UNISON="${XDG_DATA_HOME:-$HOME/.local/share}/unison"
|
|||||||
export HISTFILE="${XDG_DATA_HOME:-$HOME/.local/share}/history"
|
export HISTFILE="${XDG_DATA_HOME:-$HOME/.local/share}/history"
|
||||||
|
|
||||||
# Xspec and IXPEobssim
|
# Xspec and IXPEobssim
|
||||||
export HEADAS="$HOME/.local/lib/heasoft-6.30/x86_64-pc-linux-gnu-libc2.35/"
|
export HEADAS="$HOME/.local/lib/heasoft-6.30.1/x86_64-pc-linux-gnu-libc2.35/"
|
||||||
export TINYTIM="$HOME/.local/share/tinytim-7.5/"
|
export TINYTIM="$HOME/.local/share/tinytim-7.5/"
|
||||||
export IXPEOBSSIM_ROOT="$HOME/IXPE_analysis/ixpeobssim_latest"
|
export IXPEOBSSIM_ROOT="$HOME/IXPE_analysis/ixpeobssim_latest"
|
||||||
export IXPEOBSSIM_DATA="$HOME/IXPE_analysis/ixpeobssim_latest/ixpeobssimdata"
|
export IXPEOBSSIM_DATA="$HOME/IXPE_analysis/ixpeobssim_latest/ixpeobssimdata"
|
||||||
|
|||||||
52
.local/bin/compiler
Executable file
52
.local/bin/compiler
Executable file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/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. Opens .sent files as sent
|
||||||
|
# presentations. Runs scripts based on extention 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
|
||||||
|
|
||||||
|
textype() { \
|
||||||
|
command="pdflatex"
|
||||||
|
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
|
||||||
|
$command --output-directory="$dir" "$base" &&
|
||||||
|
grep -i addbibresource "$file" >/dev/null &&
|
||||||
|
biber --input-directory "$dir" "$base" &&
|
||||||
|
$command --output-directory="$dir" "$base" &&
|
||||||
|
$command --output-directory="$dir" "$base"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$ext" in
|
||||||
|
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
|
||||||
|
c) cc "$file" -o "$base" && "$base" ;;
|
||||||
|
go) go run "$file" ;;
|
||||||
|
h) sudo make install ;;
|
||||||
|
m) octave "$file" ;;
|
||||||
|
md) if [ -x "$(command -v lowdown)" ]; then
|
||||||
|
lowdown -d nointem -e super "$file" -Tms | groff -mpdfmark -ms -kept > "$base".pdf
|
||||||
|
elif [ -x "$(command -v groffdown)" ]; then
|
||||||
|
groffdown -i "$file" | groff > "$base.pdf"
|
||||||
|
else
|
||||||
|
pandoc "$file" --pdf-engine=xelatex -o "$base".pdf
|
||||||
|
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 ;;
|
||||||
|
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 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
|
||||||
|
esac
|
||||||
11
.local/bin/cron/README.md
Executable file
11
.local/bin/cron/README.md
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
# Important Note
|
||||||
|
|
||||||
|
These cronjobs have components that require information about your current display to display notifications correctly.
|
||||||
|
|
||||||
|
When you add them as cronjobs, I recommend you precede the command with commands as those below:
|
||||||
|
|
||||||
|
```
|
||||||
|
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $USER)/bus; export DISPLAY=:0; . $HOME/.zprofile; then_command_goes_here
|
||||||
|
```
|
||||||
|
|
||||||
|
This ensures that notifications will display, xdotool commands will function and environmental variables will work as well.
|
||||||
46
.local/bin/cron/batterynotify
Executable file
46
.local/bin/cron/batterynotify
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#export DISPLAY=:0
|
||||||
|
export $(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u "$USER" -o startx)/environ | xargs -0)
|
||||||
|
|
||||||
|
# Battery percentage at which to notify
|
||||||
|
WARNING_LEVEL=30
|
||||||
|
CRITICAL_LEVEL=10
|
||||||
|
|
||||||
|
#BATTERY_LEVEL=$(<"/sys/class/power_supply/BAT0/capacity")
|
||||||
|
#BATTERY_DISCHARGING=$([[ $(<"/sys/class/power_supply/BAT0/status") == "Discharging" ]] && echo 1 || echo 0)
|
||||||
|
# Using acpi
|
||||||
|
BATTERY_DISCHARGING=$(acpi -b | grep "Battery 0" | grep -c "Discharging")
|
||||||
|
BATTERY_LEVEL=$(acpi -b | grep "Battery 0" | grep -P -o '[0-9]+(?=%)')
|
||||||
|
|
||||||
|
# Use temporary files to store whether a notification has already been shown (to prevent multiple notifications)
|
||||||
|
CRIT_FILE=/tmp/battery_crit
|
||||||
|
WARN_FILE=/tmp/battery_warn
|
||||||
|
FULL_FILE=/tmp/battery_full
|
||||||
|
|
||||||
|
# Reset notifications if the battery is charging/discharging
|
||||||
|
if [ "$BATTERY_DISCHARGING" -eq 1 ] && [ -f $FULL_FILE ]; then
|
||||||
|
rm $FULL_FILE
|
||||||
|
elif [ "$BATTERY_DISCHARGING" -eq 0 ]; then
|
||||||
|
if [ -f $WARN_FILE ]; then
|
||||||
|
rm $WARN_FILE
|
||||||
|
fi
|
||||||
|
if [ -f $CRIT_FILE ]; then
|
||||||
|
rm $CRIT_FILE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the battery is charging and is full (and has not shown notification yet)
|
||||||
|
if [ "$BATTERY_LEVEL" -gt 95 ] && [ "$BATTERY_DISCHARGING" -eq 0 ] && [ ! -f $FULL_FILE ]; then
|
||||||
|
notify-send "Battery Full" "Battery is fully charged." -t 1500
|
||||||
|
touch $FULL_FILE
|
||||||
|
# If the battery is low and is not charging (and has not shown notification yet)
|
||||||
|
elif [ "$BATTERY_LEVEL" -le $CRITICAL_LEVEL ] && [ "$BATTERY_DISCHARGING" -eq 1 ] && [ ! -f $CRIT_FILE ]; then
|
||||||
|
notify-send "⚠️ Critical Battery Level" "${BATTERY_LEVEL}% of battery remaining." -u critical -r 9991 -t 5000
|
||||||
|
# uncomment the line below if you want to get notified at most once
|
||||||
|
#touch $WARN_FILE
|
||||||
|
elif [ "$BATTERY_LEVEL" -le $WARNING_LEVEL ] && [ "$BATTERY_DISCHARGING" -eq 1 ] && [ ! -f $WARN_FILE ]; then
|
||||||
|
notify-send "Low Battery" "${BATTERY_LEVEL}% of battery remaining." -u critical -r 9991 -t 1500
|
||||||
|
# uncomment the line below if you want to get notified at most once
|
||||||
|
#touch $WARN_FILE
|
||||||
|
fi
|
||||||
6
.local/bin/cron/crontog
Executable file
6
.local/bin/cron/crontog
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# 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.")
|
||||||
17
.local/bin/cron/newsup
Executable file
17
.local/bin/cron/newsup
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Set as a cron job to check for new RSS entries for newsboat.
|
||||||
|
# If newsboat is open, sends it an "R" key to refresh.
|
||||||
|
|
||||||
|
ping -q -c 1 example.org > /dev/null || exit
|
||||||
|
|
||||||
|
/usr/bin/notify-send "📰 Updating RSS feeds..."
|
||||||
|
|
||||||
|
pgrep -f newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit
|
||||||
|
|
||||||
|
echo 🔃 > /tmp/newsupdate
|
||||||
|
pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}"
|
||||||
|
/usr/bin/newsboat -x reload
|
||||||
|
rm -f /tmp/newsupdate
|
||||||
|
pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}"
|
||||||
|
/usr/bin/notify-send "📰 RSS feed update complete."
|
||||||
3
.local/bin/deadcells
Executable file
3
.local/bin/deadcells
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
${XDG_DATA_HOME:-$HOME/.local/share}/Games/GOG_Games/Dead\ Cells/start.sh
|
||||||
16
.local/bin/dmenuhandler
Executable file
16
.local/bin/dmenuhandler
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Feed this script a link and it will give dmenu
|
||||||
|
# some choice programs to use to open it.
|
||||||
|
|
||||||
|
case "$(printf "copy url\\nmpv\\nmpv (loop)\\nqueue download\\n\\nqueue youtube-dl\\nfeh\\nbrowser\\nw3m\\nmpv (float)" | dmenu -i -p "Open link with what program?")" in
|
||||||
|
"copy url") echo "$1" | xclip -selection clipboard ;;
|
||||||
|
mpv) setsid -f mpv -quiet "$1" >/dev/null 2>&1 ;;
|
||||||
|
"mpv (loop)") setsid -f mpv -quiet --loop "$1" >/dev/null 2>&1 ;;
|
||||||
|
"queue download") tsp curl -LO "$1" >/dev/null 2>&1 ;;
|
||||||
|
"queue youtube-dl") tsp youtube-dl --write-metadata -ic "$1" >/dev/null 2>&1 ;;
|
||||||
|
browser) setsid -f "$BROWSER" "$1" >/dev/null 2>&1 ;;
|
||||||
|
feh) setsid -f feh "$1" >/dev/null 2>&1 ;;
|
||||||
|
w3m) w3m "$1" >/dev/null 2>&1 ;;
|
||||||
|
"mpv (float)") setsid -f mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$1" >/dev/null 2>&1 ;;
|
||||||
|
esac
|
||||||
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
|
||||||
105
.local/bin/dmenurecord
Executable file
105
.local/bin/dmenurecord
Executable file
@@ -0,0 +1,105 @@
|
|||||||
|
#!/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 | grep dimensions | awk '{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 | grep dimensions | awk '{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\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:")
|
||||||
|
case "$choice" in
|
||||||
|
screencast) screencast;;
|
||||||
|
audio) audio;;
|
||||||
|
video) video;;
|
||||||
|
webcam) webcam;;
|
||||||
|
"webcam (hi-def)") webcamhidef;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
asktoend() { \
|
||||||
|
response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
|
||||||
|
[ "$response" = "Yes" ] && killrecording
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
screencast) screencast;;
|
||||||
|
audio) audio;;
|
||||||
|
video) video;;
|
||||||
|
kill) killrecording;;
|
||||||
|
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;;
|
||||||
|
esac
|
||||||
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/src/dmenu/unicode | 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
|
||||||
|
echo "$chosen" | tr -d '\n' | xclip -selection clipboard
|
||||||
|
notify-send "'$chosen' copied to clipboard." &
|
||||||
|
fi
|
||||||
8
.local/bin/doesitcache
Executable file
8
.local/bin/doesitcache
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from cachecontrol._cmd import main
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||||
|
sys.exit(main())
|
||||||
43
.local/bin/ext
Executable file
43
.local/bin/ext
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# A general, all-purpose extraction script.
|
||||||
|
#
|
||||||
|
# Default behavior: Extract archive into new directory
|
||||||
|
# Behavior with `-c` option: Extract contents into current directory
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
if [ -z "$extracthere" ]; then
|
||||||
|
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)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -z "$archive" ] && printf "Give archive to extract as argument.\\n" && exit 1
|
||||||
|
|
||||||
|
if [ -f "$archive" ] ; then
|
||||||
|
case "$archive" in
|
||||||
|
*.tar.bz2|*.tbz2) tar xvjf "$archive" ;;
|
||||||
|
*.tar.xz) tar -xf "$archive" ;;
|
||||||
|
*.tar.gz|*.tgz) tar xvzf "$archive" ;;
|
||||||
|
*.lzma) unlzma "$archive" ;;
|
||||||
|
*.bz2) bunzip2 "$archive" ;;
|
||||||
|
*.rar) unrar x -ad "$archive" ;;
|
||||||
|
*.gz) gunzip "$archive" ;;
|
||||||
|
*.tar) tar xvf "$archive" ;;
|
||||||
|
*.zip) unzip "$archive" ;;
|
||||||
|
*.Z) uncompress "$archive" ;;
|
||||||
|
*.7z) 7z x "$archive" ;;
|
||||||
|
*.xz) unxz "$archive" ;;
|
||||||
|
*.exe) cabextract "$archive" ;;
|
||||||
|
*) printf "extract: '%s' - unknown archive method\\n" "$archive" ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
printf "File \"%s\" not found.\\n" "$archive"
|
||||||
|
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 "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n"
|
||||||
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
|
||||||
3
.local/bin/hyperlightdrifter
Executable file
3
.local/bin/hyperlightdrifter
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
${XDG_DATA_HOME:-$HOME/.local/share}/Games/GOG_Games/Hyper\ Light\ Drifter/start.sh
|
||||||
19
.local/bin/i3cmds/ddspawn
Executable file
19
.local/bin/i3cmds/ddspawn
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Toggle floating dropdown terminal in i3, or start if non-existing.
|
||||||
|
# $1 is the script run in the terminal.
|
||||||
|
# All other args are terminal settings.
|
||||||
|
# Terminal names are in dropdown_* to allow easily setting i3 settings.
|
||||||
|
|
||||||
|
[ -z "$1" ] && exit
|
||||||
|
|
||||||
|
script=$1
|
||||||
|
shift
|
||||||
|
if xwininfo -tree -root | grep "(\"dropdown_$script\" ";
|
||||||
|
then
|
||||||
|
echo "Window detected."
|
||||||
|
i3 "[instance=\"dropdown_$script\"] scratchpad show; [instance=\"dropdown_$script\"] move position center"
|
||||||
|
else
|
||||||
|
echo "Window not detected... spawning."
|
||||||
|
i3 "exec --no-startup-id $TERMINAL -n dropdown_$script $@ -e $script"
|
||||||
|
fi
|
||||||
3
.local/bin/i3cmds/dropdowncalc
Executable file
3
.local/bin/i3cmds/dropdowncalc
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
ifinstalled bc && echo "Welcome to the Calculator." && bc -lq
|
||||||
15
.local/bin/i3cmds/hover
Executable file
15
.local/bin/i3cmds/hover
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
[ -z "$1" ] && exit # If $1 is left, hovers in the bottom left, if right, the bottom right
|
||||||
|
current=$(xdotool getwindowfocus)
|
||||||
|
newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 3))
|
||||||
|
newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 3))
|
||||||
|
xdotool windowsize "$current" $newheight $newwidth
|
||||||
|
newsize=$(xdotool getwindowgeometry "$current" | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}')
|
||||||
|
newwidth=$(xdotool getwindowgeometry "$current" | grep Geometry | grep -o " [0-9]*")
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
left) horizontal=0; vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) ;;
|
||||||
|
right) horizontal=$(($(xdotool getdisplaygeometry | awk '{print $1}') - newwidth)) ; vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) ;;
|
||||||
|
esac
|
||||||
|
xdotool windowmove "$current" $horizontal $vertical
|
||||||
28
.local/bin/i3cmds/i3resize
Executable file
28
.local/bin/i3cmds/i3resize
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script was made by `goferito` on Github.
|
||||||
|
# Some cleanup by Luke.
|
||||||
|
|
||||||
|
[ -z "$1" ] && echo "No direction provided" && exit 1
|
||||||
|
distanceStr="2 px or 2 ppt"
|
||||||
|
|
||||||
|
moveChoice() {
|
||||||
|
i3-msg resize "$1" "$2" "$distanceStr" | grep '"success":true' || \
|
||||||
|
i3-msg resize "$3" "$4" "$distanceStr"
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
up)
|
||||||
|
moveChoice grow up shrink down
|
||||||
|
;;
|
||||||
|
down)
|
||||||
|
moveChoice shrink up grow down
|
||||||
|
;;
|
||||||
|
left)
|
||||||
|
moveChoice shrink right grow left
|
||||||
|
;;
|
||||||
|
right)
|
||||||
|
moveChoice grow right shrink left
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
5
.local/bin/i3cmds/tmuxdd
Executable file
5
.local/bin/i3cmds/tmuxdd
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This is the script that i3 runs to either start tmux in
|
||||||
|
# the dropdown terminal or log into a previous session.
|
||||||
|
tmux a || tmux
|
||||||
10
.local/bin/i3cmds/toggle-welcome
Executable file
10
.local/bin/i3cmds/toggle-welcome
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Toggles the LARBS welcome message.
|
||||||
|
|
||||||
|
PIC="${XDG_DATA_HOME:-$HOME/.local/share}/larbs/larbs.png"
|
||||||
|
|
||||||
|
grep LARBSWELCOME "$XDG_CONFIG_HOME/xprofile" &&
|
||||||
|
( sed -i "/LARBSWELCOME/d" "$XDG_CONFIG_HOME/xprofile" && notify-send -i "$PIC" "LARBS welcome message" "Welcome message disabled. Press Super+Shift+F1 again to reverse." ) ||
|
||||||
|
( echo "notify-send -i \"$PIC\" \"Welcome to LARBS\" \"Press super+F1 for the help menu.\" # LARBSWELCOME" >> "$XDG_CONFIG_HOME/xprofile" &&
|
||||||
|
notify-send -i "$PIC" "LARBS welcome message" "Welcome message re-enabled." )
|
||||||
11
.local/bin/ifinstalled
Executable file
11
.local/bin/ifinstalled
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/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
|
||||||
|
pacman -Qq "$x" >/dev/null 2>&1 ||
|
||||||
|
{ notify-send "📦 $x" "must be installed for this function." && exit 1 ;}
|
||||||
|
done
|
||||||
9
.local/bin/lf-select
Executable file
9
.local/bin/lf-select
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Reads file names from stdin and selects them in lf.
|
||||||
|
|
||||||
|
while read -r file; do
|
||||||
|
[ -z "$file" ] && continue
|
||||||
|
lf -remote "send select \"$file\""
|
||||||
|
lf -remote "send toggle"
|
||||||
|
done
|
||||||
24
.local/bin/linkhandler
Executable file
24
.local/bin/linkhandler
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/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 no url given. Opens browser. For using script as $BROWSER.
|
||||||
|
[ -z "$1" ] && { "$BROWSER"; exit; }
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*twitch.tv*)
|
||||||
|
setsid -f mpv -quiet "$1" >/dev/null 2>&1 ;;
|
||||||
|
*png|*jpg|*jpe|*jpeg|*gif)
|
||||||
|
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;;
|
||||||
|
*pdf)
|
||||||
|
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && zathura "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;;
|
||||||
|
*mp3|*flac|*opus|*mp3?source*)
|
||||||
|
setsid -f tsp curl -LO "$1" >/dev/null 2>&1 ;;
|
||||||
|
*)
|
||||||
|
if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR" "$1"
|
||||||
|
else setsid -f "$BROWSER" "$1" >/dev/null 2>&1; fi ;;
|
||||||
|
esac
|
||||||
14
.local/bin/maimpick
Executable file
14
.local/bin/maimpick
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
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" ;;
|
||||||
|
"a selected area (copy)") maim -s | xclip -selection clipboard -t image/png ;;
|
||||||
|
"current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;;
|
||||||
|
"full screen (copy)") maim | xclip -selection clipboard -t image/png ;;
|
||||||
|
esac
|
||||||
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
|
||||||
|
ffmpeg -version >/dev/null || { echo >&2 "We require 'ffmpeg' but it's not installed. Install it by 'sudo pacman -S ffmpeg' Aborting."; exit 1; }
|
||||||
|
sox --version >/dev/null || { echo >&2 "We require 'sox' but it's not installed. Install it by 'sudo pacman -S sox' Aborting."; 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"
|
||||||
8
.local/bin/normalizer
Executable file
8
.local/bin/normalizer
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from charset_normalizer.cli.normalizer import cli_detect
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||||
|
sys.exit(cli_detect())
|
||||||
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="$(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 ;;
|
||||||
|
esac
|
||||||
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="youtube-dl --add-metadata"
|
||||||
|
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."
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
# Increase key speed via a rate change
|
# Increase key speed via a rate change
|
||||||
xset r rate 300 50
|
xset r rate 300 50
|
||||||
# Map the caps lock key to super...
|
# Map the caps lock key to super...
|
||||||
setxkbmap -option caps:super
|
setxkbmap -option caps:super fr
|
||||||
# But when it is pressed only once, treat it as escape.
|
# 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.
|
# Map the menu button to right super as well.
|
||||||
|
|||||||
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; }'
|
||||||
8
.local/bin/samedir
Executable file
8
.local/bin/samedir
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Open a terminal window in the same directory as the currently active window.
|
||||||
|
|
||||||
|
PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
|
||||||
|
PID="$(pstree -lpA "$PID" | tail -n 1 | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')"
|
||||||
|
cd "$(readlink /proc/"$PID"/cwd)" || return 1
|
||||||
|
"$TERMINAL"
|
||||||
124
.local/bin/slider
Executable file
124
.local/bin/slider
Executable file
@@ -0,0 +1,124 @@
|
|||||||
|
#!/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" ;;
|
||||||
|
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)
|
||||||
|
-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}" -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.
|
||||||
@@ -9,31 +9,32 @@ case $BLOCK_BUTTON in
|
|||||||
♻: stagnant charge
|
♻: stagnant charge
|
||||||
🔌: charging
|
🔌: charging
|
||||||
⚡: charged
|
⚡: charged
|
||||||
|
❗: battery very low!
|
||||||
- Scroll to change adjust xbacklight." ;;
|
- Scroll to change adjust xbacklight." ;;
|
||||||
4) xbacklight -inc 10 ;;
|
4) xbacklight -inc 10 ;;
|
||||||
5) xbacklight -dec 10 ;;
|
5) xbacklight -dec 10 ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# acpi alternative
|
# # acpi alternative
|
||||||
acpi | sed "s/Battery [0-9]: //;s/[Dd]ischarging, /🔋/;s/[Nn]ot charging, /🛑/;s/[Cc]harging, /🔌/;s/[Uu]nknown, /♻️/;s/[Ff]ull, /⚡/;s/ \(remaining\|until charged\)//"; exit
|
# acpi | sed "s/Battery [0-9]: //;s/[Dd]ischarging, /🔋/;s/[Nn]ot charging, /🛑/;s/[Cc]harging, /🔌/;s/[Uu]nknown, /♻️/;s/[Ff]ull, /⚡/;s/ \(remaining\|until charged\)//"; exit
|
||||||
done | sed 's/ *$//'
|
# done | sed 's/ *$//'
|
||||||
|
|
||||||
# Loop through all attached batteries and format the info
|
# Loop through all attached batteries and format the info
|
||||||
# for battery in /sys/class/power_supply/BAT?*; do
|
for battery in /sys/class/power_supply/BAT?*; do
|
||||||
# # If non-first battery, print a space separator.
|
# If non-first battery, print a space separator.
|
||||||
# [ -n "${capacity+x}" ] && printf " "
|
[ -n "${capacity+x}" ] && printf " "
|
||||||
# # Sets up the status and capacity
|
# Sets up the status and capacity
|
||||||
# case "$(cat "$battery/status")" in
|
case "$(cat "$battery/status")" in
|
||||||
# "Full") status="⚡" ;;
|
"Full") status="⚡" ;;
|
||||||
# "Discharging") status="🔋" ;;
|
"Discharging") status="🔋" ;;
|
||||||
# "Charging") status="🔌" ;;
|
"Charging") status="🔌" ;;
|
||||||
# "Not charging") status="🛑" ;;
|
"Not charging") status="🛑" ;;
|
||||||
# "Unknown") status="♻️" ;;
|
"Unknown") status="♻️" ;;
|
||||||
# esac
|
esac
|
||||||
# capacity=$(cat "$battery/capacity")
|
capacity=$(cat "$battery/capacity")
|
||||||
# # Will make a warn variable if discharging and low
|
# Will make a warn variable if discharging and low
|
||||||
# [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗"
|
[ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗"
|
||||||
# # Prints the info
|
# Prints the info
|
||||||
# printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
|
printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
|
||||||
# done && exit 0
|
done && printf "\\n"
|
||||||
|
|||||||
59
.local/bin/tag
Executable file
59
.local/bin/tag
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/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" ;;
|
||||||
|
*) echo "File type not implemented yet." ;;
|
||||||
|
esac
|
||||||
14
.local/bin/texclear
Executable file
14
.local/bin/texclear
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/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|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 ;;
|
||||||
|
*) printf "Give .tex file as argument.\\n" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
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."
|
||||||
26
.local/bin/unix
Executable file
26
.local/bin/unix
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#original artwork by http://www.sanderfocus.nl/#/portfolio/tech-heroes
|
||||||
|
#converted to shell by #nixers @ irc.unix.chat
|
||||||
|
|
||||||
|
cat << 'eof'
|
||||||
|
[38;5;255m,_ ,_==▄▂[0m
|
||||||
|
[38;5;255m, ▂▃▄▄▅▅[48;5;240m▅[48;5;20m▂[48;5;240m▅¾[0m. [38;5;199m/ [38;5;20m/[0m
|
||||||
|
[38;5;255m[48;5;20m▄[0m[38;5;255m[48;5;199m▆[38;5;16m[48;5;255m<´ [38;5;32m"[38;5;34m»[38;5;255m▓▓[48;5;32m▓[48;5;240m%[0m\ [38;5;199m/ [38;5;20m/ [38;5;45m/ [38;5;118m/[0m
|
||||||
|
[38;5;255m,[38;5;255m[48;5;240m▅[38;5;16m[48;5;255m7" [38;5;160m´[38;5;34m>[38;5;255m[48;5;39m▓▓[38;5;199m[48;5;255m▓[0m[38;5;255m% [38;5;20m/ [38;5;118m/ [38;5;199m> [38;5;118m/ [38;5;199m>[38;5;255m/[38;5;45m%[0m
|
||||||
|
[38;5;255m▐[48;5;240m[38;5;255m¶[48;5;240m[38;5;255m▓[48;5;255m [38;5;196m,[38;5;34m»[48;5;201m[38;5;255m▓▓[0m[38;5;255m¾´[0m [38;5;199m/[38;5;255m> %[38;5;199m/[38;5;118m%[38;5;255m/[38;5;199m/ [38;5;45m/ [38;5;199m/[0m
|
||||||
|
[38;5;255m[48;5;240m▓[48;5;255m[38;5;16m▃[48;5;16m[38;5;255m▅▅[38;5;16m[48;5;255m▅▃,,[38;5;32m▄[38;5;16m▅[38;5;255m[48;5;16m▅▅[38;5;255m[48;5;20mÆ[0m[38;5;255m\[0m[38;5;20m/[38;5;118m/[38;5;255m /[38;5;118m/[38;5;199m/[38;5;255m>[38;5;45m// [38;5;255m/[38;5;118m>[38;5;199m/ [38;5;20m/[0m
|
||||||
|
[48;5;20m[38;5;255mV[48;5;255m[38;5;16m║[48;5;20m[38;5;255m«[0m[38;5;255m¼.;[48;5;240m[38;5;255m→[48;5;255m[38;5;16m ║[0m[38;5;255m<«.,[48;5;25m[38;5;255m`[48;5;240m=[0m[38;5;20m/[38;5;199m/ [38;5;255m/>[38;5;45m/[38;5;118m/[38;5;255m%/[38;5;199m% / [38;5;20m/[0m
|
||||||
|
[38;5;20m//[48;5;255m[38;5;16m╠<´ -²,)[48;5;16m[38;5;255m(▓[48;5;255m[38;5;16m~"-[38;5;199m╝/[0m[38;5;255m¾[0m[38;5;199m/ [38;5;118m%[38;5;255m/[38;5;118m>[38;5;45m/ [38;5;118m/[38;5;199m>[0m
|
||||||
|
[38;5;20m/ / [38;5;118m/ [48;5;20m[38;5;255m▐[48;5;240m[38;5;16m%[48;5;255m -./▄▃▄[48;5;16m[38;5;255m▅[48;5;255m[38;5;16m▐[48;5;255m[38;5;16m, [38;5;199m/[48;5;199m[38;5;255m7[0m[38;5;20m/[38;5;199m/[38;5;255m;/[38;5;199m/[38;5;118m% [38;5;20m/ /[0m
|
||||||
|
[38;5;20m/ [38;5;199m/[38;5;255m/[38;5;45m/[38;5;118m/[38;5;255m[48;5;240m`[48;5;20m[38;5;255m▌[48;5;20m[38;5;255m▐[48;5;255m[38;5;16m %z[0m[38;5;255mWv xX[48;5;20m[38;5;255m▓[48;5;34m[38;5;255m▇[48;5;199m[38;255m▌[0m[38;5;20m/[38;5;199m/[38;5;255m&;[38;5;20m% [38;5;199m/ [38;5;20m/[0m
|
||||||
|
[38;5;20m/ / [38;5;255m/ [38;5;118m%[38;5;199m/[38;5;255m/%/[48;5;240m[38;5;255m¾[48;5;255m[38;5;16m½´[38;5;255m[48;5;16m▌[0m[38;5;246m▃▄[38;5;255m▄▄[38;5;246m▄▃▃[0m[48;5;16m[38;5;255m▐[38;5;255m[48;5;199m¶[48;5;20m[38;5;255m\[0m[38;5;20m/[0m[48;5;255m[38;5;240m&[0m [38;5;20m/[0m
|
||||||
|
[38;5;199m<[38;5;118m/ [38;5;45m/[38;5;255m</[38;5;118m%[38;5;255m/[38;5;45m/[38;5;255m`[48;5;16m▓[48;5;255m[38;5;16m![48;5;240m[38;5;255m%[48;5;16m[38;5;255m▓[0m[38;5;255m%[48;5;240m[38;5;255m╣[48;5;240m[38;5;255;╣[0m[38;5;255mW[0m[38;5;250mY<Y)[48;5;255m[38;5;16my&[0m[38;5;255m/`[48;5;240m\[0m
|
||||||
|
[38;5;20m/ [38;5;199m/ [38;5;199m%[38;5;255m/%[38;5;118m/[38;5;45m/[38;5;255m<[38;5;118m/[38;5;199m%[38;5;45m/[38;5;20m/[48;5;240m[38;5;255m\[38;5;16m[48;5;255mi7; ╠N[0m[38;5;246m>[38;5;255m)VY>[48;5;240m[38;5;255m7[0m[38;5;255m; [38;5;255m[48;5;240m\[0m[38;5;255m_[0m [38;5;255mUNIX IS VERY SIMPLE [38;5;45mIT JUST NEEDS A[0m
|
||||||
|
[38;5;20m/ [38;5;255m/[38;5;118m<[38;5;255m/ [38;5;45m/[38;5;255m/<[38;5;199m/[38;5;20m/[38;5;199m/[38;5;20m<[38;5;255m_/%\[38;5;255m[48;5;16m▓[48;5;255m[38;5;16m V[0m[38;5;255m%[48;5;255m[38;5;16mW[0m[38;5;255m%£)XY[0m [38;5;240m_/%[38;5;255m‾\_,[0m [38;5;45mGENIUS TO UNDERSTAND ITS SIMPLICITY[38;5;255m[0m
|
||||||
|
[38;5;199m/ [38;5;255m/ [38;5;199m/[38;5;255m/[38;5;118m%[38;5;199m/[48;5;240m[38;5;255m_,=-[48;5;20m-^[0m[38;5;255m/%/%%[48;5;255m[38;5;16m\¾%[0m[38;5;255m¶[0m[48;5;255m[38;5;16m%[0m[38;5;255m%}[0m [38;5;240m/%%%[38;5;20m%%[38;5;240m%;\,[0m
|
||||||
|
[38;5;45m%[38;5;20m/[38;5;199m< [38;5;20m/[48;5;20m[38;5;255m_/[48;5;240m [0m[38;5;255m%%%[38;5;240m%%[38;5;20m;[38;5;255mX[38;5;240m%[38;5;20m%[38;5;255m\%[38;5;240m%;, _/%%%;[38;5;20m,[38;5;240m \[0m
|
||||||
|
[38;5;118m/ [38;5;20m/ [38;5;240m%[38;5;20m%%%%[38;5;240m%;, [38;5;255m\[38;5;240m%[38;5;20m%[38;5;255ml[38;5;240m%%;// _/[38;5;20m%;,[0m [38;5;234mdmr[0m
|
||||||
|
[38;5;20m/ [38;5;240m%[38;5;20m%%;,[0m [38;5;255m<[38;5;20m;[38;5;240m\-=-/ /[0m
|
||||||
|
[38;5;20m;,[0m [38;5;240ml[0m
|
||||||
|
eof
|
||||||
14
.local/bin/vifmimg
Executable file
14
.local/bin/vifmimg
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
[ -z "$FIFO_UEBERZUG" ] && exit
|
||||||
|
|
||||||
|
readonly ID_PREVIEW="preview"
|
||||||
|
|
||||||
|
if [ "$1" = "draw" ]; then
|
||||||
|
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" [x]="$2" [y]="$3" [max_width]="$4" [max_height]="$5" [path]="${PWD}/$6") > "$FIFO_UEBERZUG"
|
||||||
|
elif [ "$1" = "videopreview" ]; then
|
||||||
|
[ ! -f "/tmp/$6.png" ] && ffmpegthumbnailer -i "${PWD}/$6" -o "/tmp/$6.png" -s 0 -q 10 &&
|
||||||
|
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" [x]="$2" [y]="$3" [max_width]="$4" [max_height]="$5" [path]="/tmp/$6.png") > "$FIFO_UEBERZUG"
|
||||||
|
else
|
||||||
|
declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") > "$FIFO_UEBERZUG"
|
||||||
|
fi
|
||||||
18
.local/bin/vu
Executable file
18
.local/bin/vu
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This is a wrapper for vifm to allow ueberzug images.
|
||||||
|
|
||||||
|
export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}"
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm "$FIFO_UEBERZUG" 2>/dev/null
|
||||||
|
pkill -P $$ 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
rm "$FIFO_UEBERZUG" 2>/dev/null
|
||||||
|
mkfifo "$FIFO_UEBERZUG"
|
||||||
|
trap cleanup EXIT
|
||||||
|
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash &
|
||||||
|
|
||||||
|
vifmimg
|
||||||
|
cleanup
|
||||||
Reference in New Issue
Block a user