Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2019-09-17 22:31 bspwm/.config/bspwm/bspwmrc Page 1
- #!/usr/bin/env bash
- # ----------------------------------------------------------------------------
- # desktops/monitors
- # ----------------------------------------------------------------------------
- desktopnames=(I II III IV V VI VII VIII IX X)
- # desktopnames=(🦊 '>_' 🦄 🤠 🍕)
- # monitors=$(bspc query -M | wc -l)
- # desktopspermonitor=$((desktops / monitors))
- # todo: get my second monitor back and see if any configuration is needed
- desktops=5
- bspc monitor -d ${desktopnames[@]:0:desktops}
- bspc config remove_disabled_monitors true
- bspc config remove_unplugged_monitors true
- # ----------------------------------------------------------------------------
- # border
- # ----------------------------------------------------------------------------
- #
- # geometry
- #
- bspc config border_width 2
- bspc config window_gap 12
- #
- # color
- #
- # todo: get colors from xresources
- # todo: tweak locked colors
- # bspc config active_border_color "#83a598"
- bspc config active_border_color "#1D667A"
- bspc config active_locked_border_color "#7E7F89"
- # bspc config focused_border_color "#11809E"
- # bspc config focused_border_color "#2aa198"
- # bspc config focused_border_color "#3c3836"
- bspc config focused_border_color "#cb4b16"
- bspc config focused_locked_border_color "#C7B579"
- # bspc config normal_border_color "#a0a0a0"
- bspc config normal_border_color "#3F3E3B"
- bspc config normal_locked_border_color "#3F3E3B"
- # bspc config presel_border_color "#A7BF81"
- bspc config presel_border_color "#ff0000"
- bspc config presel_feedback_color "#9b9b9b"
- bspc config urgent_border_color "#EFA29A"
- # ----------------------------------------------------------------------------
- # behavior
- # ----------------------------------------------------------------------------
- bspc config split_ratio 0.5
- bspc config borderless_monocle true
- bspc config gapless_monocle true
- bspc config pointer_follows_monitor true
- # bspc config initial_polarity first_child
- # bspc config focus_follows_pointer true
- # bspc config automatic_scheme spiral
- # bspc config click_to_focus any
- # bspc config pointer_modifier mod1
- # ----------------------------------------------------------------------------
- # rules
- # ----------------------------------------------------------------------------
- #
- # external rules
- #
- bspc config external_rules_command "$HOME/.config/bspwm/external_rules"
- #
- # simple rules
- #
- bspc rule -r '*' # todo: this is most definitely unneeded
- bspc rule -a Firefox desktop='^1' follow=on
- bspc rule -a konsole desktop='^2' follow=on
- bspc rule -a code-oss desktop='^3' follow=on
- bspc rule -a GitKraken desktop='^4' follow=on
- bspc rule -a qBittorrent desktop='^5'
- bspc rule -a 'Tor Browser' desktop='^5' state=floating
- bspc rule -a 'Yad' state=floating
- # plasma workarounds
- bspc rule -a plasmashell state=floating sticky=on border=off layer=above
- bspc rule -a krunner state=floating layer=above sticky=on border=off
- # bspc rule -a Gimp desktop='^8' state=floating follow=on
- # bspc rule -a Chromium desktop='^2'
- # bspc rule -a mplayer2 state=floating
- # bspc rule -a Kupfer.py focus=on
- # bspc rule -a Screenkey manage=off
- # ----------------------------------------------------------------------------
- # ADOPT - don't lose already open windows when switching wms on the go
- # ----------------------------------------------------------------------------
- # invert window order on adopting (normal behavior makes the last used window the smallest)
- bspc config initial_polarity first_child
- bspc config automatic_scheme spiral
- bspc wm --adopt-orphans
- # todo: would be really nice to not unminimize the windows on adoption
- # reset normal ordering behavior
- bspc config initial_polarity second_child
- bspc config automatic_scheme longest_side
- # ----------------------------------------------------------------------------
- # remove rules that need to be applied on launch only
- # ----------------------------------------------------------------------------
- # bspc rule -r konsole
- # ----------------------------------------------------------------------------
- # run things
- # ----------------------------------------------------------------------------
- # compton -b
- # polybar example &>/dev/null &# redirect stdout
- # ungrab plasma hotkeys
- qdbus org.kde.plasmanetworkmanagement /modules/khotkeys quit
- qdbus org.kde.keyboard /modules/khotkeys reread_configuration
- kquitapp5 kglobalaccel
- # grab bspwm hotkeys
- killall sxhkd
- sleep 0.1
- # sxhkd -c<(cat "$HOME"/.config/sxhkd/sxhkdrc "$HOME"/.config/sxhkd/sxhkdrc-bspwm) 1>/dev/null &
- sxhkd -c "$HOME/.config/sxhkd/sxhkdrc" "$HOME/.config/sxhkd/sxhkdrc-bspwm"
- sleep 0.1
- # restore plasma hotkeys
- kglobalaccel5 >/dev/null 2>&1 &
- # for n in $(bspc query -N); do
- # bspc node "$n" -g hidden=off
- # done
- # xdotool search --class "krunner" windowunmap
- # xdotool search --class "plasmashell" windowunmap
- 2019-09-03 18:26 bspwm/.config/bspwm/external_rules Page 1
- #!/usr/bin/env bash
- wid=$1
- class=$2
- instance=$3
- # open new windows in preselection if it's active and ignore the rules
- pn=$(bspc query -N -n newest.\!automatic.local) && echo "node=$pn"
- # if [ "$instance" = fontforge ]; then
- # title=$(xtitle "$wid")
- # case "$title" in
- # Layers | Tools | Warning)
- # echo "focus = off"
- # ;;
- # esac
- # if [[ $instance == plasmashell ]]; then
- # # echo hidden=off
- # bspwm_root_id=$(xdo id -N Bspwm -n root | sort | head -n 1)
- # xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" $wid
- # for wid in $(xdotool search --class plasmashell); do
- # xdo below -t "$bspwm_root_id" "$wid"
- # done
- # fi
- 2019-09-17 22:29 sxhkd/.config/sxhkd/sxhkdrc-bspwm Page 1
- #
- # bspwm hotkeys
- #
- # quit/restart bspwm
- # shouldn't be used in plasma+bspwm session, use wm-switch.sh in that case
- super + ctrl + alt + {q,r}
- bspc {quit,wm -r}
- # close and kill
- alt + {_,shift + }F4
- bspc node -{c,k}
- # super + {_,shift + }x
- # bspc node -{c,k}
- #
- # state/flags
- #
- # set the window state
- super + F1; {t,r,f,g}
- bspc node -t {tiled,pseudo_tiled,floating,fullscreen}
- # set the node flags
- super + F1; {m,l,s,p}
- bspc node -g {marked,locked,sticky,private}
- # toggle all hidden
- super + d
- bspwm-helper.sh showdesktop
- # hide window
- super + F4
- bspc node -g hidden
- # unhide window
- super + shift + F4
- bspc node $(bspc query -N -n .hidden | tail -n1) -g hidden=off
- # toggle floating
- super + f
- bspwm-helper.sh togglefloating
- # bspc node -t ~floating
- # toggle fullscreen
- super + shift+ F1
- bspc node -t ~fullscreen
- # bspwm-helper.sh togglefullscreen
- #
- # layout
- #
- # alternate between the tiled and monocle layout
- super + F1; F1
- bspc desktop -l next
- #
- # cross-desktop control
- #
- # super+x/z to move between desktops in the current monitor
- super + {x,z}
- bspc desktop -f {next,prev}.local
- # bspc desktop -f {next,prev}
- super + shift + {x,z}
- bspc node --to-desktop {next,prev}.local --follow
- # super+scroll to move between desktops
- super + button{4,5}
- bspc desktop -f {next,prev}
- super + shift + button{4,5}
- bspc node --to-desktop {next,prev} --follow
- # focus desktop (if selecting the same desktop, go to recent desktop)
- super + {1-9,0}
- a='^{1-9,10}'; \
- [ "$(bspc query -D -d "$a")" != "$(bspc query -D -d)" ] \
- && bspc desktop -f "$a" || bspc desktop -f last
- # send to the given desktop
- super + shift + {1-9,0}
- bspc node -d '^{1-9,10}'
- super + shift + Tab
- bspc node -d last --follow
- #
- # focus
- #
- # focus the node in the given direction
- super + {Left,Down,Up,Right}
- bspc node -f {west,south,north,east}
- # focus the older or newer node in the focus history (a bit different from alt-tab)
- # super + {g,f}
- alt + {Tab,shift + Tab}
- bspc wm -h off; \
- bspc node {older,newer} -f; \
- bspc wm -h on
- # focus the last node/desktop
- super + {grave,Tab}
- bspc {node,desktop} -f last
- # focus the next/previous node in the current desktop
- super + {_,shift + }c
- bspc node -f {next,prev}.local
- # focus the node for the given path jump
- # super + {p,b,comma,period}
- # bspc node -f @{parent,brother,first,second}
- #
- # node movement
- #
- # rotate/circulate
- super + shift + {a,d}
- bspc node @parent -R {-90,90}
- super + shift + {f,s}
- bspc node @parent -C {forward,backward}
- super + ctrl + shift + {a,d}
- bspc node @/ -R {90,-90}
- super + ctrl + shift + {f,s}
- bspc node @/ -C {forward,backward}
- # swap the current node and the biggest node
- super + shift + b
- bspc node -s biggest
- # swap the node in the given direction
- # super + shift + {Left,Down,Up,Right}
- # bspc node -s {west,south,north,east}
- # swap tile / move a floating window
- super + shift + {Left,Down,Up,Right}
- if bspwm-helper.sh caps_enabled; then step=50; else step=20; fi; \
- [ -z "$(bspc query -N -n .focused.floating)" ] && {\
- bspc node -s west || bspc node -v -$step 0,\
- bspc node -s south || bspc node -v 0 $step,\
- bspc node -s north || bspc node -v 0 -$step,\
- bspc node -s east || bspc node -v $step 0}
- # move left upper corner
- super + alt + {Left,Down,Up,Right}
- if bspwm-helper.sh caps_enabled; then step=50; else step=20; fi; \
- bspc node -z {left -$step 0,top 0 $step,top 0 -$step,left $step 0}
- # move right bottom corner
- super + alt + shift + {Left,Down,Up,Right}
- if bspwm-helper.sh caps_enabled; then step=50; else step=20; fi; \
- bspc node -z {right -$step 0,bottom 0 $step,bottom 0 -$step,right $step 0}
- #
- # preselect
- #
- super + ctrl + w; space
- bspc node -n newest.!automatic.local; bspc node -p cancel
- super + ctrl + w: {Left,Down,Up,Right}
- bspc node -p ~{west,south,north,east}
- super + ctrl + w: {1-9}
- bspc node -o 0.{1-9}
- super + ctrl + w; q
- bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel
- # send focused to preselected
- super + ctrl + space
- bspc node -n newest.!automatic.local
- # send the newest marked node to the newest preselected node
- # super + ctrl + space
- # bspc node newest.marked.local -n newest.!automatic.local
- # preselect the direction or cancel preselection if same direction is chosen twice
- super + ctrl + {Left,Down,Up,Right}
- 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 desktop
- super + ctrl + z
- bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel
- # cancel the preselection for the focused node
- # super + ctrl + shift + z
- # bspc node -p cancel
- 2019-09-17 22:40 scripts/.local/bin/wm-switch Page 1
- #!/usr/bin/env bash
- # set -x
- function kill_wms_and_bars() {
- killall kwin_x11
- killall bspwm
- killall awesome
- killall polybar
- killall compton
- sleep 0.1
- }
- function reload_plasma() {
- killall plasmashell
- killall redshift # redshift would flicker if we don't kill it. it gets restarted with plasma
- sleep 0.1
- plasmashell --replace &
- # kquitapp5 plasmashell && kstart5 plasmashell
- }
- function reload_hotkeys() {
- local type="$1"
- if [ -z "$type" ]; then
- if pgrep bspwm &>/dev/null; then
- type="bspwm"
- fi
- fi
- # ungrab plasma hotkeys so that they don't conflict
- qdbus org.kde.plasmanetworkmanagement /modules/khotkeys quit
- qdbus org.kde.keyboard /modules/khotkeys reread_configuration
- kquitapp5 kglobalaccel
- # ungrab sxhkd
- killall sxhkd
- notify "reloading hotkeys"
- sleep 0.1
- # grab sxhkd first so that they override all other hotkeys
- case "$type" in
- "kwin")
- sxhkd 1>/dev/null &
- ;;
- "bspwm")
- # sxhkd -c <(cat "$HOME"/.config/sxhkd/sxhkdrc "$HOME"/.config/sxhkd/sxhkdrc-bspwm) 1>/dev/null &
- sxhkd -c "$HOME/.config/sxhkd/sxhkdrc" "$HOME/.config/sxhkd/sxhkdrc-bspwm" 1>/dev/null &
- ;;
- esac
- sleep 0.1
- # regrab plasma hotkeys
- kglobalaccel5 >/dev/null 2>&1 &
- }
- function notify() {
- notify-send "$@" &
- }
- function to_bspwm() {
- notify "activating bspwm"
- kill_wms_and_bars
- sleep 0.1
- bspwm >/dev/null &
- # plasma must be alive when launching bspwm so that it doesn't occupy the panel space
- # after launching bspwm, reload plasma to fix some random plasmashell windows being visible, etc
- notify "reloading plasma"
- sleep 0.5
- reload_plasma
- sleep 2
- # fix plasma panel being on top of fullscreen windows
- notify "fixing fullscreen panel"
- bspwm_root_id=$(xdo id -N Bspwm -n root | sort | head -n 1)
- for wid in $(xdotool search --class plasmashell); do
- xdo below -t "$bspwm_root_id" "$wid"
- done
- # xdo lower -N plasmashell
- # xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" $wid
- killall compton
- compton -b --blur-kern "$(compton-convgen.py gaussian 15 -f sigma=3.14 --dump-compton)" --opacity-rule="35:class_g = 'Bspwm' && class_i = 'presel_feedback'"
- # compton -b --blur-method kawase --blur-strength 3
- }
- function to_kwin() {
- notify "activating kwin"
- kill_wms_and_bars
- kwin_x11 --replace 1>/dev/null &
- reload_hotkeys
- # recover windows that were lost when switching
- xdo show -d
- xdo show -D
- }
- function help() {
- echo 'usage: wm-switch.sh [OPTION]
- A script to switch between WMs.
- OPTIONS:
- -h, --help show this help
- kwin switch to kwin
- bspwm switch to bspwm
- sxhkd reload sxhkd
- '
- }
- function main() {
- case "$1" in
- bspwm) to_bspwm ;;
- kwin) to_kwin ;;
- reload-hotkeys) shift && reload_hotkeys "$@" ;;
- -h | --help) help ;;
- *) echo "No such command: $*" && help ;;
- esac
- }
- main "$@"
- 2019-09-15 03:49 scripts/.local/bin/bspwm-helper.sh Page 1
- #!/usr/bin/env bash
- #region utils
- function notify() {
- timeout 0.5 notify-send "$@"
- }
- function hextodec() {
- # convert hex to dec
- printf "%d\n" "$1"
- }
- function hextodec_strip() {
- # convert hex prefixed with 0x to dec
- num=$(echo "$1" | cut -b 3-) # strip 0x part
- hextodec "$num"
- }
- function dectohex() {
- # convert dec to hex
- out=$(printf '%08x\n' "$1") # convert to hex padded to 8 digits with 0s
- out=${out^^} # make uppercase
- out="0x$out" # add 0x prefix
- echo "$out"
- }
- function hexify() {
- # convert number to hex if not prefixed with 0x
- if [[ $1 == 0x* ]]; then #todo: posixfy
- echo "$1"
- else
- dectohex "$1"
- fi
- }
- #endregion
- #region bspwm utils
- function get_focused_node() {
- bspc query -N -n focused
- }
- function fix_node_id() {
- # attempt to convert to hex if value seems like a decimal id
- # if no id, get focused node id. because empty id in quotes will break bspwm's implied focused node
- # and i'd like to leave quotes because shellcheck is nagging
- hexify "${1:-$(get_focused_node)}"
- }
- function node_is() {
- local selector="$1"
- local hexid="$2" # id in form of 0x0000000A
- [ -n "$(bspc query -N -n "$hexid$selector")" ]
- }
- function is_hidden() {
- node_is ".hidden" "$1"
- }
- #endregion
- function printkeynames() {
- cat /usr/include/X11/keysymdef.h
- }
- function togglehidden() {
- # toggle hidden state by id. focus the unhidden node
- if [ -z "$1" ]; then
- notify "can't hide node: no node provided"
- return
- fi
- local hexid
- hexid=$(hexify "$1")
- # bspc node "$hexid" -g hidden
- if is_hidden "$hexid"; then
- bspc node "$hexid" -g hidden=off
- bspc node -f "$hexid"
- else
- bspc node "$hexid" -g hidden=on
- fi
- }
- function showdesktop() {
- # hide/unhide all windows on current desktop
- bspc node @/.local -g hidden
- return
- if [ -z "$(bspc query -N -n .local.hidden)" ]; then
- # hide all
- # bspc node any.local.\!hidden -g hidden=on
- bspc node @/.local.\!hidden -g hidden=on
- # for id in $(bspc query -N -n .local.\!hidden); do
- # bspc node "$id" -g hidden=on
- # done
- else
- # bspc node any.local.hidden -g hidden=off
- bspc node @/.local.hidden -g hidden=off
- #unhide all
- # for id in $(bspc query -N -n .local.hidden); do
- # bspc node "$id" -g hidden=off
- # done
- fi
- }
- function togglefloating() {
- # toggle between floating and tiled state by id. with no id default to focused.
- # it's possible to use `bspc node -t ~floating` but if you make a floating node fullscreen,
- # then it will be switching between fullscreen and floating mode.
- # requiring you to specifically select tiled
- local hexid
- hexid=$(fix_node_id "$1")
- if node_is ".floating" "$hexid"; then
- bspc node "$hexid" -t tiled
- echo "tiling"
- else
- bspc node "$hexid" -t floating
- echo "floating"
- fi
- }
- function togglefullscreen() {
- # toggle between fullscreen and tiled state by id. with no id default to focused
- # refer to togglefloating() why it's not `bspc node -t ~fullscreen`
- local hexid
- hexid=$(fix_node_id "$1")
- if node_is ".fullscreen" "$hexid"; then
- bspc node "$hexid" -t tiled
- echo "tiling"
- else
- bspc node "$hexid" -t fullscreen
- echo "fullscreen"
- fi
- }
- function togglehiddenbyname() {
- hexid=$(jumpapp -L "$1" | sed -n 2p | cut -b -10)
- bspc node "$hexid" -g hidden=off
- # bspwm-helper.sh togglehidden "$a"
- }
- function caps_enabled() {
- [ "$(xset -q | grep Caps | sed -e 's/.*Caps Lock:\s*//g' | cut -b -2)" = "on" ]
- }
- # function dynamicmove() {
- # desktopnames=(I II III IV V VI VII VIII IX X)
- # desktops=$(bspc query -D)
- # if [ $1 -gt ${#desktops[@]} ]; then
- # bspc monitor -d ${desktopnames[@]:0:$1}
- # fi
- # bspc node -d "^$1"
- # }
- # function preselect() {
- # local node
- # node=$(bspc query -N -n focused.\!automatic.local)
- # if [ -z "$node" ]; then
- # bspc node -p "$1"
- # else
- # bspc node -p cancel
- # fi
- # }
- function help() {
- echo 'usage: bspwm-helper.sh OPTION
- A helper script for bspwm actions that are a pain to remember how to write properly.
- OPTIONS:
- -h, --help show this help
- togglehidden (id) toggle hidden flag on a window
- togglefloating [id] toggle between tiled and floating state. id defaults to focused node.
- togglefullscreen [id] toggle between tiled and fullscreen state. id defaults to focused node.
- togglehiddenbyname [name] toggle between tiled and fullscreen state. id defaults to focused node.
- showdesktop a
- printkeynames a
- '
- }
- case "$1" in
- -h | --help) help ;;
- togglehidden) shift && togglehidden "$1" ;;
- togglefloating) shift && togglefloating "$1" ;;
- togglefullscreen) shift && togglefullscreen "$1" ;;
- showdesktop) showdesktop ;;
- printkeynames) printkeynames ;;
- togglehiddenbyname) shift && togglehiddenbyname "$1" ;;
- caps_enabled) caps_enabled ;;
- # preselect) shift && preselect "$1" ;;
- *) echo "No such command $1" && help ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement