Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/dash
- #
- # simplepanel.sh
- #
- # Simple panel script for bspwm with lemonbar
- # inspired by limepanel.
- #
- # Set size and position
- SP_WIDTH=
- SP_HEIGHT=28
- SP_POSITION=
- # Set fonts
- SP_FONT_1="xos4Terminus:pixelsize=18"
- SP_OFFSET_1=-6
- SP_FONT_2="Symbola:pixelsize=30"
- SP_OFFSET_2=2
- # Set colors
- SP_BG_COLOR="#FFEFF0F1"
- SP_BG_COLOR_1="#FF3DAEE9"
- SP_FG_COLOR="#FF101010"
- SP_FG_COLOR_1="grey"
- SP_FG_COLOR_2="#FF5C616C"
- # Set lemonbar format codes
- BC="%{B-}"
- BC1="%{B$SP_BG_COLOR_1}"
- FC="%{F-}"
- FC1="%{F$SP_FG_COLOR_1}"
- FC2="%{F$SP_FG_COLOR_2}"
- SEPARATOR="$FC1│$FC"
- CENTER="%{c}"
- RIGHT="%{r}"
- # Set panel structure - provide a string with a list of modules.
- # Add your own modules as you wish.
- sp_modules="
- sp_spacer
- sp_main_menu
- sp_separator
- sp_bspwm_status
- sp_center
- sp_window_title
- sp_right
- sp_separator
- sp_conky_info
- sp_spacer
- "
- # Module definitions - each module shoud print one line at a time.
- # Dynamic modules should print a line for every new value.
- # The panel updates every time a module prints a line.
- sp_spacer()
- {
- echo " " ;
- }
- sp_main_menu()
- {
- echo "$FC2%{A:morc_menu:}☰%{A}$FC" ;
- }
- sp_separator()
- {
- echo "$SEPARATOR" ;
- }
- sp_center()
- {
- echo "$CENTER" ;
- }
- sp_right()
- {
- echo "$RIGHT" ;
- }
- sp_bspwm_status()
- {
- IFS=':' ;
- bspc subscribe \
- | while read line ; do
- set -- $line ;
- while [ $# -gt 0 ] ; do
- case $1 in
- O*|F*|U*)
- printf "%s %s %s" "$BC1" "${1#?}" "$BC" ;;
- o*|u*)
- printf " %s " "${1#?}" ;;
- esac ;
- shift ;
- done ;
- printf "\n" ;
- done ;
- }
- sp_window_title()
- {
- xtitle -s -t -40 ;
- }
- sp_clock()
- {
- while true ; do
- date +%R ;
- sleep 60 ;
- done ;
- }
- sp_conky_info()
- {
- echo '
- conky.config = {
- out_to_x = false,
- out_to_console = true,
- use_spacer = "left",
- default_graph_width = 8,
- console_graph_ticks = " ,_,—,‾",
- out_to_stderr = false,
- cpu_avg_samples = 2,
- no_buffers = true,
- update_interval = 1
- };
- conky.text =
- [[
- CPU:\
- ${cpugraph}\
- ${cpu}%\
- '$SEPARATOR'\
- ${wireless_essid wlp2s0}\
- ${wireless_link_qual_perc wlp2s0}%\
- '$SEPARATOR'\
- ${time %T}
- ]]
- ' | conky -q -c - ;
- }
- ########
- # MAIN #
- ########
- # INITIALIZE PANEL
- sp_values="" ;
- for module in $sp_modules ; do # set initial values
- sp_values="$sp_values\n" ;
- done ;
- i=0 ;
- for module in $sp_modules ; do # start modules
- $module \
- | while read line ; do
- printf "%s/%s\n" "$i" "$line"; # add module index to the line
- done & # spawn proccess for dynamic modules
- i=$(($i+1)) ;
- done \
- | while read line ; do # UPDATE PANEL
- index="${line%%/*}" ; # get index of module that needs update
- new_value="${line#*/}" ; # get new value for that module
- i=0 ;
- sp_values_new="" ;
- while [ -n "$sp_values" ] ; do # read old set of values
- if [ $i -eq $index ] ; then
- value="$new_value" ; # replace appropriate value
- else
- value="${sp_values%%\\n*}" ; # keep all other values
- fi
- sp_values="${sp_values#*\\n}" ; # remove old value
- printf "%s" "$value" ;
- sp_values_new="$sp_values_new$value\n" ; # write new set of values
- i=$(($i+1)) ;
- done ;
- printf "\n" ;
- sp_values="$sp_values_new" ; # replace old values with new ones
- sleep 0.01 ; # a delay needed for smooth updates
- done \
- | lemonbar \
- -g ${SP_WIDTH}x${SP_HEIGHT}${SP_POSITION} \
- -f $SP_FONT_1 \
- -o $SP_OFFSET_1 \
- -f $SP_FONT_2 \
- -o $SP_OFFSET_2 \
- -B $SP_BG_COLOR \
- -F $SP_FG_COLOR \
- | while read line; do eval "$line"; done; # execute button commands
- wait
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement