summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
author--global <ik.boikov.public@protonmail.com>2021-12-19 12:03:01 +0100
committer--global <ik.boikov.public@protonmail.com>2021-12-19 12:03:01 +0100
commit25b613f755424edad38ab7616365bb618237b9fe (patch)
tree46a18fb58fe6ae487be7568da93c813d7268e30e /scripts
parent6c02d1695a7d31e4a660f25df848f938f5f08da4 (diff)
migration to dwm; home cleanup
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/.local/bin/borg-backup72
-rwxr-xr-xscripts/.local/bin/cdmenu7
-rwxr-xr-xscripts/.local/bin/compile57
-rwxr-xr-xscripts/.local/bin/drecord123
-rwxr-xr-xscripts/.local/bin/ff-clean3
-rwxr-xr-xscripts/.local/bin/ifinstalled13
-rwxr-xr-xscripts/.local/bin/pauseallmpv10
-rwxr-xr-xscripts/.local/bin/remaps28
-rwxr-xr-xscripts/.local/bin/setbg16
-rwxr-xr-xscripts/.local/bin/statusbar/sb-battery37
-rwxr-xr-xscripts/.local/bin/statusbar/sb-clock31
-rwxr-xr-xscripts/.local/bin/statusbar/sb-cpu12
-rwxr-xr-xscripts/.local/bin/statusbar/sb-cpubars44
-rwxr-xr-xscripts/.local/bin/statusbar/sb-disk23
-rwxr-xr-xscripts/.local/bin/statusbar/sb-doppler206
-rwxr-xr-xscripts/.local/bin/statusbar/sb-forecast35
-rwxr-xr-xscripts/.local/bin/statusbar/sb-help-icon17
-rwxr-xr-xscripts/.local/bin/statusbar/sb-internet26
-rwxr-xr-xscripts/.local/bin/statusbar/sb-iplocate17
-rwxr-xr-xscripts/.local/bin/statusbar/sb-kbselect16
-rwxr-xr-xscripts/.local/bin/statusbar/sb-mailbox20
-rwxr-xr-xscripts/.local/bin/statusbar/sb-memory16
-rwxr-xr-xscripts/.local/bin/statusbar/sb-moonphase37
-rwxr-xr-xscripts/.local/bin/statusbar/sb-mpdup8
-rwxr-xr-xscripts/.local/bin/statusbar/sb-music19
-rwxr-xr-xscripts/.local/bin/statusbar/sb-nettraf29
-rwxr-xr-xscripts/.local/bin/statusbar/sb-news17
-rwxr-xr-xscripts/.local/bin/statusbar/sb-pacpackages29
-rwxr-xr-xscripts/.local/bin/statusbar/sb-popupgrade9
-rwxr-xr-xscripts/.local/bin/statusbar/sb-price50
-rwxr-xr-xscripts/.local/bin/statusbar/sb-tasks20
-rwxr-xr-xscripts/.local/bin/statusbar/sb-torrent27
-rwxr-xr-xscripts/.local/bin/statusbar/sb-volume30
-rwxr-xr-xscripts/.local/bin/sysact19
-rwxr-xr-xscripts/.local/bin/termcolors9
35 files changed, 1051 insertions, 81 deletions
diff --git a/scripts/.local/bin/borg-backup b/scripts/.local/bin/borg-backup
deleted file mode 100755
index 2ba7774..0000000
--- a/scripts/.local/bin/borg-backup
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-# Setting this, so the repo does not need to be given on the commandline:
-#export BORG_REPO=ssh://pi@192.168.3.1/media/nas/borgbackup
-export BORG_REPO=/media/wdblue-old/borgbackup
-# See the section "Passphrase notes" for more infos.
-#export BORG_PASSPHRASE='XYZl0ngandsecurepa_55_phrasea&&123'
-#export BORG_PASSCOMMAND="cat $HOME/.config/borg/keys/media_wdblue_old_borgbackup"
-# some helpers and error handling:
-info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
-trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
-info "Starting backup"
-
-# Backup the most important directories into an archive named after
-# the machine this script is currently running on:
-
-borg create \
- --progress \
- --filter AME \
- --list \
- --stats \
- --show-rc \
- --compression zlib,9 \
- --exclude-caches \
- --exclude='*build*' \
- --exclude='*svn*' \
- --exclude='*temp*' \
- --exclude='*tmp*' \
- --exclude='*git*' \
- --exclude='*log*' \
- --exclude='*old*' \
- --exclude='*bak*' \
- \
- ::'{hostname}-{now}' \
- /media/wdblue/dox \
- /media/wdblue/dox-arch \
- /media/wdblue/vid/gachi \
- /media/wdblue/pix \
- /media/wdblue/tracks \
- /media/wdblue/sync \
-
-backup_exit=$?
-
-info "Pruning repository"
-
-# Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly
-# archives of THIS machine. The '{hostname}-' prefix is very important to
-# limit prune's operation to this machine's archives and not apply to
-# other machines' archives also:
-
-borg prune \
- --list \
- --prefix '{hostname}-' \
- --show-rc \
- --keep-daily 7 \
- --keep-weekly 4 \
- --keep-monthly 6 \
-
-prune_exit=$?
-
-# use highest exit code as global exit code
-
-global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
-
-if [ ${global_exit} -eq 0 ]; then
- info "Backup and Prune finished successfully"
-elif [ ${global_exit} -eq 1 ]; then
- info "Backup and/or Prune finished with warnings"
-else
- info "Backup and/or Prune finished with errors"
-fi
-
-exit ${global_exit}
diff --git a/scripts/.local/bin/cdmenu b/scripts/.local/bin/cdmenu
index 67d9b7a..e1a4fdf 100755
--- a/scripts/.local/bin/cdmenu
+++ b/scripts/.local/bin/cdmenu
@@ -1,3 +1,8 @@
#! /bin/bash
# colored dmenu for use in scripts
-dmenu -nb '#020e1d' -nf '#00b1ff' -sb '#00b1ff' -sf '#020e1d' "$@"
+
+getcolor() {
+ xrdb -query | awk '/*.color'"$1":'/ { print substr($2,2) }'
+}
+# sync that with dwm's config.h!
+dmenu -nb "#$(getcolor 0)" -nf "#$(getcolor 4)" -sb "#$(getcolor 4)" -sf "#$(getcolor 0)" "$@"
diff --git a/scripts/.local/bin/compile b/scripts/.local/bin/compile
new file mode 100755
index 0000000..faf37c9
--- /dev/null
+++ b/scripts/.local/bin/compile
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+# This script will compile or run another finishing operation on a document. I
+# have this script run via vim.
+#
+# Compiles .tex. groff (.mom, .ms), .rmd, .md, .org. Opens .sent files as sent
+# presentations. Runs scripts based on 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 1
+
+textype() { \
+ command="pdflatex"
+ ( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex"
+ $command --output-directory="$dir" "$base" &&
+ grep -qi addbibresource "$file" &&
+ biber --input-directory "$dir" "$base" &&
+ $command --output-directory="$dir" "$base" &&
+ $command --output-directory="$dir" "$base"
+}
+
+case "$ext" in
+ # Try to keep these cases in alphabetical order.
+ [0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
+ c) cc "$file" -o "$base" && "$base" ;;
+ cpp) g++ "$file" -o "$base" && "$base" ;;
+ cs) mcs "$file" && mono "$base".exe ;;
+ go) go run "$file" ;;
+ h) sudo make install ;;
+ java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
+ m) octave "$file" ;;
+ md) if [ -x "$(command -v lowdown)" ]; then
+ lowdown -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 -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
diff --git a/scripts/.local/bin/drecord b/scripts/.local/bin/drecord
new file mode 100755
index 0000000..ee70830
--- /dev/null
+++ b/scripts/.local/bin/drecord
@@ -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)" | cdmenu -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" | cdmenu -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
diff --git a/scripts/.local/bin/ff-clean b/scripts/.local/bin/ff-clean
new file mode 100755
index 0000000..b20805f
--- /dev/null
+++ b/scripts/.local/bin/ff-clean
@@ -0,0 +1,3 @@
+#!/bin/sh
+# remove firefox extensions
+sudo rm /usr/lib/firefox/browser/features/*.xpi -v
diff --git a/scripts/.local/bin/ifinstalled b/scripts/.local/bin/ifinstalled
new file mode 100755
index 0000000..b81081b
--- /dev/null
+++ b/scripts/.local/bin/ifinstalled
@@ -0,0 +1,13 @@
+#!/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
+ if ! which "$x" >/dev/null 2>&1 && ! apt -qq list "$x" >/dev/null 2>&1; then
+ notify-send "πŸ“¦ $x" "must be installed for this function." && exit 1 ;
+ fi
+done
diff --git a/scripts/.local/bin/pauseallmpv b/scripts/.local/bin/pauseallmpv
new file mode 100755
index 0000000..d69a414
--- /dev/null
+++ b/scripts/.local/bin/pauseallmpv
@@ -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
diff --git a/scripts/.local/bin/remaps b/scripts/.local/bin/remaps
index 0b780ab..262b70e 100755
--- a/scripts/.local/bin/remaps
+++ b/scripts/.local/bin/remaps
@@ -6,9 +6,29 @@
xset r rate 200 75
# Map the menu button to right super as well.
-xmodmap -e 'keycode 135 = Super_R'
+#xmodmap -e 'keycode 135 = Super_R'
# external keyboard Alt_R may be mapped to Multi_Key instead of ISO_Level3_Shift, which breaks French QWERTY layout
-xmodmap -e "keycode 64 = Alt_L"
-#xmodmap -e "keycode 64 = ISO_Level3_Shift"
-xmodmap -e "keycode 108 = ISO_Level3_Shift"
+#xmodmap -e "keycode 64 = Alt_L"
+#xmodmap -e "keycode 108 = ISO_Level3_Shift"
+
+
+# reset all options
+/usr/bin/setxkbmap -option
+
+# 105-key generic keyboard
+# utilize french and russian layouts
+# use qwerty instead of aqerty for french layout
+# toggle layout with shift+caps
+# french accents on right alt
+# compose on right ctrl
+# non-breaking spaces on right alt + space
+# kill X on left ctrl + left alt + backspace
+/usr/bin/setxkbmap -model pc105 \
+ -layout fr,ru \
+ -variant us, \
+ -option grp:shift_caps_toggle \
+ -option lv3:ralt_switch \
+ -option compose:rctrl \
+ -option nbsp:level3n \
+ -option terminate:ctrl_alt_bkspc
diff --git a/scripts/.local/bin/setbg b/scripts/.local/bin/setbg
index 397646d..795b28f 100755
--- a/scripts/.local/bin/setbg
+++ b/scripts/.local/bin/setbg
@@ -7,10 +7,13 @@
# If wal is installed, also generates a colorscheme.
# Location of link to wallpaper link.
-bgloc="${XDG_DATA_HOME:-$HOME/.local/share/wallpapers}/bg"
+bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/wallpapers/bg"
-trueloc="$(readlink -f "$1")" &&
+# 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." ;;
@@ -18,8 +21,13 @@ case "$(file --mime-type -b "$trueloc")" in
esac
# If pywal is installed, use it.
-command -v wal >/dev/null 2>&1 &&
- wal -i "$trueloc" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1 &&
+if command -v wal >/dev/null 2>&1 ; then
+ wal -i "$(readlink -f $bgloc)" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1 &&
pidof dwm >/dev/null && xdotool key super+F12
+# 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"
diff --git a/scripts/.local/bin/statusbar/sb-battery b/scripts/.local/bin/statusbar/sb-battery
new file mode 100755
index 0000000..93cbe08
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-battery
@@ -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"
diff --git a/scripts/.local/bin/statusbar/sb-clock b/scripts/.local/bin/statusbar/sb-clock
new file mode 100755
index 0000000..33f5b25
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-clock
@@ -0,0 +1,31 @@
+#!/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"
+
+date "+%d/%m/%Y (%a) %H:%M:%S"
diff --git a/scripts/.local/bin/statusbar/sb-cpu b/scripts/.local/bin/statusbar/sb-cpu
new file mode 100755
index 0000000..1572b52
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-cpu
@@ -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}'
diff --git a/scripts/.local/bin/statusbar/sb-cpubars b/scripts/.local/bin/statusbar/sb-cpubars
new file mode 100755
index 0000000..cfa54e4
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-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/scripts/.local/bin/statusbar/sb-disk b/scripts/.local/bin/statusbar/sb-disk
new file mode 100755
index 0000000..e947509
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-disk
@@ -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}')"
diff --git a/scripts/.local/bin/statusbar/sb-doppler b/scripts/.local/bin/statusbar/sb-doppler
new file mode 100755
index 0000000..dc93db0
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-doppler
@@ -0,0 +1,206 @@
+#!/bin/sh
+
+# Show a Doppler RADAR of an American 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 "Northeast
+Southeast
+PacNorthWest
+PacSouthWest
+UpperMissVly
+SouthMissVly
+SouthPlains
+NorthRockies
+SouthRockies
+Alaska
+Carib
+Hawaii
+CentGrLakes
+Conus-Large
+KABR: Aberdeen, SD
+KBIS: Bismarck, ND
+KFTG: Denver/Boulder, CO
+KDMX: Des Moines, IA
+KDTX: Detroit, MI
+KDDC: Dodge City, KS
+KDLH: Duluth, MN
+KCYS: Cheyenne, WY
+KLOT: Chicago, IL
+KGLD: Goodland, KS
+KUEX: Hastings, NE
+KGJX: Grand Junction, CO
+KGRR: Grand Rapids, MI
+KMVX: Fargo/Grand Forks, ND
+KGRB: Green Bay, WI
+KIND: Indianapolis, IN
+KJKL: Jackson, KY
+KARX: La Crosse, WI
+KILX: Lincoln/Central Illinois, IL
+KLVX: Louisville, KY
+KMQT: Marquette
+KMKX: Milwaukee, WI
+KMPX: Minneapolis, MN
+KAPX: Gaylord/Alpena, MI
+KLNX: North Platte, NE
+KIWX: N. Webster/Northern, IN
+KOAX: Omaha, NE
+KPAH: Paducah, KY
+KEAX: Pleasant Hill, MO
+KPUX: Pueblo, CO
+KDVN: Quad Cities, IA
+KUDX: Rapid City, SD
+KRIW: Riverton, WY
+KSGF: Springfield, MO
+KLSX: St. LOUIS, MO
+KFSD: Sioux Falls, IA
+KTWX: Topeka, KS
+KICT: Wichita, KS
+KVWX: Paducah, KY
+ICAO: Responsible Wfo
+KLTX: WILMINGTON, NC
+KCCX: State College/Central, PA
+KLWX: Sterling, VA
+KFCX: Blacksburg/Roanoke, VA
+KRAX: Raleigh/Durham, NC
+KGYX: Portland, ME
+KDIX: Mt Holly/Philadelphia, PA
+KPBZ: Pittsburgh, PA
+KAKQ: Wakefield, VA
+KMHX: Morehead City, NC
+KGSP: Greer/Greenville/Sprtbg, SC
+KILN: Wilmington/Cincinnati, OH
+KCLE: Cleveland, OH
+KCAE: Columbia, SC
+KBGM: Binghamton, NY
+KENX: Albany, NY
+KBUF: Buffalo, NY
+KCXX: Burlington, VT
+KCBW: Caribou, ME
+KBOX: Boston /Taunton, MA
+KOKX: New York City, NY
+KCLX: Charleston, SC
+KRLX: Charleston, WV
+ICAO: Responsible WFO
+KBRO: Brownsville, TX
+KABX: Albuquerque, NM
+KAMA: Amarillo, TX
+KFFC: Peachtree City/Atlanta, GA
+KEWX: Austin/Sanantonio, TX
+KBMX: Birmingham, AL
+KCRP: Corpus Christi, TX
+KFWS: Dallas / Ft. Worth, TX
+KEPZ: El Paso, TX
+KHGX: Houston/ Galveston, TX
+KJAX: Jacksonville, FL
+KBYX: Key West, FL
+KMRX: Morristown/knoxville, TN
+KLBB: Lubbock, TX
+KLZK: Little Rock, AR
+KLCH: Lake Charles, LA
+KOHX: Nashville, TN
+KMLB: Melbourne, FL
+KNQA: Memphis, TN
+KAMX: Miami, FL
+KMAF: Midland/odessa, TX
+KTLX: Norman, OK
+KHTX: Huntsville, AL
+KMOB: Mobile, AL
+KTLH: Tallahassee, FL
+KTBW: Tampa Bay Area, FL
+KSJT: San Angelo, TX
+KINX: Tulsa, OK
+KSRX: Tulsa, OK
+KLIX: New Orleans/slidell, LA
+KDGX: Jackson, MS
+KSHV: Shreveport, LA
+ICAO: Responsible WFO
+KLGX: Seattle / Tacoma, WA
+KOTX: Spokane, WA
+KEMX: Tucson, AZ
+KYUX: Phoenix, AZ
+KNKX: San Diego, CA
+KMUX: Monterey/san Francisco, CA
+KHNX: San Joaquin/hanford, CA
+KSOX: San Diego, CA
+KATX: Seattle / Tacoma, WA
+KIWA: Phoenix, AZ
+KRTX: Portland, OR
+KSFX: Pocatello, ID
+KRGX: Reno, NV
+KDAX: Sacramento, CA
+KMTX: Salt Lake City, UT
+KPDT: Pendleton, OR
+KMSX: Missoula, MT
+KESX: Las Vegas, NV
+KVTX: Los Angeles, CA
+KMAX: Medford, OR
+KFSX: Flagstaff, AZ
+KGGW: Glasgow, MT
+KLRX: Elko, NV
+KBHX: Eureka, CA
+KTFX: Great Falls, MT
+KCBX: Boise, ID
+KBLX: Billings, MT
+KICX: Salt Lake City, UT
+ICAO: Responsible Wfo W/ MSCF
+PABC: Anchorage, AK
+PAPD: Fairbanks, AK
+PHKM: Honolulu, HI
+PAHG: Anchorage, AK
+PAKC: Anchorage, AK
+PAIH: Anchorage, AK
+PHMO: Honolulu, HI
+PAEC: Fairbanks, AK
+TJUA: San Juan, PR
+PACG: Juneau, AK
+PHKI: Honolulu, HI
+PHWA: Honolulu, HI
+ICAO: Responsible Wfo W/ MSCF
+KFDR: Norman, OK
+PGUA: Guam
+KBBX: Sacramento, CA
+KFDX: Albuquerque, NM
+KGWX: Jackson, MS
+KDOX: Wakefield, VA
+KDYX: San Angelo, TX
+KEYX: Las Vegas, NV
+KEVX: Mobile, AL
+KHPX: Paducah, KY
+KTYX: Burlington, VT
+KGRK: Dallas / Ft. Worth, TX
+KPOE: Lake Charles, LA
+KEOX: Tallahassee, FL
+KHDX: El Paso, TX
+KDFX: San Antonio, TX
+KMXX: Birmingham, AL
+KMBX: Bismarck, ND
+KVAX: Jacksonville, FL
+KJGX: Peachtree City/atlanta, GA
+KVNX: Norman, OK
+KVBX: Vandenberg Afb: Orcutt, CA" | dmenu -r -i -l 50 -p "Select a National Weather Service radar to use as default:" | sed "s/:.*//" | tr "[:lower:]" "[:upper:]")"
+
+# Sanity check of selection and ensure user did not escape.
+echo "$chosen" | grep -q "^[A-Z]\+$" && echo "$chosen" > "$radarloc" ;}
+
+getdoppler() {
+ loc="$(cat "$radarloc")"
+ notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc."
+ curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;}
+
+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 change RADAR location.
+After $secs seconds, new clicks will also automatically update the doppler RADAR." ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+echo πŸ—ΊοΈ
diff --git a/scripts/.local/bin/statusbar/sb-forecast b/scripts/.local/bin/statusbar/sb-forecast
new file mode 100755
index 0000000..1a625bd
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-forecast
@@ -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_DATA_HOME:-$HOME/.local/share}/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
diff --git a/scripts/.local/bin/statusbar/sb-help-icon b/scripts/.local/bin/statusbar/sb-help-icon
new file mode 100755
index 0000000..8fa4a52
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-help-icon
@@ -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 "❓"
diff --git a/scripts/.local/bin/statusbar/sb-internet b/scripts/.local/bin/statusbar/sb-internet
new file mode 100755
index 0000000..94b7da2
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-internet
@@ -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)"
diff --git a/scripts/.local/bin/statusbar/sb-iplocate b/scripts/.local/bin/statusbar/sb-iplocate
new file mode 100755
index 0000000..2c70b08
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-iplocate
@@ -0,0 +1,17 @@
+#!/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/;.*//"
+
+locaddr=$(hostname -I | awk '{print $1}')
+echo $locaddr
+
+case $BLOCK_BUTTON in
+ 1) notify-send "$(curl ifconfig.me 2>/dev/null)"
+esac
diff --git a/scripts/.local/bin/statusbar/sb-kbselect b/scripts/.local/bin/statusbar/sb-kbselect
new file mode 100755
index 0000000..f0c923f
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-kbselect
@@ -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"
diff --git a/scripts/.local/bin/statusbar/sb-mailbox b/scripts/.local/bin/statusbar/sb-mailbox
new file mode 100755
index 0000000..2132184
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-mailbox
@@ -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"
diff --git a/scripts/.local/bin/statusbar/sb-memory b/scripts/.local/bin/statusbar/sb-memory
new file mode 100755
index 0000000..b238c74
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-memory
@@ -0,0 +1,16 @@
+#!/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
+
+RAM=$(free --mebi | sed -n '2{p;q}' | awk '{printf ("%2.1f/%2.1f\n", ( $3 / 1024), ($2 / 1024))}')
+
+swap=$(free --mebi | sed -n '3{p;q}' | awk '{printf ("%2.1f/%2.1f\n", ( $3 / 1024), ($2 / 1024))}')
+
+echo "$RAM $swap GiB"
diff --git a/scripts/.local/bin/statusbar/sb-moonphase b/scripts/.local/bin/statusbar/sb-moonphase
new file mode 100755
index 0000000..fab8b4d
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-moonphase
@@ -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
diff --git a/scripts/.local/bin/statusbar/sb-mpdup b/scripts/.local/bin/statusbar/sb-mpdup
new file mode 100755
index 0000000..af81a7d
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-mpdup
@@ -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
diff --git a/scripts/.local/bin/statusbar/sb-music b/scripts/.local/bin/statusbar/sb-music
new file mode 100755
index 0000000..7ea7032
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-music
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+filter() { mpc | sed "/^volume:/d;s/\\&/&amp;/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
diff --git a/scripts/.local/bin/statusbar/sb-nettraf b/scripts/.local/bin/statusbar/sb-nettraf
new file mode 100755
index 0000000..eb7a73b
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-nettraf
@@ -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=${XDG_CACHE_HOME:-$HOME/.cache}/${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) $(numfmt --to=iec $tx)
diff --git a/scripts/.local/bin/statusbar/sb-news b/scripts/.local/bin/statusbar/sb-news
new file mode 100755
index 0000000..fe701db
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-news
@@ -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)"
diff --git a/scripts/.local/bin/statusbar/sb-pacpackages b/scripts/.local/bin/statusbar/sb-pacpackages
new file mode 100755
index 0000000..37ebed3
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-pacpackages
@@ -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"
diff --git a/scripts/.local/bin/statusbar/sb-popupgrade b/scripts/.local/bin/statusbar/sb-popupgrade
new file mode 100755
index 0000000..29d6230
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-popupgrade
@@ -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 _
diff --git a/scripts/.local/bin/statusbar/sb-price b/scripts/.local/bin/statusbar/sb-price
new file mode 100755
index 0000000..42c84c1
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-price
@@ -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")"
diff --git a/scripts/.local/bin/statusbar/sb-tasks b/scripts/.local/bin/statusbar/sb-tasks
new file mode 100755
index 0000000..586300e
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-tasks
@@ -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"
diff --git a/scripts/.local/bin/statusbar/sb-torrent b/scripts/.local/bin/statusbar/sb-torrent
new file mode 100755
index 0000000..6527005
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-torrent
@@ -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
diff --git a/scripts/.local/bin/statusbar/sb-volume b/scripts/.local/bin/statusbar/sb-volume
new file mode 100755
index 0000000..3cfdc45
--- /dev/null
+++ b/scripts/.local/bin/statusbar/sb-volume
@@ -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%"
diff --git a/scripts/.local/bin/sysact b/scripts/.local/bin/sysact
new file mode 100755
index 0000000..f12bfa1
--- /dev/null
+++ b/scripts/.local/bin/sysact
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# A dmenu wrapper script for system functions.
+case "$(readlink -f /sbin/init)" in
+ *systemd*) ctl='systemctl' ;;
+ *) ctl='loginctl' ;;
+esac
+
+case "$(printf "πŸ”’ lock\nπŸšͺ leave dwm\n♻️ renew dwm\n🐻 hibernate\nπŸ’€ sleep\nπŸ”ƒ reboot\nπŸ–₯️shutdown\nπŸ“Ί display off" | cdmenu -i -p 'Action: ')" in
+ 'πŸ”’ lock') slock ;;
+ 'πŸšͺ leave dwm') kill -TERM "$(pgrep -u "$USER" "\bdwm$")" ;;
+ '♻️ renew dwm') kill -HUP "$(pgrep -u "$USER" "\bdwm$")" ;;
+ '🐻 hibernate') slock $ctl hibernate ;;
+ 'πŸ’€ sleep') slock $ctl suspend ;;
+ 'πŸ”ƒ reboot') $ctl reboot ;;
+ 'πŸ–₯️shutdown') $ctl poweroff ;;
+ 'πŸ“Ί display off') xset dpms force off ;;
+ *) exit 1 ;;
+esac
diff --git a/scripts/.local/bin/termcolors b/scripts/.local/bin/termcolors
new file mode 100755
index 0000000..f72e18d
--- /dev/null
+++ b/scripts/.local/bin/termcolors
@@ -0,0 +1,9 @@
+for x in {0..8}; do
+ for i in {30..37}; do
+ for a in {40..47}; do
+ echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "
+ done
+ echo
+ done
+done
+echo ""