My dotfiles. Period.

i3staplus 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/dash
  2. # prepend i3status with more stuff
  3. kb_layout() {
  4. local layout
  5. local color
  6. layout=$(
  7. setxkbmap -query \
  8. | awk '/layout/{print $2}'
  9. )
  10. case $layout in
  11. us) color='' ;;
  12. *) color=',"color": "#ff0000"' ;;
  13. esac
  14. printf '{"full_text": " %s"%s},' \
  15. "$layout" "$color"
  16. }
  17. bmo_be_ovw() {
  18. local ovw_path=.local/share/bmo/be/important.state
  19. local ovw
  20. local color
  21. test -s "$ovw_path" || return 0
  22. ovw=$(cat "$ovw_path")
  23. case $ovw in
  24. *%onbreak) color=',"color": "#33aa55"' ;;
  25. *%mtg) color=',"color": "#ff0000"' ;;
  26. *%working) color=',"color": "#cccccc"' ;;
  27. *) color='' ;;
  28. esac
  29. printf '{"full_text": " %s"%s},' \
  30. "$ovw" "$color"
  31. }
  32. i3status \
  33. | while true
  34. do
  35. read line
  36. case $line in
  37. '[{'*) line="[$(kb_layout)$(bmo_be_ovw){${line#\[\{}" ;;
  38. ',[{'*) line=",[$(kb_layout)$(bmo_be_ovw){${line#,\[\{}" ;;
  39. esac
  40. echo "$line"
  41. done