commit dfe1da12467f99aacb7eb60dfccaf3011c41de73
parent c59e177dde0eccbed39523d7689736066cbb0d40
Author: jacobs-github <JacobDoesLinux@protonmail.com>
Date: Tue, 25 Feb 2020 15:35:58 -0800
updated everything
Diffstat:
| M | lemonbar/bin/lemon | | | 139 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------- |
1 file changed, 100 insertions(+), 39 deletions(-)
diff --git a/lemonbar/bin/lemon b/lemonbar/bin/lemon
@@ -1,86 +1,147 @@
#!/bin/dash
-# Jacob Edwards, 2020
-# complete, functianal, lemonbar config.
-
+# Jacob Edwards, January to Febuary, 2020
+# completly ugly (sourcecode), functianal, lemonbar config.
# kill lemonbar if it's running
if [ -n "$( pidof -s lemonbar )" ]; then
- bspc config bottom_padding -1
+ bspc config bottom_padding 0
killall lemonbar
killall lemon
exit 0
else
- bspc config bottom_padding 1
+ bspc config bottom_padding 0
fi
+# lower lemonbar after start
+lower(){
+ sleep 2.8
+ xdo lower -n lemonbar
+}
+
+
+
+# colors
+defaultbg='00000a'
+primaryfg='dd5555'
+
+c_workspace='%%{F#fff}'
+
+c_time="%%{F#$primaryfg}"
+c_date="%%{F#$primaryfg}"
+
+c_mpd_status="%%{F#aaa}"
+c_mpd_title="%%{F#f55}"
+c_mpd_sep="%%{F#aaa}"
+c_mpd_auther="%%{F#f55}"
+
+c_battery_discharging="%%{F#000}"
+c_battery_charging="%%{F#000}"
+c_battery_perc_sign="%%{F#222}"
+c_battery_prefix="%%{F#000}"
+
+c_memory="%%{F#$primaryfg}"
+c_memory_sep="%%{F#777}"
+
+c_cpu="%%{F#$primaryfg}"
+c_cpuperc="%%{F#777}"
+
+# static variables
+memmax="$( calc "$( free --mega | head -n 2 | tail -n 1 | awk '{print $2}' )" / 1024 | head -c 5)"
+
+cpumax="$( calc "$( cat /sys/bus/cpu/devices/cpu0/cpufreq/cpuinfo_max_freq )" / 1000 | awk '{printf $1}' )"
+# functions
bspwm_workspace(){
- printf '%%{F#f5a}'
- printf '%%{B#0f0000}'
+ printf "$c_workspace"
bspc query --desktops --desktop --names
}
+gettime(){
+ printf "$c_time"
+ date "+%R"
+}
-atime(){
- printf '%%{B#000000}'
- date '+%%{F#444}%R'
+getdate(){
+ printf "$c_date"
+ date '+%A %d'
}
+cpu(){
+ # I was overcomplecating things, thankyou.
+ # https://stackoverflow.com/questions/9229333/how-to-get-overall-cpu-usage-e-g-57-on-linux
+ local cpu="$( ps -A -o pcpu | tail -n +2 | paste -sd+ | bc )"
+ cpu="$( calc "$cpu" / 4 )" # maybe dividing it by treads will make it accurate?
-adate(){
- printf '%%{B#222}'
- date '+%%{F#444}%d/%m/%y'
+ printf "$c_cpu$cpu$c_cpuperc%%"
}
-
mpd_playing(){
local current="$( mpc status | head -n 2 | tail -n 1 | awk '{print $1}' )"
if [ "$current" = '[playing]' ] || [ "$current" = '[paused]' ]; then
- printf "%%{F#6f4f2f}$( mpc status | head -n 2 | tail -n 1 | awk '{print $1}' ) %%{F#6f3f3f}$(mpc current | awk -F ' - ' '{print $2}')%%{F#333} by %%{F#444}$( mpc current | awk -F ' - ' '{print $1}' )"
+ printf "$c_mpd_status$( mpc status | head -n 2 | tail -n 1 | awk '{print $1}' ) "
+ printf "$c_mpd_title$(mpc current | awk -F ' - ' '{print $2}')"
+ printf "$c_mpd_sep by "
+ printf "$c_mpd_auther$( mpc current | awk -F ' - ' '{print $1}' )"
fi
}
-
-
-
-
battery(){
- local batdir='/sys/class/power_supply/BAT0'
- local status="$( cat "$batdir/status" )"
-
- if [ "$status" = 'Discharging' ]; then
- status='- %%{F#8f3f3f}'
- elif [ "$status" = 'Charging' ]; then
- local prefix='^%%{F#3fafaf}'
+ local powerd='/sys/class/power_supply/'
+ local perc="$( cat "$powerd/BAT0/capacity" )"
+ local status="$( cat "$powerd/AC/online" )"
+
+ if [ "$status" -eq '0' ]; then
+ printf "${c_battery_prefix}${c_battery_discharging}"
+ elif [ "$status" -eq 1 -a "$perc" -ge 100 ]; then
+ printf "${c_battery_charging}"
+ elif [ "$status" -eq '1' ]; then
+ printf "${c_battery_prefix}^${c_battery_charging}"
fi
- local perc="$( cat "$batdir/capacity" )"
- printf "%%{F#777}$prefix$perc%%{F#888}%%"
+ printf "$perc"
+ printf "$c_battery_perc_sign%%"
}
+memory_gig(){
+ local mem="$( free --mega | head -n 2 | tail -n 1 | awk '{print $3}' )"
+ mem="$( calc "$mem" / 1024 | head -c 5)"
+ printf "$c_memory$memmax$c_memory_sep/$c_memory${mem}g"
+}
+memory_meg(){
+ local mem="$( free --mega | head -n 2 | tail -n 1 | awk '{print $3}' )"
+ printf "$c_memory${mem}m"
+}
+# start bar
+lower &
while true; do
- ws="$( bspwm_workspace )"
- adate="$( adate )"
- atime="$( atime )"
- mpd="$( mpd_playing )"
+ getdate="$( getdate )"
+ gettime="$( gettime )"
+ ws="$( bspwm_workspace )"
+ memory="$( memory_meg )"
+ timesince="$( daterelitive "$LOG" )"
bat="$( battery )"
+ mpd="$( mpd_playing )"
+ #cpu="$( cpu )"
- echo "%{l} $atime $ws%{c}$mpd %{r}$adate $bat "
- xdo lower -n lemonbar # it's wasteful but im lazy and don't want to find a solution.
-
- sleep 0.25
+ #echo "%{l} $gettime $ws%{c}$mpd %{r} $getdate $memory $bat "
+ echo "%{l} $gettime ($getdate) $ws %{c} $mpd %{r} $memory %{F#000}%{B#fff0f0} $timesince [ $bat ] %{B#$defaultbg}"
+ sleep 0.28
done | lemonbar\
- -n lemonbar\
+ -n lemonbar\
-f gohufont\
-F '#ffffff'\
- -B '#000000'\
+ -B "#$defaultbg"\
-g 'x20+0+0'\
-b\
-a 0\
- -o 1
+ -o 1\
+ -u 5\
+ -U '#722'
+
+# vim:filetype=sh