printf '},\n'
}
+print_calc() {
+ printf "%d" $(calc "$1")
+}
+
+color_at() {
+ IDX=0
+ while true; do
+ IDX=$(print_calc "${IDX} + 1")
+ STEP=$(echo "$2" | cut -d'_' -f${IDX})
+ if [ -z "${STEP}" ]; then
+ break
+ fi
+ LIMIT=$(echo "${STEP}" | cut -d':' -f1)
+ COLOR=$(echo "${STEP}" | cut -d':' -f2)
+ if [ "${LIMIT}" -ge "${1}" ]; then
+ printf "${COLOR}"
+ break
+ fi
+ done
+}
+
print_clipboard() {
print_selection() {
print_bar_block "$1:[" "${COL_WHITE}" 0
if [ -z "${IP}" ]; then
print_bar_block '-'
else
- print_bar_block "${IP}" "${COL_WHITE}"
+ print_bar_block "${IP}" "${COL_WHITE}" "$2"
fi
}
print_conn enp
- print_conn wlp
+ print_conn wlp 0
+ STATUS_WIFI=$(nmcli -t -f IN-USE,SSID,SIGNAL dev wifi | grep '^\*:')
+ if [ ! -z "${STATUS_WIFI}" ]; then
+ SIGNAL=$(echo -n "${STATUS_WIFI}" | cut -d':' -f3)
+ COLOR=$(color_at $SIGNAL "45:${COL_RED}_85:${COL_YELLOW}_100:${COL_GREEN}")
+ print_bar_block " ${SIGNAL}" "${COLOR}" 0
+ print_bar_block "% $(echo "${STATUS_WIFI}" | cut -d':' -f2)"
+ fi
}
print_battery() {
cat_energy() {
cat "${BAT_DIR}/energy_$1"
}
- printf "%d" $(calc "100 * $(cat_energy $1) // $(cat_energy $2)")
+ print_calc "100 * $(cat_energy $1) // $(cat_energy $2)"
}
CHARGE=$(calc_percent now full)
- COLOR="${COL_GREEN}"
- if [ "${CHARGE}" -lt 25 ]; then
- COLOR="${COL_RED}"
- elif [ "${CHARGE}" -lt 65 ]; then
- COLOR="${COL_YELLOW}"
- fi
+ COLOR=$(color_at $CHARGE "25:${COL_RED}_65:${COL_YELLOW}_100:${COL_GREEN}")
print_bar_block "${CHARGE}%" "${COLOR}" 0
COLOR="${COL_WHITE}"
print_temperature() {
COLOR="${COL_WHITE}"
TEMPERATURE=$(cat ${SYSCLASS_DIR}/thermal/thermal_zone0/temp)
- TEMPERATURE_IN_C=$(printf "%d" $(calc "${TEMPERATURE} // 1000"))
- if [ $TEMPERATURE_IN_C -gt 85 ]; then
- COLOR="${COL_RED}"
- elif [ $TEMPERATURE_IN_C -gt 65 ]; then
- COLOR="${COL_YELLOW}"
- fi
+ TEMPERATURE_IN_C=$(print_calc "${TEMPERATURE} // 1000")
+ COLOR=$(color_at $TEMPERATURE_IN_C "65:${COL_GREEN}_85:${COL_YELLOW}_999:${COL_RED}")
print_bar_block "${TEMPERATURE_IN_C}" "${COLOR}" 0
print_bar_block '°'
}
MUTE=M
if [ "$(pactl get-sink-mute 0)" = "Mute: no" ]; then
MUTE=
- COLOR="${COL_WHITE}"
+ COLOR="${COL_RED}"
fi
print_bar_block "v:${MUTE}$(pactl get-sink-volume 0 | head -1 | cut -d' ' -f5)" "${COLOR}"
}
print_bar_block "k:${LAYOUT}"
}
-printf '{"version": 1}\n['
+printf '{"version": 1}\n['
while true; do
printf '['
print_clipboard