bspwmを設定してみる
bspwmとは?
linux環境などで利用できるタイル型ウィンドウマネージャー。
類似なウィンドウマネージャーではi3やawesome、dwmなどがあり、それぞれ好みで利用できる。
linuxは無料で提供されているので、色々と自分の好みによって選べばいいと思う。
上の画像はbraveとalacrittyを2画面出していて、画面上部はpolybarを設定している。picomで半透明化しているので背景画像も見ながら作業ができる。
インストール
archl inuxでのインストールは以下のとおり。arch wiki に書いてあるそのままになる。
sudo pacman -S bspwm
sudo pacman -S sxhkd
bspwmはウィンドウ環境を設定するだけなので、keybindについてはsxhkdを利用しないとならない。
各種設定
xinitの設定
インストールしたらxinitで起動できるように設定する。
~/.xinitrcに以下の書き込みをおこなう。
## bspwm
sxhkd &
exec bspwm
bspwmの設定
~/.config/bspwm/bspwmrcに各種記載を行う。
#! /bin/sh
pgrep -x sxhkd > /dev/null || sxhkd &
# モニターが複数ある場合は、xrandrでモニター名を調べて記載
# 自分の設定では、ウィンドウ1〜6をメインディスプレイに、ウィンドウ7〜9をセカンドディスプレイに
bspc monitor eDP1 -d 1 2 3 4 5 6
bspc monitor DP1 -d 7 8 9
# ウィンドウのボーダー線の太さと、ウィンドウ同士の間を設定
bspc config border_width 1
bspc config window_gap 12
bspc config split_ratio 0.52
bspc config borderless_monocle true
bspc config gapless_monocle true
# 各ウィンドウごとのルールを設定
# 全画面表示させるか、タイル型にするかなどがウィンドウ毎に設定できる
bspc rule -a Gimp desktop='^8' state=floating follow=on
bspc rule -a Emacs state=tiled
bspc rule -a mplayer2 state=floating
bspc rule -a Kupfer.py focus=on
bspc rule -a Screenkey manage=off
#### BSPWM coloring ####
bspc config normal_border_color "#4c566a"
bspc config active_border_color "#1e1e1e"
bspc config focused_border_color "#5e81ac"
bspc config presel_feedback_color "#5e81ac"
bspc config urgent_border_color "#dd2727"
# 起動時に立ち上げるプログラムを設定する
killall sxhkd # これは必須
sxhkd & # これは必須
picom &
fcitx &
ntfd &
nm-applet &
blueman-applet &
#### polybar ####
sh /home/hoge/.config/polybar/launch.sh
#### background ####
sh /home/hoge/.config/bspwm/feh.sh
Polybarの設定
polybarについてはお好みの設定でやる必要あり
サンプルでついているものをベースに自分なりの設定を実施
フォントについては、Play、mononoki nerd font、unifontをインストールしてつかっている
~/.config/polybar/configファイルを作成し好みの設定に書き換える
;==========================================================
;
;
; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗
; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗
; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝
; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗
; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║
; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
;
;
; To learn more about how to configure Polybar
; go to https://github.com/polybar/polybar
;
; The README contains a lot of information
;
;==========================================================
[colors]
background = #aa2F343F
background-alt = #444
foreground = #dfdfdf
foreground-alt = #bfbfbf
primary = #ffb52a
secondary = #e60053
alert = #bd2c40
[bar/default]
monitor = ${env:MONITOR:eDP1}
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 = Play:pixelsize=12;1
font-1 = unifont:fontformat=truetype:size=12:antialias=false;0
font-2 = siji:pixelsize=18;1
font-3 = "Iosevka Nerd Font Mono:pixelsize=22;4"
font-4 = "WeatherIcons:size=15"
font-5 = "MaterialIcons:size=17"
modules-left = powermenu bspwm mpd
modules-center = xwindow
modules-right = cpu memory battery xbacklight pulseaudio xkeyboard date
tray-position = right
tray-padding = 2
cursor-click = pointer
cursor-scroll = ns-resize
[bar/default2]
monitor = ${env:MONITOR:DP1}
width = 100%
height = 27
;offset-x = 1%
;offset-y = 1%
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 = Play:pixelsize=12;1
font-1 = unifont:fontformat=truetype:size=12:antialias=false;0
font-2 = siji:pixelsize=18;1
font-3 = "Iosevka Nerd Font Mono:pixelsize=22;4"
modules-left = bspwm
modules-center = mpd
modules-right = date
cursor-click = pointer
cursor-scroll = ns-resize
[module/xwindow]
type = internal/xwindow
label = %title:0:30:...%
[module/xkeyboard]
type = internal/xkeyboard
blacklist-0 = num lock
format-prefix = " "
format-prefix-foreground = ${colors.foreground-alt}
format-prefix-underline = ${colors.secondary}
label-layout = %layout%
label-layout-underline = ${colors.secondary}
label-indicator-padding = 2
label-indicator-margin = 1
label-indicator-background = ${colors.secondary}
label-indicator-underline = ${colors.secondary}
[module/filesystem]
type = internal/fs
interval = 25
mount-0 = /
label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %percentage_used%%
label-unmounted = %mountpoint% not mounted
label-unmounted-foreground = ${colors.foreground-alt}
[module/bspwm]
type = internal/bspwm
label-font = 3
pin-workspaces = true
inline-mode = false
enable-click = true
enable-scroll = false
reverse-scroll = false
fuzzy-match = true
ws-icon-0 = 1;1.
ws-icon-1 = 2;2.
ws-icon-2 = 3;3.
ws-icon-3 = 4;4.
ws-icon-4 = 5;5.
ws-icon-5 = 6;6.
ws-icon-6 = 7;7.♛
ws-icon-7 = 8;8.♜
ws-icon-8 = 9;9.♞
ws-icon-default =
; Available tags:
; <label-monitor>
; <label-state> - gets replaced with <label-(focused|urgent|occupied|empty)>
; <label-mode> - gets replaced with <label-(monocle|tiled|fullscreen|floating|locked|sticky|private)>
; Default: <label-state>
format = <label-monitor> <label-state> <label-mode>
; Available tokens:
; %name%
; Default: %name%
label-monitor = %name%
; If any values for label-dimmed-N are defined, the workspace/mode
; colors will get overridden with those values if the monitor is out of focus
; To only override workspaces in a specific state, use:
; label-dimmed-focused
; label-dimmed-occupied
; label-dimmed-urgent
; label-dimmed-empty
label-dimmed-foreground = #555
label-dimmed-underline = ${bar/top.background}
label-dimmed-focused-background = #f00
; Available tokens:
; %name%
; %icon%
; %index%
; Default: %icon% %name%
label-focused = %icon%
label-focused-foreground = #ffffff
label-focused-background = #3f3f3f
label-focused-underline = #fba922
; Available tokens:
; %name%
; %icon%
; %index%
; Default: %icon% %name%
label-occupied = %icon%
label-occupied-underline = #555555
; Available tokens:
; %name%
; %icon%
; %index%
; Default: %icon% %name%
label-urgent = %icon%
label-urgent-foreground = #000000
label-urgent-background = #bd2c40
label-urgent-underline = #9b0a20
; Available tokens:
; %name%
; %icon%
; %index%
; Default: %icon% %name%
label-empty = %icon%
label-empty-foreground = #555
; Separator in between workspaces
label-separator = |
label-separator-padding = 2
label-separator-foreground = #ffb52a
[module/i3]
type = internal/i3
format = <label-state> <label-mode>
index-sort = true
wrapping-scroll = false
; Only show workspaces on the same output as the bar
;pin-workspaces = true
label-mode-padding = 2
label-mode-foreground = #000
label-mode-background = ${colors.primary}
; focused = Active workspace on focused monitor
label-focused = %index%
label-focused-background = ${colors.background-alt}
label-focused-underline= ${colors.primary}
label-focused-padding = 2
; unfocused = Inactive workspace on any monitor
label-unfocused = %index%
label-unfocused-padding = 2
; visible = Active workspace on unfocused monitor
label-visible = %index%
label-visible-background = ${self.label-focused-background}
label-visible-underline = ${self.label-focused-underline}
label-visible-padding = ${self.label-focused-padding}
; urgent = Workspace with urgency hint set
label-urgent = %index%
label-urgent-background = ${colors.alert}
label-urgent-padding = 2
[module/mpd]
type = internal/mpd
format-online = <label-song> <icon-prev> <icon-stop> <toggle> <icon-next>
icon-prev =
icon-stop =
icon-play =
icon-pause =
icon-next =
label-song-maxlen = 25
label-song-ellipsis = true
[module/xbacklight]
type = internal/xbacklight
format = <label> <bar>
label = BL
bar-width = 7
bar-indicator = |
bar-indicator-foreground = #fff
bar-indicator-font = 2
bar-fill = ─
bar-fill-font = 2
bar-fill-foreground = #9f78e1
bar-empty = ─
bar-empty-font = 2
bar-empty-foreground = ${colors.foreground-alt}
[module/backlight-acpi]
inherit = module/xbacklight
type = internal/backlight
card = intel_backlight
[module/cpu]
type = internal/cpu
interval = 2
format-prefix = " "
format-prefix-foreground = ${colors.foreground-alt}
format-underline = #f90000
label = %percentage:2%%
[module/memory]
type = internal/memory
interval = 2
format-prefix = " "
format-prefix-foreground = ${colors.foreground-alt}
format-underline = #4bffdc
label = %percentage_used%%
[module/wlan]
type = internal/network
interface = wlp2s0
interval = 3.0
format-connected = <ramp-signal> <label-connected>
format-connected-underline = #9f78e1
label-connected = %essid%
format-disconnected =
ramp-signal-0 =
ramp-signal-1 =
ramp-signal-2 =
ramp-signal-3 =
ramp-signal-4 =
ramp-signal-foreground = ${colors.foreground-alt}
[module/eth]
type = internal/network
interface = ppp0
interval = 3.0
format-connected-underline = #55aa55
format-connected-prefix = " "
format-connected-prefix-foreground = ${colors.foreground-alt}
label-connected = %local_ip%
format-disconnected =
[module/date]
type = internal/date
interval = 5
date-alt =
date = " %Y-%m-%d"
time = %H:%M
time-alt = %H:%M:%S
format-prefix =
format-prefix-foreground = ${colors.foreground-alt}
format-underline = #0a6cf5
label = %date% %time%
[module/pulseaudio]
type = internal/pulseaudio
format-volume = <label-volume> <bar-volume>
label-volume = VOL %percentage%%
label-volume-foreground = ${root.foreground}
label-muted = 🔇 muted
label-muted-foreground = #666
bar-volume-width = 7
bar-volume-foreground-0 = #55aa55
bar-volume-foreground-1 = #55aa55
bar-volume-foreground-2 = #55aa55
bar-volume-foreground-3 = #55aa55
bar-volume-foreground-4 = #55aa55
bar-volume-foreground-5 = #f5a70a
bar-volume-foreground-6 = #ff5555
bar-volume-gradient = false
bar-volume-indicator = |
bar-volume-indicator-font = 2
bar-volume-fill = ─
bar-volume-fill-font = 2
bar-volume-empty = ─
bar-volume-empty-font = 2
bar-volume-empty-foreground = ${colors.foreground-alt}
[module/alsa]
type = internal/alsa
format-volume = <label-volume> <bar-volume>
label-volume = VOL
label-volume-foreground = ${root.foreground}
format-muted-prefix = " "
format-muted-foreground = ${colors.foreground-alt}
label-muted = sound muted
bar-volume-width = 10
bar-volume-foreground-0 = #55aa55
bar-volume-foreground-1 = #55aa55
bar-volume-foreground-2 = #55aa55
bar-volume-foreground-3 = #55aa55
bar-volume-foreground-4 = #55aa55
bar-volume-foreground-5 = #f5a70a
bar-volume-foreground-6 = #ff5555
bar-volume-gradient = false
bar-volume-indicator = |
bar-volume-indicator-font = 2
bar-volume-fill = ─
bar-volume-fill-font = 2
bar-volume-empty = ─
bar-volume-empty-font = 2
bar-volume-empty-foreground = ${colors.foreground-alt}
[module/battery]
type = internal/battery
battery = BAT0
adapter = AC
full-at = 98
format-charging = <animation-charging> <label-charging>
format-charging-underline = #ffb52a
format-discharging = <animation-discharging> <label-discharging>
format-discharging-underline = ${self.format-charging-underline}
format-full-prefix = " "
format-full-prefix-foreground = ${colors.foreground-alt}
format-full-underline = ${self.format-charging-underline}
ramp-capacity-0 =
ramp-capacity-1 =
ramp-capacity-2 =
ramp-capacity-foreground = ${colors.foreground-alt}
animation-charging-0 =
animation-charging-1 =
animation-charging-2 =
animation-charging-foreground = ${colors.foreground-alt}
animation-charging-framerate = 750
animation-discharging-0 =
animation-discharging-1 =
animation-discharging-2 =
animation-discharging-foreground = ${colors.foreground-alt}
animation-discharging-framerate = 750
[module/temperature]
type = internal/temperature
thermal-zone = 0
warn-temperature = 60
format = <ramp> <label>
format-underline = #f50a4d
format-warn = <ramp> <label-warn>
format-warn-underline = ${self.format-underline}
label = %temperature-c%
label-warn = %temperature-c%
label-warn-foreground = ${colors.secondary}
ramp-0 =
ramp-1 =
ramp-2 =
ramp-foreground = ${colors.foreground-alt}
[module/powermenu]
type = custom/menu
expand-right = true
format-spacing = 1
label-open =
label-open-foreground = ${colors.secondary}
label-close = cancel
label-close-foreground = ${colors.secondary}
label-separator = |
label-separator-foreground = ${colors.foreground-alt}
menu-0-0 = reboot
menu-0-0-exec = menu-open-1
menu-0-1 = power off
menu-0-1-exec = menu-open-2
menu-1-0 = cancel
menu-1-0-exec = menu-open-0
menu-1-1 = reboot
menu-1-1-exec = sudo reboot
menu-2-0 = power off
menu-2-0-exec = sudo poweroff
menu-2-1 = cancel
menu-2-1-exec = menu-open-0
[module/weather]
type = custom/script
exec = busctl --user -j get-property io.ntfd /weather openweathermap.strings RenderedTemplate | jq -r .data
label-font = 5
[settings]
screenchange-reload = true
pseudo-transparency = true
[global/wm]
margin-top = 5
margin-bottom = 5
背景画像の設定
背景色を5分おきで変更したいので以下のシェルを作成している
#! /bin/sh
killall -q feh
killall -q sleep
while true; do
feh --randomize --bg-fill /usr/share/backgrounds/archlinux/*
sleep 600
done
ちなみにすてきな背景画像がほしいな、と思ったらお気に入りのdistrotubeのDerek Taylorさんのgitlabにあったので、興味あれば。
sxhkdの設定
~/.config/sxhkd/sxhkdrcにkeybindを設定する。
ちなみに、自分の環境ではalacrittyをメインターミナルとして使っているので、super+enterで立ち上がるように設定している。
また、rofiでプログラムを起動するようにしているため、rofiのインストールしている。super+dで起動するようにカスタマイズ
#
# wm independent hotkeys
#
# terminal emulator
super + Return
alacritty
# program launcher
super + d
rofi -combi-modi window,drun,ssh -theme solarized -font "hack 12" -show combi -icon-theme "Papirus" -show-icons
super + i
xfce4-screenshooter
# make sxhkd reload its configuration files:
super + Escape
pkill -USR1 -x sxhkd
#
# bspwm hotkeys
#
# quit/restart bspwm
super + shift + {q,r}
bspc {quit,wm -r}
# close and kill
super + q
bspc node -{c,k}
# alternate between the tiled and monocle layout
super + m
bspc desktop -l next
# send the newest marked node to the newest preselected node
super + y
bspc node newest.marked.local -n newest.!automatic.local
# swap the current node and the biggest window
super + g
bspc node -s biggest.window
#
# state/flags
#
# set the window state
super + {t,shift + t,s,f}
bspc node -t {tiled,pseudo_tiled,floating,fullscreen}
# set the node flags
super + ctrl + {m,x,y,z}
bspc node -g {marked,locked,sticky,private}
#
# focus/swap
#
# focus the node in the given direction
super + {_,shift + }{h,j,k,l}
bspc node -{f,s} {west,south,north,east}
# focus the node for the given path jump
super + {p,b,comma,period}
bspc node -f @{parent,brother,first,second}
# focus the next/previous window in the current desktop
super + {_,shift + }c
bspc node -f {next,prev}.local.!hidden.window
# focus the next/previous desktop in the current monitor
super + bracket{left,right}
bspc desktop -f {prev,next}.local
# focus the last node/desktop
super + {grave,Tab}
bspc {node,desktop} -f last
# focus the older or newer node in the focus history
super + {o,i}
bspc wm -h off; \
bspc node {older,newer} -f; \
bspc wm -h on
# focus or send to the given desktop
super + {_,shift + }{1-9,0}
bspc {desktop -f,node -d} '^{1-9,10}'
#
# preselect
#
# preselect the direction
super + ctrl + {h,j,k,l}
bspc node -p {west,south,north,east}
# preselect the ratio
super + ctrl + {1-9}
bspc node -o 0.{1-9}
# cancel the preselection for the focused node
super + ctrl + space
bspc node -p cancel
# cancel the preselection for the focused desktop
super + ctrl + shift + space
bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel
#
# move/resize
#
# expand a window by moving one of its side outward
super + alt + {h,j,k,l}
bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}
# contract a window by moving one of its side inward
super + alt + shift + {h,j,k,l}
bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}
# move a floating window
super + {Left,Down,Up,Right}
bspc node -v {-20 0,0 20,0 -20,20 0}
これで一通りの設定は完成
この記事が気に入ったらサポートをしてみませんか?