From 41c41b77020cc678352e7c4316104befc5598215 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Thu, 4 May 2023 15:04:51 -0700 Subject: [PATCH] pdate icons in scripts --- scripts/dwmblocks-battery | 57 ++++++++++++++++++++++++++------------- scripts/dwmblocks-network | 8 +++--- scripts/dwmblocks-volume | 8 +++--- 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/scripts/dwmblocks-battery b/scripts/dwmblocks-battery index 6a0a33c..89c896f 100755 --- a/scripts/dwmblocks-battery +++ b/scripts/dwmblocks-battery @@ -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 diff --git a/scripts/dwmblocks-network b/scripts/dwmblocks-network index 7a5c1e1..9aba058 100755 --- a/scripts/dwmblocks-network +++ b/scripts/dwmblocks-network @@ -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 diff --git a/scripts/dwmblocks-volume b/scripts/dwmblocks-volume index 3cd7125..bf61ed5 100755 --- a/scripts/dwmblocks-volume +++ b/scripts/dwmblocks-volume @@ -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}"