Move function files to their own folder. Move the copy to General from Workstation. Leave dwm-status function under Workstation.

This commit is contained in:
2025-11-10 21:37:25 -07:00
parent 91c0a412bf
commit 683e03eab2
5 changed files with 12 additions and 2 deletions

View File

@@ -1,22 +0,0 @@
#!/usr/bin/env bash
# 2025-11-10 Hyperling
function battery-display {
detailed="N"
if [[ -n $1 ]]; then
detailed="Y"
fi
if [[ "$detailed" == "Y" ]]; then
upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | grep -o "[0-9.%]*"
else
int="`upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | grep -o "[0-9]*" | head -n 1`"
echo "${int}%"
fi
}
alias show-battery="battery-display"
alias battery="battery-display"
alias battery-use="battery-display"
alias battery-usage="battery-display"
alias battery-level="battery-display"
alias battery-levels="battery-display"

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env bash
# 2025-11-10 Hyperling
function storage-display {
location="$1"
style="$2"
if [[ -z "$location" ]]; then
echo "ERROR: Location must be passed. $location"
fi
if [[ "$style" == "%" || "$style" == "pct" || "$style" == "percent" ]]; then
df -h "$location" | tail -n 1 | awk '{print $5" Used"}'
elif [[ "$style" == "/" || "$style" == "use" || "$style" == "usage" ]]; then
df -h "$location" | tail -n 1 | awk '{print $4"/"$2" Free"}'
elif [[ "$style" == "G" || "$style" == "S" || "$style" == "F" ]]; then
df -h "$location" | tail -n 1 | awk '{print $4" Free"}'
else
df -h "$location" | tail -n 1 | awk '{print $5" Used, "$4"/"$2" Free"}'
fi
}
alias storage='echo -n "Root: " && storage-display "/" "F" && echo -n "Home: " && storage-display "/home" "F"'
export dwm_storage_style="F"
function storage-root {
storage-display / "$1"
}
function storage-root-dwm {
storage-root "$dwm_storage_style"
}
function storage-home {
storage-display /home "$1"
}
function storage-home-dwm {
storage-home "$dwm_storage_style"
}

View File

@@ -1,173 +0,0 @@
#!/usr/bin/env bash
# 2025-11-10 Hyperling
# Volume management for systems without working volume buttons.
# Written for ease of use in terminal and simple window management systems.
function volume-usage {
cat <<- EOF
Usage: volume [%int] [(+/-)%int] [-d] [-r] [-t] [-h]
Set to a static value:
volume 100, volume 65
Increment or decrement. Passing only + or - and no number defaults to 5.
volume -5, volume 5-, volume - 5, volume 5 -
volume +20, volume 20+, volume + 20, volume 20 +
Display the current volume:
volume,
volume-display, volume display, volume --display, volume -d,
volume +d
Set volume to a random number between 0 and 100.
volume-random, volume random, volume --random, volume -r
Be silly and oscillate volume in a loop:
volume-trip, volume trip, volume --trip, volume -t
Display this help text:
volume-usage,
volume-help volume help, volume --help, volume -h
EOF
return $1
}
alias volume-help="volume-usage"
alias vol-h="volume-help"
function volume {
## Check Params ##
if [[ "$1" == "--help" || "$1" == "help" || "$1" == "-h" ]]; then
volume-usage 1
return 1
fi
if [[ (-z "$1" && -z "$2")
|| "$1" == "--display" || "$1" == "display" || "$1" == "-d" || "$1" == "+d"
]]; then
volume-display
return 0
fi
## Parse Params ##
dir=""
amt=""
# Remove percent signs.
if [[ "$1" == *"%"* || "$2" == *"%"* ]]; then
set -- "${1//%/}" "${2//%/}"
fi
# Check if format is written text.
if [[ "$1" == "full" || "$1" == "max" ]]; then
amt=100
fi
if [[ "$1" == "mute" || "$1" == "none" ]]; then
amt=0
fi
# Check if the format is "volume +/- %int"
if [[ -z "$amt" && -z "$dir" ]]; then
if [[ "$1" == "+" || "$1" == "-" ]]; then
dir="$1"
amt="$2"
if [[ -z "$2" ]]; then
amt="5"
else
amt="$2"
fi
fi
fi
# Check if the format is "volume +/- %int".
if [[ -z "$amt" && -z "$dir" ]]; then
if [[ "$2" == "+" || "$2" == "-" ]]; then
amt="$1"
dir="$2"
fi
fi
# Check if amount and direction are adjacent, and if so, pull the values.
if [[ -z "$amt" && -z "$dir" ]]; then
if [[ "$1" == *"+"* ]]; then
dir="+"
elif [[ "$1" == *"-"* ]]; then
dir="-"
fi
if [[ -n "$dir" && -z "$amt" ]]; then
amt="$1"
amt=${amt//-/}
amt=${amt//+/}
fi
fi
# Check if format is direct volume.
if [[ -z "$dir" && -z "$amt" && -n "$1" && -z "$2" ]]; then
amt="$1"
fi
## Error Checking ##
regex='^[0-9]+$'
if ! [[ $amt =~ $regex ]]; then
echo "> ERROR: Amount '$amt' does not seem like a integer."
volume-usage 2
return 2
fi
## Main ##
if [[ -n "$dir" && -n "$amt" ]]; then
echo "> Changing volume by '$dir$amt%'."
amixer -q sset Master ${amt}%${dir}
echo "> Volume is now '`volume-display`'."
return 0
fi
if [[ -z "$dir" && -n "$1" ]]; then
echo "> Setting volume to '$amt'."
amixer -q sset Master ${amt}%
echo "> Volume has been set to '`volume-display`'."
return 0
fi
echo "> ERROR: Should not have made it here. Please report this to the developer."
echo "$0 $1 $2"
return 7
}
alias vol="volume "
alias vol-="volume - "
alias vol+="volume + "
function volume-display {
if [[ "$1" == "-v" || "$1" == "--verbose" || "$1" == "verbose" ]]; then
amixer sget Master
else
amixer sget Master | egrep -o '[0-9]{1,3}%' | head -n 1
fi
}
alias "vol-d"="volume-display"
## TBD/TODO ##
# Go up and down until cancelled.
#function volume-trip {
# curr eq amixer current readout
# if curr lt 50 then dir eq + else dir eq -
# while true; do
# if vol is 0 then dir eq +
# if vol is 100 then dir eq -
# curr eq \$curr $dir 1
# amixer set volume to curr
# sleep 0.1
# done
#}
#alias vol-t="volume-trip"
#alias volume-wub="volume-trip"
#alias vol-w="volume-wub"
#function volume-random {
# v eq $RANDOM % 101
# amixer set volume eq v
#}
#alias vol-r="volume-random"