summaryrefslogtreecommitdiffstats
path: root/.local
diff options
context:
space:
mode:
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/booksplit10
-rwxr-xr-x.local/bin/compiler4
-rwxr-xr-x.local/bin/cron/checkup2
-rwxr-xr-x.local/bin/cron/newsup2
-rwxr-xr-x.local/bin/dmenumount2
-rwxr-xr-x.local/bin/linkhandler2
-rwxr-xr-x.local/bin/opout4
-rwxr-xr-x.local/bin/statusbar/clock2
-rwxr-xr-x.local/bin/statusbar/cpubars44
-rwxr-xr-x.local/bin/statusbar/crypto2
-rwxr-xr-x.local/bin/statusbar/nettraf4
-rwxr-xr-x.local/bin/statusbar/price6
12 files changed, 65 insertions, 19 deletions
diff --git a/.local/bin/booksplit b/.local/bin/booksplit
index 3d0ab07..7730ac2 100755
--- a/.local/bin/booksplit
+++ b/.local/bin/booksplit
@@ -27,11 +27,13 @@ total="$(wc -l < "$2")"
while read -r x;
do
end="$(echo "$x" | cut -d' ' -f1)"
+
[ -n "$start" ] &&
echo "From $start to $end; $track $title"
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
- [ -n "$start" ] && echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn "$file" &&
- echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
+ [ -n "$start" ] && echo "Splitting \"$title\"..." &&
+ ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn -c copy "$file" &&
+ echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
title="$(echo "$x" | cut -d' ' -f 2-)"
esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
track="$((track+1))"
@@ -40,5 +42,5 @@ done < "$2"
# The last track must be done outside the loop.
echo "From $start to the end: $title"
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
-echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn "$file" &&
- echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
+echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn -c copy "$file" &&
+ echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file" \ No newline at end of file
diff --git a/.local/bin/compiler b/.local/bin/compiler
index 213013e..1892d5f 100755
--- a/.local/bin/compiler
+++ b/.local/bin/compiler
@@ -32,9 +32,9 @@ case "$ext" in
go) go run "$file" ;;
h) sudo make install ;;
m) octave "$file" ;;
- md) if command -v lowdown >/dev/null; then
+ md) if [ -x "$(command -v lowdown)" ]; then
lowdown -d nointem -e super "$file" -Tms | groff -mpdfmark -ms -kept > "$base".pdf
- elif command -v groffdown >/dev/null; then
+ elif [ -x "$(command -v groffdown)" ]; then
groffdown -i "$file" | groff > "$base.pdf"
else
pandoc "$file" --pdf-engine=xelatex -o "$base".pdf
diff --git a/.local/bin/cron/checkup b/.local/bin/cron/checkup
index 34ed61e..bf7f85d 100755
--- a/.local/bin/cron/checkup
+++ b/.local/bin/cron/checkup
@@ -2,7 +2,7 @@
# Syncs repositories and downloads updates, meant to be run as a cronjob.
-ping -q -c 1 1.1.1.1 > /dev/null || exit
+ping -q -c example.org > /dev/null || exit
notify-send "📦 Repository Sync" "Checking for package updates..."
diff --git a/.local/bin/cron/newsup b/.local/bin/cron/newsup
index 94cfd87..29f2b3c 100755
--- a/.local/bin/cron/newsup
+++ b/.local/bin/cron/newsup
@@ -3,7 +3,7 @@
# 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 1.1.1.1 > /dev/null || exit
+ping -q -c 1 example.org > /dev/null || exit
/usr/bin/notify-send "📰 Updating RSS feeds..."
diff --git a/.local/bin/dmenumount b/.local/bin/dmenumount
index 75e11b5..488522a 100755
--- a/.local/bin/dmenumount
+++ b/.local/bin/dmenumount
@@ -49,7 +49,7 @@ asktype() { \
}
anddrives=$(simple-mtpfs -l 2>/dev/null)
-usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
+usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
if [ -z "$usbdrives" ]; then
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler
index e720641..7c7e96f 100755
--- a/.local/bin/linkhandler
+++ b/.local/bin/linkhandler
@@ -17,6 +17,6 @@ case "$1" in
*mp3|*flac|*opus|*mp3?source*)
setsid -f tsp curl -LO "$1" >/dev/null 2>&1 ;;
*)
- if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1"
+ if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR" "$1"
else setsid -f "$BROWSER" "$1" >/dev/null 2>&1; fi ;;
esac
diff --git a/.local/bin/opout b/.local/bin/opout
index 23f044e..7f452df 100755
--- a/.local/bin/opout
+++ b/.local/bin/opout
@@ -4,9 +4,9 @@
# usually the pdf of a compiled document. I find this useful especially
# running from vim.
-basename="$(echo "$1" | sed 's/\.[^\/.]*$//')"
+basename="$(echo "${*}" | sed 's/\.[^\/.]*$//')"
-case "$1" in
+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 ;;
diff --git a/.local/bin/statusbar/clock b/.local/bin/statusbar/clock
index 1b43392..af50117 100755
--- a/.local/bin/statusbar/clock
+++ b/.local/bin/statusbar/clock
@@ -20,7 +20,7 @@ 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 -D ~/.config/calcurse -d3)" ;;
- 2) setsid -f "$TERMINAL" -e calcurse -D ~/.config/calcurse ;;
+ 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" ;;
diff --git a/.local/bin/statusbar/cpubars b/.local/bin/statusbar/cpubars
new file mode 100755
index 0000000..297424e
--- /dev/null
+++ b/.local/bin/statusbar/cpubars
@@ -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"
diff --git a/.local/bin/statusbar/crypto b/.local/bin/statusbar/crypto
index ef025d4..94ed949 100755
--- a/.local/bin/statusbar/crypto
+++ b/.local/bin/statusbar/crypto
@@ -36,7 +36,7 @@ printprices() { # Print/format all prices
# If currencies haven't been updated today, try to update them.
[ "$(stat -c %x "$HOME/.local/share/crypto-prices" | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
- { ping -q -c 1 1.1.1.1 >/dev/null 2>&1 && getprices || exit ;}
+ { ping -q -c 1 example.org >/dev/null 2>&1 && getprices || exit ;}
case $BLOCK_BUTTON in
1) uptime="$(date -d "$(stat -c %x "$dir")" '+%D at %T' | sed "s|$(date '+%D')|Today|")"
diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf
index ac43416..71e6fe4 100755
--- a/.local/bin/statusbar/nettraf
+++ b/.local/bin/statusbar/nettraf
@@ -19,10 +19,10 @@ update() {
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
[ -f "$cache" ] && read -r old < "$cache" || old=0
printf %d\\n "$sum" > "$cache"
- printf %d\\n $(( (sum - old) / 1024 ))
+ printf %d\\n $(( sum - old ))
}
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
-printf "🔻%dKiB 🔺%dKiB\\n" "$rx" "$tx"
+printf "🔻%4sB 🔺%4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx)
diff --git a/.local/bin/statusbar/price b/.local/bin/statusbar/price
index 3f87f7a..45b01ad 100755
--- a/.local/bin/statusbar/price
+++ b/.local/bin/statusbar/price
@@ -11,18 +11,18 @@ dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
pricefile="$dir/$1"
chartfile="$dir/$1-chart"
-updateprice() { ping -q -c 1 1.1.1.1 >/dev/null 2>&1 &&
+updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 &&
curl -s "rate.sx/1$1" > "$pricefile" &&
curl -s "rate.sx/$1$interval" > "$chartfile" ;}
[ -d "$dir" ] || mkdir -p "$dir"
[ "$(stat -c %x "$pricefile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
- updateprice
+ updateprice "$1"
case $BLOCK_BUTTON in
1) setsid "$TERMINAL" -e less -Sf "$chartfile" ;;
- 2) notify-send -u low "$3 Updating..." "Updating $2 price..." &&
+ 2) notify-send -u low "$3 Updating..." "Updating $2 price..."
updateprice "$1" && notify-send "$3 Update complete." "$2 price is now
\$$(cat "$pricefile")" ;;
3) uptime="$(date -d "$(stat -c %x "$pricefile")" '+%D at %T' | sed "s|$(date '+%D')|Today|")"