aboutsummaryrefslogblamecommitdiff
path: root/dwm/.dwm/bar/bar.sh
blob: 796453cdcfc6ee47abcb179918de730fdeacc56a (plain) (tree)
1
2
3
4
5
6
7
8
9







                                                
                              

                                
                         









                                                        
                                                                        






















                                                                            

                                                                                   












































                                                                               
                                                                                     

                                  
                                                                                                              
    
#!/bin/dash

# ^c$var^ = fg color
# ^b$var^ = bg color

interval=0

# run bar script and dwm ( do not remove this ) 
SYMLINKDIR=$(readlink -f "$0")
BASEDIR=$(dirname "$SYMLINKDIR")
# load colors!
. $BASEDIR/themes/dracula

cpu() {
	cpu_val=$(grep -o "^[^ ]*" /proc/loadavg)

	printf "^c$black^ ^b$green^ CPU"
	printf "^c$white^ ^b$grey^ $cpu_val"
}

pkg_updates() {
	#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
		printf "^c$green^  Fully Updated"
	else
		printf "^c$green^  $updates"" updates"
	fi
}

battery() {
	get_capacity="$(cat /sys/class/power_supply/BAT0/capacity)"
	get_status="$(cat /sys/class/power_supply/BAT0/status)"
        case $get_status in
          Discharging)
	    printf "^c$blue^ 🔋  $get_capacity"
            ;;
          *)
            printf "^c$blue^   $get_capacity"
            ;;
        esac
}

brightness() {
        brightness="$(cat /sys/class/backlight/intel_backlight/brightness)"
        brightness_max="$(cat /sys/class/backlight/intel_backlight/max_brightness)"
        level=$(echo "scale=2; $brightness / $brightness_max * 100" | bc)

	printf "^c$red^   "
	printf "^c$red^%.0f\n" $level
}

mem() {
	printf "^c$blue^^b$black^  "
	printf "^c$blue^ $(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$black^ ^b$blue^ 󰤨 ^d^%s" " ^c$blue^Connected" ;;
	down) printf "^c$black^ ^b$blue^ 󰤭 ^d^%s" " ^c$blue^Disconnected" ;;
	esac
}

clock() {
	printf "^c$black^ ^b$darkblue^ 󱑆 "
	printf "^c$black^^b$blue^ $(date '+%I:%M %p') "
}

volume() {
  volume_status="$(pamixer --get-volume-human)"
  printf "^c$blue^ 🔊 $volume_status"
}

keyboard() {
  keyboard_bits=$(xset -q | grep -A 0 'LED' | cut -c59-67)
  case $keyboard_bits in 
    00000000)
      printf "^c$red^ ⌨️ en"
      ;;
    00001000)
      printf "^c$red^ ⌨️ no"
      ;;
    *)
      printf "^c$red^ ⌨️ $keyboard_bits"
      ;;
  esac
}

while true; do

	#[ $interval = 0 ] || [ $(($interval % 3600)) = 0 ] && updates=$(pkg_updates)
	interval=$((interval + 1))

        sleep 1 && xsetroot -name "$updates $(battery) $(brightness) $(cpu) $(mem) $(wlan) $(volume) $(clock)"
done