1
0
Fork 0

expand tab

This commit is contained in:
Vladimír Dudr 2022-07-08 14:53:16 +02:00
parent e0a2aa986f
commit a0a71cdcec

View file

@ -30,102 +30,102 @@ monitors=( )
i=0 i=0
while read -r _ resolution while read -r _ resolution
do do
monitors[$i]="$(herbstclient list_monitors | grep "$resolution" | cut -d":" -f1)" monitors[$i]="$(herbstclient list_monitors | grep "$resolution" | cut -d":" -f1)"
i=$((i+1)) i=$((i+1))
done < <(xrandr| awk '/ connected/ { FS=" " ; $0=$0 ; if ($3 == "primary") { res=$4 } else {res=$3} ; FS="+" ; $0=$0 ; print $2" "res }' | sort -n) done < <(xrandr| awk '/ connected/ { FS=" " ; $0=$0 ; if ($3 == "primary") { res=$4 } else {res=$3} ; FS="+" ; $0=$0 ; print $2" "res }' | sort -n)
first_loop=1 first_loop=1
notify() { notify() {
if [[ "$first_loop" != 1 ]] if [[ "$first_loop" != 1 ]]
then then
#twmnc "$@" #twmnc "$@"
notify-send "$@" notify-send "$@"
fi fi
} }
# so it bootstraps... # so it bootstraps...
( sleep 0.5; hc emit_hook volume ) & ( sleep 0.5; hc emit_hook volume ) &
hc --idle | { hc --idle | {
for monitor in "${monitors[@]}" ; do for monitor in "${monitors[@]}" ; do
tags[$monitor]="$(hc tag_status "$monitor")" tags[$monitor]="$(hc tag_status "$monitor")"
done done
date="%{T2}%{T-} $(date '+%{F#efefef}%H:%M%{F#909090}, %Y-%m-%{F#efefef}%d')" date="%{T2}%{T-} $(date '+%{F#efefef}%H:%M%{F#909090}, %Y-%m-%{F#efefef}%d')"
windowtitle="" windowtitle=""
#count-mails; #count-mails;
#charge=$(battery | awk '{print $2}') #charge=$(battery | awk '{print $2}')
while true ; do while true ; do
### prepare by monitor tags displaying ### prepare by monitor tags displaying
for monitor in "${monitors[@]}" ; do for monitor in "${monitors[@]}" ; do
output_tags[$monitor]="%{A4:herbstclient use_index +1 --skip-visible:}%{A5:herbstclient use_index -1 --skip-visible:}" output_tags[$monitor]="%{A4:herbstclient use_index +1 --skip-visible:}%{A5:herbstclient use_index -1 --skip-visible:}"
for i in ${tags[$monitor]} ; do for i in ${tags[$monitor]} ; do
case ${i:0:1} in case ${i:0:1} in
'#'|'+') '#'|'+')
output_tags[$monitor]="${output_tags[$monitor]}%{F$col_fg_pri_sel}%{B$col_bg_pri_sel}" output_tags[$monitor]="${output_tags[$monitor]}%{F$col_fg_pri_sel}%{B$col_bg_pri_sel}"
;; ;;
#'+') #'+')
#output_tags[$monitor]="${output_tags[$monitor]}%{B#3c7693}%{F#141414}" #output_tags[$monitor]="${output_tags[$monitor]}%{B#3c7693}%{F#141414}"
#;; #;;
':') ':')
output_tags[$monitor]="${output_tags[$monitor]}%{B-}%{F-}" output_tags[$monitor]="${output_tags[$monitor]}%{B-}%{F-}"
;; ;;
'!') '!')
output_tags[$monitor]="${output_tags[$monitor]}%{B${col_bg_urg}}%{F-}" output_tags[$monitor]="${output_tags[$monitor]}%{B${col_bg_urg}}%{F-}"
;; ;;
'-'|'%') '-'|'%')
output_tags[$monitor]="${output_tags[$monitor]}%{B${col_bg_sec_sel}%{F${col_fg_sec_sel}}" output_tags[$monitor]="${output_tags[$monitor]}%{B${col_bg_sec_sel}%{F${col_fg_sec_sel}}"
;; ;;
*) *)
output_tags[$monitor]="${output_tags[$monitor]}%{B-}%{F${col_fg_sec}}" output_tags[$monitor]="${output_tags[$monitor]}%{B-}%{F${col_fg_sec}}"
;; ;;
esac esac
# output_tags[$monitor]="${output_tags[$monitor]}%{A:herbstclient use_index $((${i:1} - 1 )):} ${i:1} %{A}" # output_tags[$monitor]="${output_tags[$monitor]}%{A:herbstclient use_index $((${i:1} - 1 )):} ${i:1} %{A}"
output_tags[$monitor]="${output_tags[$monitor]}%{A1:herbstclient use ${i:1}:} ${i:1} %{A}%{B-}%{F-}" output_tags[$monitor]="${output_tags[$monitor]}%{A1:herbstclient use ${i:1}:} ${i:1} %{A}%{B-}%{F-}"
done done
output_tags[$monitor]="${output_tags[$monitor]}%{A}%{A}" output_tags[$monitor]="${output_tags[$monitor]}%{A}%{A}"
done done
#bordercolor="#26221C" #bordercolor="#26221C"
separator="%{B-}%{F-}|" separator="%{B-}%{F-}|"
#separator="%{B$selbg} %{B-}%{F-}" #separator="%{B$selbg} %{B-}%{F-}"
#right= #right=
#for st in playing volume wifi temperature load date #for st in playing volume wifi temperature load date
#do #do
#data="$(eval $st)" #data="$(eval $st)"
#[[ -n "$data" ]] && right="$right $separator $data" #[[ -n "$data" ]] && right="$right $separator $data"
#done #done
### All drawing happens here ### All drawing happens here
# echo -n "%{T5}" # set font # echo -n "%{T5}" # set font
res= res=
for m in "${!monitors[@]}" ; do for m in "${!monitors[@]}" ; do
monitor=${monitors[$m]} monitor=${monitors[$m]}
### set monitor ### set monitor
res+="%{S$m}" res+="%{S$m}"
#echo -en "%{S$((${#monitors[@]} - monitor))}" #echo -en "%{S$((${#monitors[@]} - monitor))}"
### print the left ### print the left
res+="%{l}${output_tags[$monitor]}$separator ${windowtitle:0:150}" res+="%{l}${output_tags[$monitor]}$separator ${windowtitle:0:150}"
### center ### center
#echo -n "%{c}%{U${colors[bright_orange]}}${windowtitle:0:150}%{U-}" #echo -n "%{c}%{U${colors[bright_orange]}}${windowtitle:0:150}%{U-}"
### print the right ### print the right
res+="%{r}$playing $separator $volume $separator $wifi $separator $network $separator $temperature $separator $load $separator $date $separator %{U#f2f229}$charge%{U-} $separator" res+="%{r}$playing $separator $volume $separator $wifi $separator $network $separator $temperature $separator $load $separator $date $separator %{U#f2f229}$charge%{U-} $separator"
#echo -en "%{r}$right $separator %{U#f2f229}$charge%{U-} $separator" #echo -en "%{r}$right $separator %{U#f2f229}$charge%{U-} $separator"
done done
### end the output ### end the output
echo -e "$res" echo -e "$res"
### Data handling ### ### Data handling ###
# This part handles the events generated in the event loop, and sets # This part handles the events generated in the event loop, and sets
# internal variables based on them. The event and its arguments are # internal variables based on them. The event and its arguments are
# read into the array cmd, then action is taken depending on the event # read into the array cmd, then action is taken depending on the event
# name. # name.
# "Special" events (quit_panel/togglehidepanel/reload) are also handled # "Special" events (quit_panel/togglehidepanel/reload) are also handled
# here. # here.
# wait for next event # wait for next event
IFS=$'\t' read -ra cmd || break IFS=$'\t' read -ra cmd || break