pdate icons in scripts

This commit is contained in:
Alexander Rosenberg 2023-05-04 15:04:51 -07:00
parent 2e64eee765
commit 41c41b7702
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
3 changed files with 47 additions and 26 deletions

View File

@ -9,42 +9,63 @@ if [[ "$(uname)" = 'Linux' ]]; then
function is_adapted_connected {
let connected="$(cat /sys/class/power_supply/ADP1/online)"
if ((${connected} == 1)); then
echo 'true'
((${connected} == 1))
}
function get_discharging_battery_icon {
let charge_percent="${1}"
if ((${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 'false'
echo -n '󰁹'
fi
}
function get_battery_icon {
function get_charging_battery_icon {
let charge_percent="${1}"
if "$(is_adapted_connected)"; then
echo -n ''
elif ((${charge_percent} <= 10)); then
echo -n ''
if ((${charge_percent} <= 10)); then
echo -n '󰢜'
elif ((${charge_percent} <= 20)); then
echo -n ''
echo -n '󰂆'
elif ((${charge_percent} <= 30)); then
echo -n ''
echo -n '󰂇'
elif ((${charge_percent} <= 40)); then
echo -n ''
echo -n '󰂈'
elif ((${charge_percent} <= 50)); then
echo -n ''
echo -n '󰢝'
elif ((${charge_percent} <= 60)); then
echo -n ''
echo -n '󰢝'
elif ((${charge_percent} <= 70)); then
echo -n ''
echo -n '󰢞'
elif ((${charge_percent} <= 80)); then
echo -n ''
echo -n '󰂊'
elif ((${charge_percent} < 100)); then
echo -n ''
echo -n '󰂋'
else
echo -n ''
echo -n '󰂅'
fi
}
let cp="$(get_battery_percent)"
get_battery_icon "${cp}"
is_adapted_connected \
&& get_charging_battery_icon "${cp}" \
|| get_discharging_battery_icon "${cp}"
printf '%3d%%\n' "${cp}"
# Linux ends here
else

View File

@ -3,10 +3,10 @@
if [[ "$(uname)" = 'Linux' ]]; then
local active_networks="$(nmcli c s --active)"
local output=''
[[ "${active_networks}" = *' wifi '* ]] && output="${output} "
[[ "${active_networks}" = *' ethernet '* ]] && output="${output}"
[[ "${active_networks}" = *' wireguard '* ]] && output="${output} "
(( ${#output} == 0 )) && output=''
[[ "${active_networks}" = *' wifi '* ]] && output="${output}󰖩 "
[[ "${active_networks}" = *' ethernet '* ]] && output="${output}󰈁"
[[ "${active_networks}" = *' wireguard '* ]] && output="${output}󰖂 "
(( ${#output} == 0 )) && output='󰈂'
bluetoothctl show | grep 'Powered: yes' >/dev/null && output="${output} "
printf '%s\n' "${output}"
else

View File

@ -3,12 +3,12 @@
let volume="$(pamixer --get-volume)"
local icon
if [[ "$(pamixer --get-mute)" = "true" ]]; then
icon=''
icon='󰸈'
elif ((${volume} > 50)); then
icon=''
icon='󰖀'
elif ((${volume} > 0)); then
icon='奔'
icon='󰖀'
else
icon=''
icon='󰕾'
fi
printf '%s%3d%%\n' "${icon}" "${volume}"