Move status to be a normal function so it's available on non-workstations.

This commit is contained in:
2025-11-10 21:57:59 -07:00
parent 692df74d41
commit 5274d6d94d

82
files/functions/status.function Executable file
View File

@@ -0,0 +1,82 @@
#!/usr/bin/env bash
# 2025-11-10 Hyperling
# Icons: https://fontawesome.com/v4/cheatsheet/
source "`which volume.function`"
source "`which battery.function`"
source "`which storage.function`"
function datetime {
date +"%Y-%m-%d %H:%M:%S"
}
function status-display {
# Defaults
cmd="echo"
sleep=0.2
if [[ "`storage-root`" == "`storage-home`" ]]; then
function status-display-storage {
echo "`storage-root`"
}
else
function status-display-storage {
echo "Root (`storage-root`), Home (`storage-home`)"
}
fi
# Test Config
if [[ $1 == "-t" || $1 == "--test" || $1 == "test" ]]; then
sleep=5
fi
# DWM Config
if [[ $1 == "-d" || $1 == "--dwm" || $1 == "dwm" ]]; then
cmd="xsetroot -name"
if [[ "`storage-root`" == "`storage-home`" ]]; then
function status-display-storage {
echo "`storage-root-dwm`)"
}
else
function status-display-storage {
echo "(Root `storage-root-dwm`, Home `storage-home-dwm`)"
}
fi
fi
battery=""; storage=""; volume=""; datetime="";
userhost="`whoami`@`hostname`"
while true; do
# Reset Variables
if [[ $datetime == *"00" ]]; then
unset battery
unset storage
fi
if [[ $datetime != "`datetime`" ]]; then
unset volume
unset datetime
fi
# Set Variables
if [[ -z $battery ]]; then
battery="`battery-display`"
fi
if [[ -z $storage ]]; then
storage="`status-display-storage`"
fi
if [[ -z $volume ]]; then
volume="`volume-display`"
fi
if [[ -z $datetime ]]; then
datetime="`datetime`"
fi
# Display Variables
readout="$readout  $battery"
readout="$readout |  $storage"
readout="$readout |  $volume"
readout="$readout |  $userhost"
readout="$readout |  $datetime"
$cmd "$readout"
readout=""
sleep $sleep
done
}
alias status="status-display --test"