Initial commit

This commit is contained in:
2023-02-21 12:15:57 -08:00
commit a8d9901a57
9 changed files with 436 additions and 0 deletions

53
scripts/dwmblocks-battery Executable file
View File

@ -0,0 +1,53 @@
#!/usr/bin/env zsh
if [[ "$(uname)" = 'Linux' ]]; then
let charge_full="$(cat '/sys/class/power_supply/BAT0/charge_full')."
function get_battery_percent {
let charge_now="$(cat '/sys/class/power_supply/BAT0/charge_now')."
printf '%.0f' "$((charge_now / charge_full * 100))"
}
function is_adapted_connected {
let connected="$(cat /sys/class/power_supply/ADP1/online)"
if ((${connected} == 1)); then
echo 'true'
else
echo 'false'
fi
}
function get_battery_icon {
let charge_percent="${1}"
if "$(is_adapted_connected)"; then
echo -n ''
elif ((${charge_percent} <= 10)); then
echo -n ''
elif ((${charge_percent} <= 20)); then
echo -n ''
elif ((${charge_percent} <= 30)); then
echo -n ''
elif ((${charge_percent} <= 40)); then
echo -n ''
elif ((${charge_percent} <= 50)); then
echo -n ''
elif ((${charge_percent} <= 60)); then
echo -n ''
elif ((${charge_percent} <= 70)); then
echo -n ''
elif ((${charge_percent} <= 80)); then
echo -n ''
elif ((${charge_percent} < 100)); then
echo -n ''
else
echo -n ''
fi
}
let cp="$(get_battery_percent)"
get_battery_icon "${cp}"
printf '%3d%%\n' "${cp}"
# Linux ends here
else
echo "${0}: error: unknown os: \"$(uname)\"" >&2
exit 1
fi

14
scripts/dwmblocks-network Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env zsh
if [[ "$(uname)" = 'Linux' ]]; then
local active_networks="$(nmcli c s --active)"
local output=''
[[ "${active_networks}" = *' wifi '* ]] && output="${output}直 "
[[ "${active_networks}" = *' wireguard '* ]] && output="${output}嬨 "
(( ${#output} == 0 )) && output=''
bluetoothctl show | grep 'Powered: yes' >/dev/null && output="${output} "
printf '%s\n' "${output}"
else
echo "${0}: error: unknown os: \"$(uname)\"" >&2
exit 1
fi

14
scripts/dwmblocks-volume Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env zsh
let volume="$(pamixer --get-volume)"
local icon
if [[ "$(pamixer --get-mute)" = "true" ]]; then
icon='ﱝ'
elif ((${volume} > 50)); then
icon='墳'
elif ((${volume} > 0)); then
icon='奔'
else
icon='奄'
fi
printf '%s%3d%%\n' "${icon}" "${volume}"