Advertisement
Matt_23

simple dwm bar

Nov 7th, 2022
1,427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.44 KB | Source Code | 0 0
  1. #!/bin/bash
  2.  
  3. w_date(){
  4.     w_date="$(date +" %B %d  %H:%M")"
  5.     echo -e "$w_date"
  6. }
  7.  
  8. w_bat(){
  9.     bat_cap="$(cat /sys/class/power_supply/BAT0/capacity)"
  10.     bat_stat="$(cat /sys/class/power_supply/BAT0/status)"
  11.  
  12.     if [[ "$bat_stat" == "Charging" ]]
  13.     then
  14.         echo -e " $bat_cap%"
  15.     elif [[ "$bat_cap" == "100" ]]
  16.     then
  17.         echo -e " $bat_cap%"
  18.     elif [[ $bat_cap > 90 ]]
  19.     then
  20.         echo -e " $bat_cap%"
  21.     elif [[ $bat_cap > 80 ]] && [[ $bat_cap < 91 ]]
  22.     then
  23.         echo -e " $bat_cap%"
  24.     elif [[ $bat_cap > 70 ]] && [[ $bat_cap < 81 ]]
  25.     then
  26.         echo -e " $bat_cap%"
  27.     elif [[ $bat_cap > 60 ]] && [[ $bat_cap < 71 ]]
  28.     then
  29.         echo -e " $bat_cap%"
  30.     elif [[ $bat_cap > 50 ]] && [[ $bat_cap < 61 ]]
  31.     then
  32.         echo -e " $bat_cap%"
  33.     elif [[ $bat_cap > 40 ]] && [[ $bat_cap < 51 ]]
  34.     then
  35.         echo -e " $bat_cap%"
  36.     elif [[ $bat_cap > 30 ]] && [[ $bat_cap < 41 ]]
  37.     then
  38.         echo -e " $bat_cap%"
  39.     elif [[ $bat_cap > 20 ]] && [[ $bat_cap < 31 ]]
  40.     then
  41.         echo -e " $bat_cap%"
  42.     elif [[ $bat_cap > 10 ]] && [[ $bat_cap < 21 ]]
  43.     then
  44.         echo -e " $bat_cap%"
  45.     else
  46.         echo -e " $bat_cap%"
  47.     fi
  48.  
  49. }
  50.  
  51. w_vol(){
  52.     vol="$(pamixer --get-volume-human)"
  53.     if [[ "$vol" == "muted" ]]
  54.     then
  55.         echo " off"
  56.     else
  57.         vol_s="$(echo $vol | sed 's/.$//')"
  58.         if [[ $vol_s > 50 ]] || [[ "$vol_s" == "100" ]]
  59.         then
  60.             echo " $vol"
  61.         else
  62.             echo " $vol"
  63.         fi
  64.     fi
  65. }
  66.  
  67. set_name(){
  68.     xsetroot -name "$(w_date) | $(w_bat) | $(w_vol) |"
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement