bspwm 的双屏设置

<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

解释一下:

  1. HDMI-1做为主显示器,它共有I II III IV V VI VII VIII IX九个桌面。
  2. eDP-1只有一个X桌面。
  3. 不方便的是,每次拔掉外接显示器都要重新启动一次bspwm才能使之生效。
  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值