Skip to content

Instantly share code, notes, and snippets.

@rohshall
Forked from jinyeow/bspwmrc
Last active November 8, 2022 23:40
Show Gist options
  • Save rohshall/43c48893cb8d0431481e3e62168eadaa to your computer and use it in GitHub Desktop.
Save rohshall/43c48893cb8d0431481e3e62168eadaa to your computer and use it in GitHub Desktop.
Config files related to bspwm and panel (lemonbar)
#! /bin/sh
xrandr.sh
sxhkd &
xcompmgr &
$HOME/bin/panel &
bspc monitor LVDS-1 -d 1 2 3 4 5
bspc monitor HDMI-2 -d 6 7 8 9 0
bspc config border_width 1
bspc config window_gap 1
bspc config split_ratio 0.52
bspc config borderless_monocle true
bspc config gapless_monocle true
bspc config focus_follows_pointer true
wm_name LG3D
#! /bin/sh
trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
mkfifo "$PANEL_FIFO"
while true;
do
echo "T$(xdotool getwindowfocus getwindowname)";
date +'S%a %H:%M %y-%m-%d';
echo "B$(upower -i /org/freedesktop/UPower/devices/battery_batt | grep "percentage" | cut -d: -f2 | sed 's/\s+//g')"
sleep 2;
done > "$PANEL_FIFO" &
bspc subscribe report > "$PANEL_FIFO" &
. $HOME/bin/panel_colors
$HOME/bin/panel_bar < "$PANEL_FIFO" | lemonbar -a 32 -u 2 -n "$PANEL_WM_NAME" -g x$PANEL_HEIGHT -f "$PANEL_FONT" -F "$COLOR_DEFAULT_FG" -B "$COLOR_DEFAULT_BG" | sh &
wait
#! /bin/sh
if xdo id -a "$PANEL_WM_NAME" > /dev/null ; then
printf "%s\n" "The panel is already running." >&2
exit 1
fi
trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
mkfifo "$PANEL_FIFO"
bspc config top_padding $PANEL_HEIGHT
bspc subscribe report > "$PANEL_FIFO" &
xtitle -sf 'T%s\n' > "$PANEL_FIFO" &
clock -sf 'S%D %a %H:%M' > "$PANEL_FIFO" &
temp -sf'C%.1f deg' -n0 > "$PANEL_FIFO" &
battery -sf'B%s %i' -n0 > "$PANEL_FIFO" &
. $(dirname "$0")/panel_colors
$(dirname "$0")/panel_bar < "$PANEL_FIFO" | lemonbar -a 32 -n "$PANEL_WM_NAME" -g x$PANEL_HEIGHT -f "$PANEL_FONT" -F "$COLOR_DEFAULT_FG" -B "$COLOR_DEFAULT_BG" | sh &
wid=$(xdo id -a "$PANEL_WM_NAME")
tries_left=20
while [ -z "$wid" -a "$tries_left" -gt 0 ] ; do
sleep 0.05
wid=$(xdo id -a "$PANEL_WM_NAME")
tries_left=$((tries_left - 1))
done
[ -n "$wid" ] && xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid"
wait
#! /bin/sh
#
# Example panel for lemonbar
. $(dirname "$0")/panel_colors
num_mon=$(bspc query -M | wc -l)
while read -r line ; do
case $line in
S*)
# clock output
sys="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}"
;;
C*)
# temp output
celcius="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}"
;;
B*)
# battery output
batt="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}"
;;
T*)
# xtitle output
title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}"
;;
W*)
# bspwm's state
wm=""
IFS=':'
set -- ${line#?}
while [ $# -gt 0 ] ; do
item=$1
name=${item#?}
case $item in
[mM]*)
[ $num_mon -lt 2 ] && shift && continue
case $item in
m*)
# monitor
FG=$COLOR_MONITOR_FG
BG=$COLOR_MONITOR_BG
;;
M*)
# focused monitor
FG=$COLOR_FOCUSED_MONITOR_FG
BG=$COLOR_FOCUSED_MONITOR_BG
;;
esac
wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc monitor -f ${name}:} ${name} %{A}%{B-}%{F-}"
;;
[fFoOuU]*)
case $item in
f*)
# free desktop
FG=$COLOR_FREE_FG
BG=$COLOR_FREE_BG
;;
F*)
# focused free desktop
FG=$COLOR_FOCUSED_FREE_FG
BG=$COLOR_FOCUSED_FREE_BG
;;
o*)
# occupied desktop
FG=$COLOR_OCCUPIED_FG
BG=$COLOR_OCCUPIED_BG
;;
O*)
# focused occupied desktop
FG=$COLOR_FOCUSED_OCCUPIED_FG
BG=$COLOR_FOCUSED_OCCUPIED_BG
;;
u*)
# urgent desktop
FG=$COLOR_URGENT_FG
BG=$COLOR_URGENT_BG
;;
U*)
# focused urgent desktop
FG=$COLOR_FOCUSED_URGENT_FG
BG=$COLOR_FOCUSED_URGENT_BG
;;
esac
wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}"
;;
[LTG]*)
# layout, state and flags
wm="${wm}%{F$COLOR_STATE_FG}%{B$COLOR_STATE_BG} ${name} %{B-}%{F-}"
;;
esac
shift
done
;;
esac
printf "%s\n" "%{l}${wm}%{c}${title}%{r}${celcius} ${batt} ${sys}"
done
PANEL_FIFO=/tmp/panel-fifo
PANEL_HEIGHT=24
PANEL_FONT="-adobe-helvetica-medium-r-normal--17-*-*-*-*-*-*-*"
PANEL_WM_NAME=bspwm_panel
export PANEL_FIFO PANEL_HEIGHT PANEL_FONT PANEL_WM_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment