aboutsummaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
authorawy <awy@awy.one>2024-11-28 17:49:11 +0300
committerawy <awy@awy.one>2024-11-28 17:49:11 +0300
commitabeb2dcdf2f2e6ca3ed1836d8cf3d6edf93129f3 (patch)
treeb67df3bfdaeddf4165361899053cb4c74d2681e5 /.local/bin
upload
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/bookmarks142
-rwxr-xr-x.local/bin/cron/checkup18
-rwxr-xr-x.local/bin/cron/newsup16
-rwxr-xr-x.local/bin/linkhandler26
-rwxr-xr-x.local/bin/reloadsingbox3
-rwxr-xr-x.local/bin/start-pipewire7
-rwxr-xr-x.local/bin/statusbar/sb-clock29
-rwxr-xr-x.local/bin/statusbar/sb-doppler22
-rwxr-xr-x.local/bin/statusbar/sb-forecast53
-rwxr-xr-x.local/bin/statusbar/sb-internet43
-rwxr-xr-x.local/bin/statusbar/sb-mailbox20
-rwxr-xr-x.local/bin/statusbar/sb-memory12
-rwxr-xr-x.local/bin/statusbar/sb-microphone37
-rwxr-xr-x.local/bin/statusbar/sb-nettraf29
-rwxr-xr-x.local/bin/statusbar/sb-news17
-rwxr-xr-x.local/bin/statusbar/sb-pacpackages29
-rwxr-xr-x.local/bin/statusbar/sb-popupgrade9
-rwxr-xr-x.local/bin/statusbar/sb-volume39
-rwxr-xr-x.local/bin/sysact26
19 files changed, 577 insertions, 0 deletions
diff --git a/.local/bin/bookmarks b/.local/bin/bookmarks
new file mode 100755
index 0000000..444b251
--- /dev/null
+++ b/.local/bin/bookmarks
@@ -0,0 +1,142 @@
+#!/bin/dash
+
+URLQUERY_FILE="${HOME}/.local/share/urlquery"
+ACTION_MENU="@@"
+
+CLIPBOARD() {
+ wl-paste
+}
+
+DMENU() {
+ bemenu -i -l "${1}" -p "${2}"
+}
+
+error_notify() {
+ notify-send "${1}"
+ exit "1"
+}
+
+ensure_file_exists() {
+ [ -f "${URLQUERY_FILE}" ] || {
+ notify-send "${URLQUERY_FILE} does not exist. Creating it now."
+ printf "SearXNG=https://searx.tiekoetter.com/search?q=\n" > "${URLQUERY_FILE}"
+ }
+}
+
+get_selection() {
+ cut -d= -f1 "${URLQUERY_FILE}" | DMENU "${LINE_COUNT}" "Bookmarks"
+}
+
+update_file() {
+ pattern="${1}"
+ replacement="${2}"
+
+ sed "/${pattern}/c\\${replacement}" "${URLQUERY_FILE}" > "${URLQUERY_FILE}.tmp" &&
+ mv "${URLQUERY_FILE}.tmp" "${URLQUERY_FILE}" ||
+ error_notify "Failed to update the file."
+}
+
+is_valid_url() {
+ printf "%s\n" "${1}" | grep -qE "^https?://[^[:space:]/?#][^[:space:]]+$"
+}
+
+add_bookmark() {
+ URL="$(CLIPBOARD)"
+
+ is_valid_url "${URL}" || error_notify "The clipboard content is not a valid URL."
+
+ grep -q "=${URL}$" "${URLQUERY_FILE}" &&
+ notify-send "The URL is already in the list." && return
+
+ NAME="$(printf "" | DMENU "0" "Name")"
+
+ [ -n "${NAME}" ] && printf "%s\n" "${NAME}=${URL}" >> "${URLQUERY_FILE}" &&
+ notify-send "'${NAME}' is bookmarked."
+}
+
+delete_bookmark() {
+ NAME="$(get_selection)"
+
+ [ -z "${NAME}" ] && error_notify "Failed to delete the bookmark." && return
+
+ sed "/^${NAME}=/d" "${URLQUERY_FILE}" > "${URLQUERY_FILE}.tmp"
+ mv "${URLQUERY_FILE}.tmp" "${URLQUERY_FILE}"
+
+ [ -s "${URLQUERY_FILE}" ] && grep -qE "\S" "${URLQUERY_FILE}" || rm "${URLQUERY_FILE}"
+
+ notify-send "'${NAME}' is deleted."
+}
+
+edit_name() {
+ OLD_NAME="${1}"
+ NEW_NAME="$(printf "" | DMENU "0" "New Name")"
+
+ [ -z "${NEW_NAME}" ] && return
+
+ URL="$(grep "^${OLD_NAME}=" "${URLQUERY_FILE}" | cut -d= -f2)"
+
+ update_file "^${OLD_NAME}=" "${NEW_NAME}=${URL}"
+}
+
+edit_url() {
+ NAME="${1}"
+ NEW_URL="$(echo "" | DMENU "0" "New URL")"
+
+ [ -z "${NEW_URL}" ] && return
+
+ update_file "^${NAME}=.*" "${NAME}=${NEW_URL}"
+}
+
+edit_bookmark() {
+ NAME="$(get_selection)"
+
+ [ -z "${NAME}" ] && error_notify "Failed to edit the bookmark." && return
+
+ FIELD="$(printf "Name\nURL\n" | DMENU "2" "Edit")"
+
+ case "${FIELD}" in
+ "Name")edit_name "${NAME}";;
+ "URL")edit_url "${NAME}"
+ esac
+
+ notify-send "'${NAME}' is updated."
+}
+
+open_bookmark() {
+ URL="$(grep "^${SELECTION}=" "${URLQUERY_FILE}" | cut -d= -f2-)"
+
+ [ -z "${URL}" ] && notify-send "Bookmark not found." && exit "1"
+
+ case "${URL}" in
+ *"search"* | *"wiki"* | *"packages"* | *"chatgpt"*) QUERY="$(echo "" | DMENU "0" "Search")"
+ URL="${URL}${QUERY}"
+ ;;
+ esac
+
+ "${BROWSER}" "${URL}" || notify-send "Failed to open the URL."
+}
+
+ensure_file_exists
+
+LINE_COUNT="$(wc -l < "${URLQUERY_FILE}")"
+
+[ "${LINE_COUNT}" -ge "15" ] && LINE_COUNT="15"
+
+SELECTION="$(get_selection)"
+
+[ -z "${SELECTION}" ] && exit
+
+case "${SELECTION}" in
+ "${ACTION_MENU}")
+ ACTION="$(printf "Add\nDelete\nEdit\n" | DMENU "3" "Action")"
+
+ case "${ACTION}" in
+ "Add") add_bookmark ;;
+ "Delete") delete_bookmark ;;
+ "Edit") edit_bookmark ;;
+ esac
+ ;;
+ *)
+ open_bookmark
+ ;;
+esac
diff --git a/.local/bin/cron/checkup b/.local/bin/cron/checkup
new file mode 100755
index 0000000..387c04e
--- /dev/null
+++ b/.local/bin/cron/checkup
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Syncs repositories and downloads updates, meant to be run as a cronjob.
+export DISPLAY=':0'
+
+notify-send "πŸ“¦ Repository Sync" "Checking for package updates..."
+
+doas pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
+
+Check your internet connection, if pacman is already running, or run update manually to see errors."
+pkill -RTMIN+8 "${STATUSBAR:-i3blocks}"
+
+if pacman -Qu | grep -v "\[ignored\]"
+then
+ notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (πŸ“¦) for update."
+else
+ notify-send "πŸ“¦ Repository Sync" "Sync complete. No new packages for update."
+fi
diff --git a/.local/bin/cron/newsup b/.local/bin/cron/newsup
new file mode 100755
index 0000000..dd85c9f
--- /dev/null
+++ b/.local/bin/cron/newsup
@@ -0,0 +1,16 @@
+#!/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.
+export DISPLAY=':0'
+
+/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:-i3blocks}"
+/usr/bin/newsboat -x reload
+rm -f /tmp/newsupdate
+pkill -RTMIN+6 "${STATUSBAR:-i3blocks}"
+/usr/bin/notify-send "πŸ“° RSS feed update complete."
diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler
new file mode 100755
index 0000000..17adc30
--- /dev/null
+++ b/.local/bin/linkhandler
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Feed script a url or file location.
+# If an image, it will view in nsxiv,
+# if a video or gif, it will view in mpv
+# if a music file or pdf, it will download,
+# otherwise it opens link in browser.
+
+if [ -z "$1" ]; then
+ url="$(xclip -o)"
+else
+ url="$1"
+fi
+
+case "$url" in
+ *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtube.com/shorts*|*youtu.be*|*youtube.com/v/*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*)
+ setsid -f mpv -quiet "$url" >/dev/null 2>&1 ;;
+ *png|*jpg|*jpe|*jpeg|*gif|*webp)
+ curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && imv "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
+ *pdf|*cbz|*cbr)
+ curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
+ *mp3|*flac|*opus|*mp3?source*)
+ qndl "$url" 'curl -LO' >/dev/null 2>&1 ;;
+ *)
+ [ -f "$url" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$url" >/dev/null 2>&1 || setsid -f "$BROWSER" "$url" >/dev/null 2>&1
+esac
diff --git a/.local/bin/reloadsingbox b/.local/bin/reloadsingbox
new file mode 100755
index 0000000..731c618
--- /dev/null
+++ b/.local/bin/reloadsingbox
@@ -0,0 +1,3 @@
+#!/bin/sh
+killall sing-box
+setsid -f sing-box -c /mnt/ssd/settings/config.json run
diff --git a/.local/bin/start-pipewire b/.local/bin/start-pipewire
new file mode 100755
index 0000000..e883493
--- /dev/null
+++ b/.local/bin/start-pipewire
@@ -0,0 +1,7 @@
+#!/bin/sh
+killall pipewire
+killall pipewire-pulse
+killall wireplumber
+setsid -f pipewire
+setsid -f pipewire-pulse
+setsid -f wireplumber
diff --git a/.local/bin/statusbar/sb-clock b/.local/bin/statusbar/sb-clock
new file mode 100755
index 0000000..56d15d3
--- /dev/null
+++ b/.local/bin/statusbar/sb-clock
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+clock=$(date '+%I')
+
+case "$clock" in
+ "00") icon="πŸ•›" ;;
+ "01") icon="πŸ•" ;;
+ "02") icon="πŸ•‘" ;;
+ "03") icon="πŸ•’" ;;
+ "04") icon="πŸ•“" ;;
+ "05") icon="πŸ•”" ;;
+ "06") icon="πŸ••" ;;
+ "07") icon="πŸ•–" ;;
+ "08") icon="πŸ•—" ;;
+ "09") icon="πŸ•˜" ;;
+ "10") icon="πŸ•™" ;;
+ "11") icon="πŸ•š" ;;
+ "12") icon="πŸ•›" ;;
+esac
+
+case $BLOCK_BUTTON in
+ 1) notify-send "This Month" "$(cal | sed "s/\<$(date +'%e'|tr -d ' ')\>/<b><span color='red'>&<\/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" ;;
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+date "+%Y %b %d (%a) $icon %H:%M"
diff --git a/.local/bin/statusbar/sb-doppler b/.local/bin/statusbar/sb-doppler
new file mode 100755
index 0000000..f673fb3
--- /dev/null
+++ b/.local/bin/statusbar/sb-doppler
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Show a Doppler RADAR of a user's preferred location.
+secs=600 # Download a new doppler radar if one hasn't been downloaded in $secs seconds.
+radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar"
+doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif"
+
+getdoppler() { curl -sL https://meteoinfo.ru/hmc-output/rmap/phenomena.gif > "$doppler" ;}
+
+showdoppler() { setsid -f mpv "$doppler" > /dev/null ;}
+
+case $BLOCK_BUTTON in
+ 1) [ $(($(date '+%s') - $(stat -c %Y "$doppler"))) -gt "$secs" ] && getdoppler
+ showdoppler ;;
+ 2) getdoppler && showdoppler ;;
+ 3) notify-send "πŸ—ΊοΈ Doppler RADAR module" "\- Left click for local Doppler RADAR.
+- Middle click to update RADAR location.
+After $secs seconds, new clicks will also automatically update the doppler RADAR." ;;
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+echo πŸŒ…
diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast
new file mode 100755
index 0000000..d0e5326
--- /dev/null
+++ b/.local/bin/statusbar/sb-forecast
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# Displays today's precipication chance (β˜”), and daily low (πŸ₯Ά) and high (🌞).
+# Usually intended for the statusbar.
+
+url="${WTTRURL:-wttr.in}"
+weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport"
+
+# Get a weather report from 'wttr.in' and save it locally.
+getforecast() { timeout --signal=1 2s curl -sf "$url/$LOCATION" > "$weatherreport" || exit 1; }
+
+# Forecast should be updated only once a day.
+checkforecast() {
+ [ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null |
+ cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ]
+}
+
+getprecipchance() {
+ echo "$weatherdata" | sed '16q;d' | # Extract line 16 from file
+ grep -wo "[0-9]*%" | # Find a sequence of digits followed by '%'
+ sort -rn | # Sort in descending order
+ head -1q # Extract first line
+}
+
+getdailyhighlow() {
+ echo "$weatherdata" | sed '13q;d' | # Extract line 13 from file
+ grep -o "m\\([-+]\\)*[0-9]\\+" | # Find temperatures in the format "m<signed number>"
+ sed 's/[+m]//g' | # Remove '+' and 'm'
+ sort -g | # Sort in ascending order
+ sed -e 1b -e '$!d' # Extract the first and last lines
+}
+
+readfile() { weatherdata="$(cat "$weatherreport")" ;}
+
+showweather() {
+ readfile
+ printf "rain: %s min: %sΒ° max: %sΒ°\n" "$(getprecipchance)" $(getdailyhighlow)
+}
+
+case $BLOCK_BUTTON in
+ 1) setsid -f "$TERMINAL" -e less -Sfr "$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" ;;
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+checkforecast || getforecast
+
+showweather
diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet
new file mode 100755
index 0000000..07774e0
--- /dev/null
+++ b/.local/bin/statusbar/sb-internet
@@ -0,0 +1,43 @@
+#!/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
+
+togglevpn() {
+ if [ ! -n "$(cat /sys/class/net/libre/operstate 2>/dev/null)" ];then
+ reloadsingbox
+ notify-send " ο€£ Internet module" "Connected to VPN"
+ else
+ killall sing-box
+ notify-send "  Internet module" "Disconnected from VPN"
+ fi
+}
+
+case $BLOCK_BUTTON in
+ 1) togglevpn 2>/dev/null ;;
+ 3) notify-send "🌐 Internet module" "\- Click to enable/disable VPN
+ ❌: wifi disabled
+ πŸ“‘: no wifi connection
+ πŸ“Ά: wifi connection with quality
+ ❎: no ethernet
+ 🌐: ethernet working
+ πŸ”’: vpn is active
+ " ;;
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+# Wifi
+if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then
+ wifiicon="$(awk '/^\s*w/ { print "πŸ“Ά", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
+elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then
+ [ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="πŸ“‘ " || wifiicon="❌ "
+fi
+
+# Ethernet
+[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="ο›Ώ " || ethericon="❎"
+
+# Wireguard
+[ -n "$(cat /sys/class/net/libre/operstate 2>/dev/null)" ] && tunicon=" ο€£ "
+
+printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon"
diff --git a/.local/bin/statusbar/sb-mailbox b/.local/bin/statusbar/sb-mailbox
new file mode 100755
index 0000000..9177e03
--- /dev/null
+++ b/.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 -w -f "$TERMINAL" -e neomutt; pkill -RTMIN+12 i3blocks ;;
+ 2) setsid -f mailsync >/dev/null ;;
+ 3) notify-send "πŸ“¬ Mail module" "\- Shows unread mail
+- Shows πŸ”ƒ if syncing mail
+- Left click opens neomutt
+- Middle click syncs mail" ;;
+ 8) setsid -f "$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 mailsync >/dev/null 2>&1 && icon="ο‹± "
+
+[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "οƒ  $unread$icon"
diff --git a/.local/bin/statusbar/sb-memory b/.local/bin/statusbar/sb-memory
new file mode 100755
index 0000000..d95d85c
--- /dev/null
+++ b/.local/bin/statusbar/sb-memory
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+case $BLOCK_BUTTON in
+ 1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
+ 2) setsid -f "$TERMINAL" -e btop ;;
+ 3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
+- Click to show memory hogs.
+- Middle click to open htop." ;;
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+free --mebi | sed -n '2{p;q}' | awk '{printf ("ο”Έ %2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'
diff --git a/.local/bin/statusbar/sb-microphone b/.local/bin/statusbar/sb-microphone
new file mode 100755
index 0000000..45754c2
--- /dev/null
+++ b/.local/bin/statusbar/sb-microphone
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# Prints the current microphone volume or ο„± if muted.
+
+case $BLOCK_BUTTON in
+ 1) setsid -w -f "$TERMINAL" -e pulsemixer; pkill -RTMIN+23 "${STATUSBAR:-i3blocks}" ;;
+ 2) wpctl set-mute @DEFAULT_SOURCE@ toggle ;;
+ 4) wpctl set-volume @DEFAULT_SOURCE@ 1%+ ;;
+ 5) wpctl set-volume @DEFAULT_SOURCE@ 1%- ;;
+ 3) notify-send "ο„° Microphone volume module" "\- Shows volume ο„°, ο„± if muted.
+- Middle click to mute.
+- Scroll to change." ;;
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+vol="$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@)"
+
+# If muted, print ο„± and exit.
+[ "$vol" != "${vol%\[MUTED\]}" ] && echo ο„± && exit
+
+vol="${vol#Volume: }"
+
+split() {
+ # For ommiting the . without calling and external program.
+ IFS=$2
+ set -- $1
+ printf '%s' "$@"
+}
+
+vol="$(printf "%.0f" "$(split "$vol" ".")")"
+
+case 1 in
+ $((vol >= 1)) ) icon="ο„°" ;;
+ * ) echo ο„± && exit ;;
+esac
+
+echo "$icon $vol%"
diff --git a/.local/bin/statusbar/sb-nettraf b/.local/bin/statusbar/sb-nettraf
new file mode 100755
index 0000000..2f223d6
--- /dev/null
+++ b/.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" ;;
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+update() {
+ sum=0
+ for arg; do
+ read -r i < "$arg"
+ sum=$(( sum + i ))
+ done
+ cache=/tmp/${1##*/}
+ [ -f "$cache" ] && read -r old < "$cache" || old=0
+ printf %d\\n "$sum" > "$cache"
+ printf %d\\n $(( sum - old ))
+}
+
+rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
+tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
+
+printf " %4sB  %4sB\\n" $(numfmt --to=iec $rx $tx)
diff --git a/.local/bin/statusbar/sb-news b/.local/bin/statusbar/sb-news
new file mode 100755
index 0000000..f5e09fd
--- /dev/null
+++ b/.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." ;;
+ 8) setsid -f "$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/.local/bin/statusbar/sb-pacpackages b/.local/bin/statusbar/sb-pacpackages
new file mode 100755
index 0000000..9b12f34
--- /dev/null
+++ b/.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" ;;
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+pacman -Qu | grep -Fcv "[ignored]" | sed "s/^/ /;s/^ 0$//g"
diff --git a/.local/bin/statusbar/sb-popupgrade b/.local/bin/statusbar/sb-popupgrade
new file mode 100755
index 0000000..900f2a6
--- /dev/null
+++ b/.local/bin/statusbar/sb-popupgrade
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+printf "Beginning upgrade.\\n"
+
+yay -Syu
+pkill -RTMIN+8 "${STATUSBAR:-i3blocks}"
+
+printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
+read -r _
diff --git a/.local/bin/statusbar/sb-volume b/.local/bin/statusbar/sb-volume
new file mode 100755
index 0000000..2676ead
--- /dev/null
+++ b/.local/bin/statusbar/sb-volume
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Prints the current volume or πŸ”‡ if muted.
+
+case $BLOCK_BUTTON in
+ 1) setsid -w -f "$TERMINAL" -e pulsemixer; pkill -RTMIN+10 "${STATUSBAR:-i3blocks}" ;;
+ 2) wpctl set-mute @DEFAULT_SINK@ toggle ;;
+ 4) wpctl set-volume @DEFAULT_SINK@ 1%+ ;;
+ 5) wpctl set-volume @DEFAULT_SINK@ 1%- ;;
+ 3) notify-send "πŸ“’ Volume module" "\- Shows volume πŸ”Š, πŸ”‡ if muted.
+- Middle click to mute.
+- Scroll to change." ;;
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
+
+# If muted, print πŸ”‡ and exit.
+[ "$vol" != "${vol%\[MUTED\]}" ] && echo  && exit
+
+vol="${vol#Volume: }"
+
+split() {
+ # For ommiting the . without calling and external program.
+ IFS=$2
+ set -- $1
+ printf '%s' "$@"
+}
+
+vol="$(printf "%.0f" "$(split "$vol" ".")")"
+
+case 1 in
+ $((vol >= 70)) ) icon=" " ;;
+ $((vol >= 30)) ) icon=" " ;;
+ $((vol >= 1)) ) icon=" " ;;
+ * ) echo  && exit ;;
+esac
+
+echo "$icon $vol%"
diff --git a/.local/bin/sysact b/.local/bin/sysact
new file mode 100755
index 0000000..b83f47f
--- /dev/null
+++ b/.local/bin/sysact
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# A dmenu wrapper script for system functions.
+export WM="sway"
+case "$(readlink -f /sbin/init)" in
+ *systemd*) ctl='systemctl' ;;
+ *) ctl='loginctl' ;;
+esac
+
+wmpid(){ # This function is needed if there are multiple instances of the window manager.
+ tree="$(pstree -ps $$)"
+ tree="${tree#*$WM(}"
+ echo "${tree%%)*}"
+}
+
+case "$(printf "πŸ”’ lock\nπŸšͺ leave $WM\n♻️ renew $WM\n🐻 hibernate\nπŸ”ƒ reboot\nπŸ–₯️shutdown\nπŸ’€ sleep\nπŸ“Ί display off" | bemenu -i -p 'Action: ')" in
+ 'πŸ”’ lock') slock ;;
+ "πŸšͺ leave $WM") swaymsg exit ;;
+ "♻️ renew $WM") kill -HUP "$(wmpid)" ;;
+ '🐻 hibernate') slock $ctl hibernate -i ;;
+ 'πŸ’€ sleep') slock $ctl suspend -i ;;
+ 'πŸ”ƒ reboot') $ctl reboot -i ;;
+ 'πŸ–₯️shutdown') $ctl poweroff -i ;;
+ 'πŸ“Ί display off') xset dpms force off ;;
+ *) exit 1 ;;
+esac