status.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. # The Sway configuration file in ~/.config/sway/config calls this script.
  3. # You should see changes to the status bar after saving this script.
  4. # If not, do "killall swaybar" and $mod+Shift+c to reload the configuration.
  5. # more font awesome fonts are here: https://fontawesome.com/cheatsheet?from=io
  6. # Battery empty 
  7. # battery quarter 
  8. # battery half 
  9. # battery full 
  10. # wifi 
  11. # file image  I could use this after I take a screen shot
  12. # 🐦 dovecot is running
  13. # Produces "21 days", for example
  14. #uptime_formatted=$(uptime | cut -d ',' -f1 | cut -d ' ' -f4,5)
  15. # function start_vpn () {
  16. # nmcli connection up my_expressvpn_switzerland_udp
  17. # ls
  18. # }
  19. # vpn_connection=$(nmcli con show --active | grep my_expressvpn_switzerland_udp | awk '{ print $1 }')
  20. vpn_connection=false
  21. volume_level=$(pactl list sinks | grep "Volume: front-left" | awk '{print $5}')
  22. # cut off the last character of the volume level which is '%'
  23. volume_level=${volume_level%?}
  24. if [ $volume_level -lt 10 ]
  25. then
  26. volume_icon="<span foreground=\"#323232\">_</span>🔇 <span foreground=\"#323232\">_</span>"
  27. elif [ $volume_level -lt 50 ]
  28. then
  29. volume_icon="<span foreground=\"#323232\">_</span>🔉 <span foreground=\"#323232\">_</span>"
  30. else
  31. volume_icon="<span foreground=\"#323232\">_</span> 🔊 <span foreground=\"#323232\">_</span>"
  32. fi
  33. # The abbreviated weekday (e.g., "Sat"), followed by the ISO-formatted date
  34. # like 2018-10-06 and the time (e.g., 14:01)
  35. date_formatted=$(date "+%H:%M %a %b %d %Y")
  36. # Get the Linux version but remove the "-1-ARCH" part
  37. linux_version=$(uname -r | cut -d '-' -f1)
  38. #linux_version="kernel ${linux_version}"
  39. # Returns the battery status: "Full", "Discharging", or "Charging".
  40. battery_status=$(cat /sys/class/power_supply/BAT0/status)
  41. # old command nmcli network connectivity check
  42. internet_connected=$(nmcli network connectivity)
  43. if [ $vpn_connection = "my_expressvpn_switzerland_udp" ]
  44. then
  45. internet_icon="<span foreground=\"#323232\">_</span> 🖧 "
  46. elif [ $internet_connected = "full" ]
  47. then
  48. #start_vpn
  49. internet_icon="<span foreground=\"green\" size=\"large\"></span>"
  50. elif [ $internet_connected = "limited" ]
  51. then
  52. #start_vpn
  53. internet_icon="<span foreground=\"yellow\" size=\"large\"></span>"
  54. elif [ $internet_connected = "portal" ]
  55. then
  56. #start_vpn
  57. internet_icon="<span foreground=\"pink\" size=\"large\"></span>"
  58. elif [ $internet_connected = "none" ]
  59. then
  60. internet_icon="<span foreground=\"red\" size=\"large\"></span>"
  61. elif [ $internet_connected = "unknown" ]
  62. then
  63. internet_icon="<span foreground=\"red\" size=\"large\">⁈⁈</span>"
  64. fi
  65. big_space="<span foreground=\"#323232\">________________________</span>"
  66. small_space="<span foreground=\"#323232\">___________</span>"
  67. smallest_space="<span foreground=\"#323232\">_</span>"
  68. status_line="$date_formatted $big_space 🐧 $linux_version $small_space "
  69. # $uptime_formatted ↑
  70. # Emojis and characters for the status bar 💎 💻 💡 🔌 ⚡ 📁 \|
  71. echo $status_line $internet_icon $volume_icon 🔋 $battery_status