浏览代码

update config.def.h: changed icons, enabled preview + modified bar similiar to my own dwmblocks config

Noah Vogt 3 年之前
父节点
当前提交
e0ab8ccad7
共有 2 个文件被更改,包括 62 次插入14 次删除
  1. 3 3
      chadwm/config.def.h
  2. 59 11
      scripts/bar.sh

+ 3 - 3
chadwm/config.def.h

@@ -25,7 +25,7 @@ static const int vertpadtab         = 33;
 static const int horizpadtabi       = 15;
 static const int horizpadtabo       = 15;
 static const int scalepreview       = 4;
-static const int tag_preview        = 0;        /* 1 means enable, 0 is off */
+static const int tag_preview        = 1;        /* 1 means enable, 0 is off */
 static const int colorfultag        = 1;        /* 0 means use SchemeSel for selected non vacant tag */
 
 static const char *fonts[]          = { "JetBrainsMono Nerd Font:style:medium:size=10",
@@ -53,13 +53,13 @@ static const char *colors[][3]      = {
 };
 
 /* tagging */
-static char *tags[] = {"", "", "", "", ""};
+static char *tags[] = {"", "", "", "", ""};
 
 static const char* eww[] = { "eww", "open" , "eww", NULL };
 
 static const Launcher launchers[] = {
     /* command     name to display */
-    { eww,         "" },
+    { eww,         "" },
 };
 
 static const int tagschemes[] = {

+ 59 - 11
scripts/bar.sh

@@ -16,17 +16,35 @@ cpu() {
 }
 
 pkg_updates() {
-  updates=$(doas xbps-install -un | wc -l) # void
-  # updates=$(checkupdates | wc -l)   # arch , needs pacman contrib
+  #updates=$(doas xbps-install -un | wc -l) # void
+  updates=$(checkupdates | wc -l)   # arch , needs pacman contrib
   # updates=$(aptitude search '~U' | wc -l)  # apt (ubuntu,debian etc)
 
-  if [ -z "$updates" ]; then
+  if echo "$updates" | grep -q "^0$"; then
     printf "^c$green^  Fully Updated"
   else
     printf "^c$green^  $updates"" updates"
   fi
 }
 
+get_volume() {
+  percent="$(amixer sget Master | grep 'Front Left:' | \
+    awk -F '[\\]\\[]' '{print $2}' | sed 's/\%$//')"
+
+  if amixer sget Master | grep -q "off"; then
+    volume_icon="婢"
+  elif [ "$percent" -gt 69 ]; then
+    volume_icon="墳"
+  elif [ "$percent" -gt 29 ]; then
+    volume_icon="奔"
+  else
+    volume_icon="奄"
+  fi
+
+  printf "^c$red^ $volume_icon "
+  printf "^c$red^ $percent"
+}
+
 battery() {
   get_capacity="$(cat /sys/class/power_supply/BAT1/capacity)"
   printf "^c$blue^   $get_capacity"
@@ -38,20 +56,50 @@ brightness() {
 }
 
 mem() {
-  printf "^c$blue^^b$black^  "
-  printf "^c$blue^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)"
+    printf "^c$blue^^b$black^  "
+    printf "^c$blue^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)"
 }
 
 wlan() {
-	case "$(cat /sys/class/net/wl*/operstate 2>/dev/null)" in
-	up) printf "^c$black^ ^b$blue^ 󰤨 ^d^%s" " ^c$blue^Connected" ;;
-	down) printf "^c$black^ ^b$blue^ 󰤭 ^d^%s" " ^c$blue^Disconnected" ;;
-	esac
+	# case "$(cat /sys/class/net/wl*/operstate 2>/dev/null)" in
+	# up) printf "^c$black^ ^b$blue^ 󰤨 ^d^%s" " ^c$blue^Connected" ;;
+	# down) printf "^c$black^ ^b$blue^ 󰤭 ^d^%s" " ^c$blue^Disconnected" ;;
+	# esac
+
+  upstate=$(ip a | grep BROADCAST,MULTICAST | awk '{print $9}' | head -n 1)
+  case "$(cat /sys/class/net/wl*/operstate 2>/dev/null)" in
+  down)
+      if [ "$upstate" = "DOWN" ]; then
+          if [ "$(rfkill | grep 'blocked' | awk '{print $4 $5}' | \
+              sed 's/unblocked//g' | uniq | wc -l)" -eq "1" ]; then
+                  if [ "$(rfkill | grep 'blocked' | awk '{print $4 $5}' | \
+                      sed 's/unblocked//g' | grep . | wc -l)" -gt "0" ]; then
+                      printf "^c$black^ ^b$blue^ 泌^d^%s" "^c$blue^off"
+                  fi
+          elif rfkill list wifi | grep 'Soft blocked' | awk '{print $3}' | \
+              grep -q 'yes'; then
+                  printf "^c$black^ ^b$blue^ 󰤭 ^d^%s" "^c$blue^off"
+          fi
+          printf "^c$black^ ^b$blue^ ﮤ ^d^ %s" "^c$blue^$upstate"
+      else
+          printf "^c$black^ ^b$blue^ ﮣ ^d^ %s" "^c$blue^$upstate"
+      fi;;
+  up)
+          percent=$(awk '/^\s*w/ { print int($3 * 100 / 70) }' \
+              /proc/net/wireless | sed 's/100/99/')
+
+          printf "^c$black^ ^b$blue^ 󰤨  ^d^ %s" "^c$blue^$percent"
+  esac
 }
 
 clock() {
 	printf "^c$black^ ^b$darkblue^ 󱑆 "
-	printf "^c$black^^b$blue^ $(date '+%H:%M')  "
+	printf "^c$black^^b$blue^ $(date '+%H:%M') "
+}
+
+get_date() {
+	printf "^c$black^ ^b$darkblue^   "
+	printf "^c$black^^b$blue^ $(date '+%d.%m.%y')"
 }
 
 while true; do
@@ -59,5 +107,5 @@ while true; do
   [ $interval = 0 ] || [ $(($interval % 3600)) = 0 ] && updates=$(pkg_updates)
   interval=$((interval + 1))
 
-  sleep 1 && xsetroot -name "$updates $(battery) $(brightness) $(cpu) $(mem) $(wlan) $(clock)"
+  sleep 1 && xsetroot -name "$updates $(get_volume) $(battery) $(brightness) $(cpu) $(mem) $(wlan) $(get_date) $(clock)"
 done