<2022-03-27 Sun>
bspwm
的双屏设置
大部分人用的都是i3
这个窗口管理器,bspwm
用的人不多,如何设置bspwm
双屏的文章估计就更少了,所以有必要记录一下。
我参考了:“Dual monitor setup with BSPWM and Polybar”,我这里暂时没有设置polybar
,因为要写的代码太多。
可以通过xrandr
来查看当前显示器连接情况:
% xrandr -q | grep connected
eDP-1 connected 1920x1080+3840+0 (normal left inverted right x axis y axis) 309mm x 173mm
HDMI-1 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)
% xrandr -q | grep HDMI-1
HDMI-1 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
看输出,我有一个外接显示器HDMI-1
放在左侧,笔记本自带显示器eDP-1
在右侧,同时要设置显示器的分辨率等等内容,见我的$HOME/.config/bspwm/bspwmrc
内容如下:
#! /bin/sh
pgrep -x sxhkd > /dev/null || sxhkd &
# Run the xrandr command if an external monitor is connected to the
# laptop. This must be executed before the polybar command, so that
# polybar can set the two separate bars properly.
# NOTE This is a simplistic approach because I already know the settings.
laptop_external_monitor=$(xrandr --query | grep 'HDMI-1')
target_str='HDMI-1 connected'
if [[ $laptop_external_monitor = *"$target_str"* ]]; then
xrandr --output HDMI-1 --primary --mode 3840x2160 --rotate normal \
--output eDP-1 --mode 1920x1080 --rotate normal \
--right-of HDMI-1
bspc monitor HDMI-1 -d I II III IV V VI VII VIII IX
bspc monitor eDP-1 -d X
else
bspc monitor -d I II III IV V VI VII VIII IX X
fi
bspc config border_width 1
bspc config window_gap 2
bspc config split_ratio 0.52
bspc config borderless_monocle true
bspc config gapless_monocle true
bspc config focused_border_color "#00ff00"
bspc rule -a Gimp desktop='^8' state=floating follow=on
bspc rule -a Chromium desktop='^2'
bspc rule -a firefox desktop='^2'
bspc rule -a mplayer2 state=floating
bspc rule -a Kupfer.py focus=on
bspc rule -a Screenkey manage=off
# bspc rule -a Display desktop='^9' follow=on
ibus-daemon &
~/.config/polybar/launch.sh
解释一下:
HDMI-1
做为主显示器,它共有I II III IV V VI VII VIII IX
九个桌面。eDP-1
只有一个X
桌面。- 不方便的是,每次拔掉外接显示器都要重新启动一次
bspwm
才能使之生效。