added my own bspwm config
This commit is contained in:
parent
5e70c95984
commit
c132453f4e
6 changed files with 410 additions and 0 deletions
207
bspwm/panel
Executable file
207
bspwm/panel
Executable file
|
@ -0,0 +1,207 @@
|
|||
#!/usr/bin/env zsh
|
||||
source $bspwm_config_dir/common
|
||||
|
||||
cleanup() {
|
||||
jobs=${${jobstates##*:*:}%=*}
|
||||
|
||||
if [[ "$jobs" ]]; then
|
||||
eval "kill $jobs"
|
||||
fi
|
||||
|
||||
bspc config top_padding 0
|
||||
}
|
||||
|
||||
get_line() {
|
||||
declare counter=0 line=$1
|
||||
|
||||
while read; do
|
||||
if (( counter == line )); then
|
||||
printf '%s\n' "$REPLY"
|
||||
return 0
|
||||
fi
|
||||
|
||||
(( counter++ ))
|
||||
done
|
||||
}
|
||||
|
||||
parse_fifo_data() {
|
||||
declare msg desktop_spec
|
||||
declare -g win_name misc bspwm_status
|
||||
|
||||
while read; do
|
||||
case "$REPLY" in
|
||||
cmd::*)
|
||||
read -r cmd args <<< "${REPLY#cmd::}"
|
||||
|
||||
case "$cmd" in
|
||||
redraw)
|
||||
printf 'Redraw triggered\n'
|
||||
sleep 1
|
||||
printf '%s\n' "$msg"
|
||||
;;
|
||||
respawn)
|
||||
printf 'Dying...\n'
|
||||
sleep 1
|
||||
rexec
|
||||
;;
|
||||
run)
|
||||
$args
|
||||
rexec
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
updates::*) updates="${REPLY#*updates::}";;
|
||||
date::*) date="${REPLY#*date::}";;
|
||||
T*)
|
||||
if (( panel_taskbar_enable )); then
|
||||
unset win_title
|
||||
unset taskbar taskbar_windows taskbar_length
|
||||
|
||||
panel_taskbar_max_title_current=$panel_taskbar_max_title
|
||||
|
||||
while read -r _ _ _ wid _ _ _ _ focus; do
|
||||
if [[ "$wid" =~ [0-9]x[0-9A-F] ]]; then
|
||||
if [[ "$focus" == '*' ]]; then
|
||||
taskbar_windows+=( "$wid::F" )
|
||||
else
|
||||
taskbar_windows+=( "$wid::u" )
|
||||
fi
|
||||
fi
|
||||
done < <( bspc query -T -d focused )
|
||||
|
||||
taskbar_windows_n="${#taskbar_windows[@]}"
|
||||
|
||||
if (( taskbar_windows_n )); then
|
||||
until (( taskbar_length )) && (( taskbar_length <= panel_taskbar_max_length )); do
|
||||
unset taskbar
|
||||
taskbar_length=$(( (taskbar_windows_n * 2) + 2 ))
|
||||
|
||||
for w in "${taskbar_windows[@]}"; do
|
||||
IFS='::' read -r wid _ state <<< "$w"
|
||||
win_title=$( xtitle -f '%s' -t "${panel_taskbar_max_title_current}" "$wid" )
|
||||
win_title_length="${#win_title}"
|
||||
|
||||
taskbar_length=$(( taskbar_length + win_title_length ))
|
||||
|
||||
if [[ "$state" == 'F' ]]; then
|
||||
taskbar+=" %{B${colors_bg_focused}}%{F${colors_bg_normal}}%{F-} ${win_title} %{B-}%{F${colors_bg_focused}}%{F-}"
|
||||
else
|
||||
taskbar+=" %{A:bspc window -f ${wid}:} ${win_title} %{A}"
|
||||
fi
|
||||
done
|
||||
|
||||
(( panel_taskbar_max_title_current-- ))
|
||||
done
|
||||
fi
|
||||
else
|
||||
win_title="${REPLY#*T}"
|
||||
if [[ "$win_title" ]]; then
|
||||
taskbar=" %{B${colors_bg_focused}}%{F${colors_bg_normal}}%{F-} ${win_title} %{B-}%{F${colors_bg_focused}}%{F-}"
|
||||
else
|
||||
unset taskbar
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
WM*)
|
||||
unset desktop_spec
|
||||
IFS=':' read -A bspwm_status <<< "$REPLY"
|
||||
|
||||
for i in "${bspwm_status[@]}"; do
|
||||
if [[ "$i" =~ ^[oOfFuU].+ ]]; then
|
||||
n="${i#*[oOfFuU]}"
|
||||
|
||||
case "$i" in
|
||||
O*|F*|U*) desktop_spec+="%{B${colors_bg_focused}} $n %{B-}";;
|
||||
u*) desktop_spec+="%{B${colour_urgent}}%{A:bspc desktop -f $n:} $n %{A}%{B-}";;
|
||||
o*) desktop_spec+="%{B-}%{A:bspc desktop -f $n:} $n %{A}";;
|
||||
f*)
|
||||
(( panel_show_empty_tags )) && {
|
||||
desktop_spec+="%{B-} $n "
|
||||
}
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
read _ _ _ _ layout float _ < <( bspc query -T -d focused | get_line 1 )
|
||||
|
||||
if [[ "$float" == 'f' ]]; then
|
||||
float_flag='f'
|
||||
else
|
||||
float_flag=''
|
||||
fi
|
||||
|
||||
case "$layout" in
|
||||
T) layout_flag='t';;
|
||||
M) layout_flag='m';;
|
||||
esac
|
||||
|
||||
desktop_spec+=" %{A:bsptl:}[${layout_flag}${float_flag}]%{A}"
|
||||
;;
|
||||
esac
|
||||
|
||||
msg="$desktop_spec"
|
||||
|
||||
[[ "$taskbar" ]] && { msg+="$taskbar"; }
|
||||
|
||||
msg+="%{r}%{F${colors_bg_focused}}%{F-}%{B${colors_bg_focused}} $updates $date "
|
||||
msg+='%{B-}%{F-}'
|
||||
|
||||
printf '%s\n' "$msg"
|
||||
done < "$panel_fifo"
|
||||
}
|
||||
|
||||
misc_status() {
|
||||
declare ip msg date
|
||||
|
||||
while sleep 1; do
|
||||
date=$( date +%A,\ %Y.%m.%d\ %H:%M:%S )
|
||||
msg="[ $date ]"
|
||||
printf 'S:%s\n' "$msg"
|
||||
done
|
||||
}
|
||||
|
||||
rexec() {
|
||||
eval "kill ${${jobstates##*:*:}%=*[@]}"
|
||||
exec "$0"
|
||||
}
|
||||
|
||||
function panel_geometry
|
||||
{
|
||||
xrandr|grep -Eo '[[:digit:]]+x[[:digit:]]+\+[[:digit:]]+\+[[:digit:]]+'|awk -F'x|+' '{print $1,$2,$3,$4}'|read -A screen_geometry
|
||||
((panel_h)) || panel_h=20
|
||||
((panel_w)) || panel_w=$screen_geometry[2]
|
||||
((panel_l)) || panel_l=$screen_geometry[3]
|
||||
((panel_d)) || panel_d=$screen_geometry[4]
|
||||
}
|
||||
|
||||
main() {
|
||||
trap 'cleanup' EXIT TERM INT
|
||||
trap 'rexec' HUP
|
||||
|
||||
[[ -e "$panel_fifo" ]] && {
|
||||
rm "$panel_fifo" || { return 1; }
|
||||
}
|
||||
|
||||
mkfifo "$panel_fifo"
|
||||
|
||||
if (( panel_taskbar_enable )); then
|
||||
xtitle -s -t "$panel_taskbar_max_title" -f 'T%s' > "$panel_fifo" &
|
||||
else
|
||||
xtitle -s -f 'T%s' > "$panel_fifo" &
|
||||
fi
|
||||
|
||||
bspc control --subscribe > "$panel_fifo" &
|
||||
$bspwm_config_dir/panel_status &
|
||||
|
||||
bspc config top_padding "$(( panel_h + bspwm_window_gap ))"
|
||||
|
||||
parse_fifo_data | lemonbar -g "${panel_w}x${panel_h}+${panel_l}+${panel_d}" \
|
||||
-f "$font_norm" \
|
||||
-f "$font_bold" \
|
||||
-F "$colors_fg_normal" \
|
||||
-B "$colors_bg_normal" | zsh &
|
||||
wait
|
||||
}
|
||||
|
||||
main
|
Loading…
Add table
Add a link
Reference in a new issue