Bladeren bron

better bar script

siduck76 3 jaren geleden
bovenliggende
commit
a14990310e
8 gewijzigde bestanden met toevoegingen van 57 en 37 verwijderingen
  1. 56 3
      .dwm/bar
  2. 1 2
      README.md
  3. 0 6
      scripts/dwm-xbps
  4. 0 3
      scripts/nbat
  5. 0 5
      scripts/nclock
  6. 0 3
      scripts/nmem
  7. 0 6
      scripts/nwlan
  8. 0 9
      scripts/xbps-updates

+ 56 - 3
.dwm/bar

@@ -2,9 +2,62 @@
 
 interval=0
 
+update_icon() {
+  icon=""
+
+  printf "^c#94af7d^ $icon ^d^%s"
+  printf "^c#94af7d^"
+}
+
+# only for void users!
+xbps_updates() {
+
+  updates=$(xbps-install -un | cut -d' ' -f2 | sort | uniq -c | xargs)
+
+  if [ -z "$updates" ]; then
+    echo "Fully Updated"
+  else
+    echo "$updates""s"
+  fi
+}
+
+# battery
+batt() {
+  printf "^c#81A1C1^   ^d^%s" "$(acpi | sed "s/,//g" | awk '{if ($3 == "Discharging"){print $4; exit} else {print $4""}}' | tr -d "\n")"
+}
+
+brightness() {
+
+  backlight() {
+    backlight="$(xbacklight -get)"
+    echo -e "$backlight" #| cut -c 1-2
+  }
+
+  icon="   "
+  printf "^c#BF616A^$icon"
+  printf "^c#BF616A^%.0f\n" $(backlight)
+}
+
+mem() {
+  printf "^c#7797b7^^b#363c48^   ^d^%s" "^c#7797b7^^b#414753^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)"
+}
+
+wlan() {
+  case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
+  up) printf "^c#3b414d^ ^b#7681c5^ 󰤨 ^d^%s" " ^c#828dd1^Connected" ;;
+  down) printf "^c#3b414d^ ^b#7681c5^ 󰤨 ^d^%s" " ^c#828dd1^Disconnected" ;;
+  esac
+}
+
+clock() {
+  printf "^c#2E3440^ ^b#828dd1^ 󱑆 ^d^%s %s\n" "^c#2E3440^^b#6c77bb^ $(date '+%a, %I:%M %p')" "$()"
+}
+
 while true; do
-    [ $interval == 0 ] || [ $(($interval%3600)) == 0 ] && updates=$(xbps-updates)
-    interval=$((interval + 1))
 
-    sleep 1 && xsetroot -name "$(dwm-xbps) $updates $(nbat)$(nback)$(nmem) $(nwlan) $(nclock)"
+  # remove these 2 lines if u dont use void! or adjust the xbps-updates to get n.o of updates (according your distro ofc)
+  [ $interval == 0 ] || [ $(($interval % 3600)) == 0 ] && updates=$(xbps-updates)
+  interval=$((interval + 1))
+
+  sleep 1 && xsetroot -name "$(update_icon) $(xbps-updates) $(batt) $(brightness) $(mem) $(wlan) $(clock)"
 done

+ 1 - 2
README.md

@@ -5,6 +5,5 @@
 # Setup 
 
 - Put the .dwm folder in ~/
-- chmod +x all scripts in .dwm and scripts folder
-- Move all the scripts folder's files in your PATH 
+- chmod +x all scripts in .dwm folder
 - cd into chadwm and sudo make install

+ 0 - 6
scripts/dwm-xbps

@@ -1,6 +0,0 @@
-#!/bin/bash
-
-icon=""
-
-printf "^c#94af7d^ $icon ^d^%s"
-printf "^c#94af7d^"

+ 0 - 3
scripts/nbat

@@ -1,3 +0,0 @@
-#!/bin/bash
-
-printf "^c#81A1C1^ 󰠠 ^d^%s" "$(acpi | sed "s/,//g" | awk '{if ($3 == "Discharging"){print $4; exit} else {print $4""}}' | tr -d "\n") "

+ 0 - 5
scripts/nclock

@@ -1,5 +0,0 @@
-#!/bin/bash
-
-printf "^c#2E3440^ ^b#828dd1^ 󱑆 ^d^%s %s\n" "^c#2E3440^^b#6c77bb^ $(date '+%a, %I:%M %p')" "$( )"
-
-

+ 0 - 3
scripts/nmem

@@ -1,3 +0,0 @@
-#!/bin/bash
- 
-printf " ^c#7797b7^^b#363c48^   ^d^%s" "^c#7797b7^^b#414753^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)"

+ 0 - 6
scripts/nwlan

@@ -1,6 +0,0 @@
-#!/bin/bash
-
-case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
-  up) printf "^c#3b414d^ ^b#7681c5^ 󰤨 ^d^%s" " ^c#828dd1^Connected";;
-  down) printf "^c#3b414d^ ^b#7681c5^ 󰤨 ^d^%s" " ^c#828dd1^Disconnected";;
-esac

+ 0 - 9
scripts/xbps-updates

@@ -1,9 +0,0 @@
-#!/bin/bash
-
-updates=$(xbps-install  -un | cut -d' ' -f2 | sort | uniq -c | xargs)
-
-if [ -z "$updates" ]; then
-    echo "Fully Updated"
-else
-    echo "$updates""s"
-fi