You are not logged in.
I recently added polybar to my bspwm multihead setup, and I'm experiencing problems while hotplugging a monitor. polybar transfers to plugged in external monitor, but with weird margins and desktops numbering starting from 6 instead of 1. By the same token, it vanishes from the laptop display, leaving a weird margin in its stead.
Could someone help me figuring this out? I'm not looking for anything fancy here:
single monitor: one instance of polybar showing desktops 1 through 0
on plugging-in external monitor: one instance per monitor, external numbering 1-5, laptop remaining desktops
on removing external monitor: back to one instance with 1 to 0 desktops
I'm using a simple script to cover monitor hot-plugging:
#!/bin/bash
displaynum=`ls /tmp/.X11-unix/* | sed s#/tmp/.X11-unix/X##`
display=":$displaynum.0"
export DISPLAY=":$displaynum.0"
export XAUTHORITY=$(ps -C Xorg -f --no-header | sed -n 's/.*-auth //; s/ -[^ ].*//; p')
connect() {
n_desktops=5
xrandr --output HDMI-1 --mode 1920x1080 --above eDP-1 --primary
for desktop in $(bspc query -D -m eDP-1 | sed "$n_desktops"q); do
bspc desktop $desktop --to-monitor HDMI-1
done
bspc desktop Desktop --remove > /dev/null
bspc wm --reorder-monitors eDP-1 HDMI-1
}
disconnect() {
bspc monitor HDMI-1 -a Desktop > /dev/null
for desktop in $(bspc query -D -m HDMI-1); do
if ! [[ $desktop = "Desktop" ]]; then
bspc desktop $desktop --to-monitor eDP-1
fi
done
bspc desktop Desktop --remove > /dev/null
bspc wm --reorder-monitors HDMI-1 eDP-1
bspc monitor HDMI-1 --remove > /dev/null
xrandr --output HDMI-1 --off
}
if [ $(cat /sys/class/drm/card0-HDMI-A-1/status) == "connected" ] ; then
connect
elif [ $(cat /sys/class/drm/card0-HDMI-A-1/status) == "disconnected" ] ; then
disconnect
else
exit
fi
bspwm config:
#!/usr/bin/env zsh
bspc monitor eDP-1 -d 1 2 3 4 5 6 7 8 9 0
$XDG_CONFIG_HOME/polybar/start.sh
bspc config border_width 2
bspc config window_gap 8
bspc config top_padding 10
bspc config left_padding 10
bspc config right_padding 10
bspc config bottom_padding 10
bspc config normal_border_color "#272822"
bspc config focused_border_color "#fd971f"
bspc config active_border_color "#fd971f"
for side in top right bottom left; do
bspc config ${side}_monocle_padding -10;
done
bspc config split_ratio 0.50
bspc config borderless_monocle true
bspc config gapless_monocle true
bspc config single_monocle false
bspc config focus_follows_pointer true
bspc config ignore_ewmh_focus false
bspc config center_pseudo_tiled true
bspc config honor_size_hints false
bspc config remove_disabled_monitors true
bspc config remove_unplugged_monitors true
#bspc config merge_overlapping_monitors true
bspc rule -a Dialog state=floating centre=true
bspc rule -a mpv state=floating centre=true
bspc rule -a Pinentry-gtk-2 state=floating centre=true
bspc rule -a feh state=floating centre=true
bspc rule -a Zathura state=tiled
bspc rule -a chromium private=on
bspc rule -a Anki state=floating
And the script used to start the polybar:
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
MONITOR=$m polybar --reload $m &
done
For the completeness sake, here's the actual polybar config (nothing more that trimmed down default):
[colors]
;background = ${xrdb:color0:#222}
background = #222
background-alt = #444
;foreground = ${xrdb:color7:#222}
foreground = #dfdfdf
foreground-alt = #555
primary = #ffb52a
secondary = #e60053
alert = #bd2c40
[bar/eDP-1]
monitor = eDP-1
width = 100%
height = 27
radius = 6.0
fixed-center = false
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 3
line-color = #f00
border-size = 4
border-color = #00000000
padding-left = 0
padding-right = 2
module-margin-left = 1
module-margin-right = 2
font-0 = fixed:pixelsize=10;1
font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
font-2 = siji:pixelsize=10;1
modules-left = bspwm
wm-restack = bspwm
[bar/HDMI-1]
monitor = HDMI-1
width = 100%
height = 27
radius = 6.0
fixed-center = false
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 3
line-color = #f00
border-size = 4
border-color = #00000000
padding-left = 0
padding-right = 2
module-margin-left = 1
font-0 = fixed:pixelsize=10;1
font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
font-2 = siji:pixelsize=10;1
modules-left = bspwm
[module/bspwm]
type = internal/bspwm
label-focused = %name%
label-focused-background = ${colors.background-alt}
label-focused-underline= ${colors.primary}
label-focused-padding = 2
label-occupied = %name%
label-occupied-padding = 2
label-urgent = %name%!
label-urgent-background = ${colors.alert}
label-urgent-padding = 2
label-empty = %name%
label-empty-foreground = ${colors.foreground-alt}
label-empty-padding = 2
; Only show workspaces on the same output as the bar
pin-workspaces = true
[settings]
screenchange-reload = true
[global/wm]
margin-top = 5
margin-bottom = 5
I'm kind off stumped as to what am I doing wrong here, and would appreciate help and suggestions!
Last edited by boojum (2020-06-30 11:44:55)
Offline