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

View File

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

View File

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