Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Lemonbar top status bar script
- specialtime() { # return integer level of specialness
- hr=$1
- mn=$2
- special=0
- if [[ $(($(($hr / 11)) * 11)) -eq $hr ]] ; then
- if [[ $(($(($mn / 11)) * 11)) -eq $mn ]] ; then
- special=1
- fi
- elif [[ $hr -eq $mn ]] ; then
- special=1
- elif [[ "$hr" = "$(echo $mn | rev)" ]] ; then
- special=1
- elif [[ "$hr$mn" = "0123" ]] ; then
- special=2
- elif [[ "$hr$mn" = "1234" ]] ; then
- special=2
- elif [[ "$hr$mn" = "2345" ]] ; then
- special=2
- elif [[ "$hr$mn" = "0246" ]] ; then
- special=2
- elif [[ "$hr$mn" = "1357" ]] ; then
- special=2
- elif [[ "$hr$mn" = "1248" ]] ; then
- special=2
- fi
- echo $special
- }
- tim() { # get time
- hou=$(date +%I)
- lou=$(date +%H)
- min=$(date +%M)
- # get clock symbol
- if [ $hou -eq 12 ] ; then
- clk=""
- elif [ $hou -eq 1 ] ; then
- clk=""
- elif [ $hou -eq 2 ] ; then
- clk=""
- elif [ $hou -eq 3 ] ; then
- clk=""
- elif [ $hou -eq 4 ] ; then
- clk=""
- elif [ $hou -eq 5 ] ; then
- clk=""
- elif [ $hou -eq 6 ] ; then
- clk=""
- elif [ $hou -eq 7 ] ; then
- clk=""
- elif [ $hou -eq 8 ] ; then
- clk=""
- elif [ $hou -eq 9 ] ; then
- clk=""
- elif [ $hou -eq 10 ] ; then
- clk=""
- elif [ $hou -eq 11 ] ; then
- clk=""
- fi
- if [[ $(specialtime $lou $min) -gt $(specialtime $hou $min) ]] ; then
- msg="$lou:$min"
- special=$(specialtime $lou $min)
- else
- msg="$hou:$min"
- special=$(specialtime $hou $min)
- fi
- if [[ $special -eq 0 ]] ; then
- echo "%{F#4F99D3} $clk $msg "
- elif [[ $special -eq 1 ]] ; then
- echo "%{F#5EEBB8} $clk $msg "
- elif [[ $special -eq 2 ]] ; then
- echo "%{F#F12E33} $clk $msg "
- fi
- }
- dat() { # get date
- echo "%{F#8BE03C} $(date "+%a %d %b") "
- }
- pkg() { # show upgradeable packages
- num=$(cat ~/.upgradeable | sed 's/^\n//g' | wc -l)
- if [ $num -gt 0 ] ; then
- echo "%{F#5eebb8} $num %{O10}"
- fi
- }
- net() { # get network status
- name=$(nmcli connection show | grep wlp2s0 | awk '{print $1}')
- if [ -z $name ] ; then
- # no connection
- echo "%{F#F12E33} 睊 "
- else
- #connection
- echo "%{F#FFB454} 直 $name "
- fi
- }
- bat() { # get battery info
- # battery percentage
- pct=$(acpi | awk '{print $4}' | sed 's/%,//g')
- # battery charging
- chg=$(acpi | awk '{print $3}' | sed 's/,//g')
- # battery icon
- if [ $chg = "Discharging" ] ; then
- if [ $pct -lt 10 ] ; then
- ico=""
- elif [ $pct -lt 20 ] ; then
- ico=""
- elif [ $pct -lt 30 ] ; then
- ico=""
- elif [ $pct -lt 40 ] ; then
- ico=""
- elif [ $pct -lt 50 ] ; then
- ico=""
- elif [ $pct -lt 60 ] ; then
- ico=""
- elif [ $pct -lt 70 ] ; then
- ico=""
- elif [ $pct -lt 80 ] ; then
- ico=""
- elif [ $pct -lt 90 ] ; then
- ico=""
- else
- ico=""
- fi
- else
- if [ $pct -lt 20 ] ; then
- ico=""
- elif [ $pct -lt 30 ] ; then
- ico=""
- elif [ $pct -lt 40 ] ; then
- ico=""
- elif [ $pct -lt 60 ] ; then
- ico=""
- elif [ $pct -lt 80 ] ; then
- ico=""
- elif [ $pct -lt 90 ] ; then
- ico=""
- else
- ico=""
- fi
- fi
- # battery colour
- if [ $chg = "Discharging" ] ; then
- if [ $pct -lt 11 ] ; then
- col="#F12E33"
- elif [ $pct -lt 26 ] ; then
- col="#FFB454"
- else
- col="#8BE03C"
- fi
- else
- col="#4F99D3"
- fi
- # battery time
- tim=$(acpi | awk '{print $5}' | sed 's/:[0-9][0-9]$//')
- if [ $tim = "until" ] ; then
- tim="00:00"
- elif [ $tim = "charging" ] ; then
- tim="00:00"
- fi
- # output
- echo "%{F$col} $ico $pct% $tim "
- }
- # print info
- while :; do
- echo "%{O10}$(tim)%{O10}$(dat)%{r}$(pkg)$(net)%{O10}$(bat)%{O10}"
- sleep 15
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement