Skip to content

Instantly share code, notes, and snippets.

@wimstefan
Created December 31, 2020 00:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wimstefan/64e17d257d07b666079628a7e1859823 to your computer and use it in GitHub Desktop.
Save wimstefan/64e17d257d07b666079628a7e1859823 to your computer and use it in GitHub Desktop.
bspwm external rules script
#! /bin/sh
logfile=/tmp/bspwm_external_rules.log
window_id="$1"
window_class="$2"
window_instance="$3"
window_title="$(xwininfo -id "$window_id" | sed '/^xwininfo/!d ; s,.*"\(.*\)".*,\1,')"
window_type="$(xprop -id "$window_id" _NET_WM_WINDOW_TYPE | sed '/^_NET_WM_WINDOW_TYPE/!d ; s/^.* = \(.*\),.*/\1/')"
case "$window_title" in
Calculator|Explore|Keybindings|Ranger|Scratchpad )
echo "state=floating"
;;
esac
case "$window_class" in
[Dd]arktable|[Gg]imp )
case "$window_type" in
*DIALOG* )
echo "state=floating"
echo "center=on"
;;
*_NET_WM_WINDOW_TYPE_NORMAL* )
echo "state=fullscreen"
;;
esac
;;
esac
case "$window_class" in
[Ss]cribus )
case "$window_title" in
Outline|Properties )
echo "state=floating"
;;
* )
echo "state=fullscreen"
;;
esac
;;
esac
echo "Id: $window_id" >> "$logfile"
echo "Class: $window_class" >> "$logfile"
echo "Instance: $window_instance" >> "$logfile"
echo "Title: $window_title" >> "$logfile"
echo "Type: $window_type" >> "$logfile"
echo "---" >> "$logfile"
@wimstefan
Copy link
Author

xprop output for Gimp dialog window:

_NET_WM_DESKTOP(CARDINAL) = 7
WM_STATE(WM_STATE):
		window state: Normal
		icon window: 0x0
WM_HINTS(WM_HINTS):
		Client accepts input or input focus: True
		Initial state is Normal State.
		bitmap id # to use for icon: 0x7c020f0
		bitmap id # of mask for icon: 0x7c020f1
		window id # of group leader: 0x7c00001
WM_WINDOW_ROLE(STRING) = "gimp-file-open"
WM_TRANSIENT_FOR(WINDOW): window id # 0x7c020cc
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 130032243
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DIALOG
_NET_WM_USER_TIME(CARDINAL) = 224228872
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x7c02272
WM_CLIENT_LEADER(WINDOW): window id # 0x7c00001
_NET_WM_PID(CARDINAL) = 29610
WM_LOCALE_NAME(STRING) = "en_US.utf8"
WM_CLIENT_MACHINE(STRING) = "swimmer"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
		user specified location: 0, 0
		program specified minimum size: 696 by 611
		window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "gimp", "Gimp"
WM_ICON_NAME(STRING) = "Open Image"
_NET_WM_ICON_NAME(UTF8_STRING) = "Open Image"
WM_NAME(STRING) = "Open Image"
_NET_WM_NAME(UTF8_STRING) = "Open Image"

@wimstefan
Copy link
Author

bspwmrc

#!/bin/sh
xsetroot -cursor_name left_ptr
pkill sxhkd
sxhkd -c ${HOME}/.config/bspwm/sxhkdrc &
pkill picom
while pgrep -x picom >/dev/null; do sleep 1; done
picom &
pkill dunst
dunst &
feh --bg-fill ${HOME}/system/wallpapers/default.jpg &
${HOME}/.config/polybar/launch.sh

source ${HOME}/.config/bspwm/scripts/bspwm_dimensions.sh

bspc monitor -d 1 2 3 4 5 6 7 8 9

bspc config border_width          04
bspc config normal_border_color   '#2e3440'
bspc config active_border_color   '#4e586d'
bspc config focused_border_color  '#8894aa'
bspc config window_gap            12
bspc config top_padding           $(echo ${POLYBAR_HEIGHT})
bspc config bottom_padding        04
bspc config left_padding          04
bspc config right_padding         04

bspc config split_ratio           0.50
bspc config borderless_monocle    true
bspc config gapless_monocle       false
bspc config focus_follows_pointer true
bspc config ignore_ewmh_focus     false

bspc rule -a \*                   state=floating
bspc rule -a \*:\*:sys            desktop='^1'
bspc rule -a \*:\*:work           desktop='^2'
bspc rule -a \*:\*:com            desktop='^3'
bspc rule -a \*:\*:tj             desktop='^3'
bspc rule -a \*:\*:komala         desktop='^5'
bspc rule -a \*:\*:tj-laptop      desktop='^6'
bspc rule -a \*:\*:home           desktop='^6'
bspc rule -a \*:\*:swimmer        desktop='^6'
bspc rule -a scribus              desktop='^7'
bspc rule -a Thunderbird          desktop='^7'
bspc rule -a 'VirtualBox Manager' desktop='^7'
bspc rule -a 'VirtualBox Machine' desktop='^7'
bspc rule -a Darktable            desktop='^8'
bspc rule -a Gimp                 desktop='^8'
bspc rule -a Inkscape             desktop='^8'
bspc rule -a Audacity             desktop='^9'
bspc rule -a puddletag            desktop='^9'
bspc rule -a Lxappearance         center=on rectangle=${newwidth}x${newheight}+${hor}+${ver}

bspc config external_rules_command ${HOME}/.config/bspwm/scripts/external_rules.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment