Advertisement
Guest User

bspwm things

a guest
Sep 17th, 2019
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 19.12 KB | None | 0 0
  1.  
  2.  
  3. 2019-09-17 22:31           bspwm/.config/bspwm/bspwmrc            Page 1
  4.  
  5.  
  6. #!/usr/bin/env bash
  7.  
  8. # ----------------------------------------------------------------------------
  9. # desktops/monitors
  10. # ----------------------------------------------------------------------------
  11.  
  12. desktopnames=(I II III IV V VI VII VIII IX X)
  13. # desktopnames=(🦊 '>_' 🦄 🤠 🍕)
  14.  
  15. # monitors=$(bspc query -M | wc -l)
  16. # desktopspermonitor=$((desktops / monitors))
  17. # todo: get my second monitor back and see if any configuration is needed
  18.  
  19. desktops=5
  20. bspc monitor -d ${desktopnames[@]:0:desktops}
  21. bspc config remove_disabled_monitors true
  22. bspc config remove_unplugged_monitors true
  23.  
  24. # ----------------------------------------------------------------------------
  25. # border
  26. # ----------------------------------------------------------------------------
  27.  
  28. #
  29. # geometry
  30. #
  31.  
  32. bspc config border_width 2
  33. bspc config window_gap 12
  34.  
  35. #
  36. # color
  37. #
  38.  
  39. # todo: get colors from xresources
  40. # todo: tweak locked colors
  41.  
  42. # bspc config active_border_color "#83a598"
  43. bspc config active_border_color "#1D667A"
  44. bspc config active_locked_border_color "#7E7F89"
  45.  
  46. # bspc config focused_border_color "#11809E"
  47. # bspc config focused_border_color "#2aa198"
  48. # bspc config focused_border_color "#3c3836"
  49. bspc config focused_border_color "#cb4b16"
  50. bspc config focused_locked_border_color "#C7B579"
  51.  
  52. # bspc config normal_border_color "#a0a0a0"
  53. bspc config normal_border_color "#3F3E3B"
  54. bspc config normal_locked_border_color "#3F3E3B"
  55.  
  56. # bspc config presel_border_color "#A7BF81"
  57. bspc config presel_border_color "#ff0000"
  58. bspc config presel_feedback_color "#9b9b9b"
  59.  
  60. bspc config urgent_border_color "#EFA29A"
  61.  
  62. # ----------------------------------------------------------------------------
  63. # behavior
  64. # ----------------------------------------------------------------------------
  65.  
  66. bspc config split_ratio 0.5
  67. bspc config borderless_monocle true
  68. bspc config gapless_monocle true
  69. bspc config pointer_follows_monitor true
  70. # bspc config initial_polarity first_child
  71. # bspc config focus_follows_pointer true
  72. # bspc config automatic_scheme spiral
  73. # bspc config click_to_focus any
  74. # bspc config pointer_modifier mod1
  75.  
  76. # ----------------------------------------------------------------------------
  77. # rules
  78. # ----------------------------------------------------------------------------
  79.  
  80. #
  81. # external rules
  82. #
  83.  
  84. bspc config external_rules_command "$HOME/.config/bspwm/external_rules"
  85.  
  86. #
  87. # simple rules
  88. #
  89.  
  90. bspc rule -r '*' # todo: this is most definitely unneeded
  91. bspc rule -a Firefox desktop='^1' follow=on
  92. bspc rule -a konsole desktop='^2' follow=on
  93. bspc rule -a code-oss desktop='^3' follow=on
  94. bspc rule -a GitKraken desktop='^4' follow=on
  95. bspc rule -a qBittorrent desktop='^5'
  96. bspc rule -a 'Tor Browser' desktop='^5' state=floating
  97. bspc rule -a 'Yad' state=floating
  98.  
  99. # plasma workarounds
  100. bspc rule -a plasmashell state=floating sticky=on border=off layer=above
  101. bspc rule -a krunner state=floating layer=above sticky=on border=off
  102.  
  103. # bspc rule -a Gimp desktop='^8' state=floating follow=on
  104. # bspc rule -a Chromium desktop='^2'
  105. # bspc rule -a mplayer2 state=floating
  106. # bspc rule -a Kupfer.py focus=on
  107. # bspc rule -a Screenkey manage=off
  108.  
  109. # ----------------------------------------------------------------------------
  110. # ADOPT - don't lose already open windows when switching wms on the go
  111. # ----------------------------------------------------------------------------
  112.  
  113. # invert window order on adopting (normal behavior makes the last used window the smallest)
  114. bspc config initial_polarity first_child
  115. bspc config automatic_scheme spiral
  116.  
  117. bspc wm --adopt-orphans
  118. # todo: would be really nice to not unminimize the windows on adoption
  119.  
  120. # reset normal ordering behavior
  121. bspc config initial_polarity second_child
  122. bspc config automatic_scheme longest_side
  123.  
  124. # ----------------------------------------------------------------------------
  125. # remove rules that need to be applied on launch only
  126. # ----------------------------------------------------------------------------
  127.  
  128. # bspc rule -r konsole
  129.  
  130. # ----------------------------------------------------------------------------
  131. # run things
  132. # ----------------------------------------------------------------------------
  133.  
  134. # compton -b
  135. # polybar example &>/dev/null &# redirect stdout
  136.  
  137. # ungrab plasma hotkeys
  138. qdbus org.kde.plasmanetworkmanagement /modules/khotkeys quit
  139. qdbus org.kde.keyboard /modules/khotkeys reread_configuration
  140. kquitapp5 kglobalaccel
  141.  
  142. # grab bspwm hotkeys
  143. killall sxhkd
  144. sleep 0.1
  145. # sxhkd -c<(cat "$HOME"/.config/sxhkd/sxhkdrc "$HOME"/.config/sxhkd/sxhkdrc-bspwm) 1>/dev/null &
  146. sxhkd -c "$HOME/.config/sxhkd/sxhkdrc" "$HOME/.config/sxhkd/sxhkdrc-bspwm"
  147. sleep 0.1
  148.  
  149. # restore plasma hotkeys
  150. kglobalaccel5 >/dev/null 2>&1 &
  151.  
  152. # for n in $(bspc query -N); do
  153. #     bspc node "$n" -g hidden=off
  154. # done
  155.  
  156. # xdotool search --class "krunner" windowunmap
  157. # xdotool search --class "plasmashell" windowunmap
  158.  
  159. 2019-09-03 18:26        bspwm/.config/bspwm/external_rules        Page 1
  160.  
  161.  
  162. #!/usr/bin/env bash
  163.  
  164. wid=$1
  165. class=$2
  166. instance=$3
  167.  
  168. # open new windows in preselection if it's active and ignore the rules
  169. pn=$(bspc query -N -n newest.\!automatic.local) && echo "node=$pn"
  170.  
  171. # if [ "$instance" = fontforge ]; then
  172. #     title=$(xtitle "$wid")
  173. #     case "$title" in
  174. #     Layers | Tools | Warning)
  175. #         echo "focus = off"
  176. #         ;;
  177. #     esac
  178.  
  179. # if [[ $instance == plasmashell ]]; then
  180. #     # echo hidden=off
  181. #     bspwm_root_id=$(xdo id -N Bspwm -n root | sort | head -n 1)
  182. # xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" $wid
  183. #     for wid in $(xdotool search --class plasmashell); do
  184. #         xdo below -t "$bspwm_root_id" "$wid"
  185. #     done
  186. # fi
  187.  
  188. 2019-09-17 22:29        sxhkd/.config/sxhkd/sxhkdrc-bspwm         Page 1
  189.  
  190.  
  191. #
  192. # bspwm hotkeys
  193. #
  194.  
  195. # quit/restart bspwm
  196. # shouldn't be used in plasma+bspwm session, use wm-switch.sh in that case
  197. super + ctrl + alt + {q,r}
  198.     bspc {quit,wm -r}
  199.  
  200. # close and kill
  201. alt + {_,shift + }F4
  202.     bspc node -{c,k}
  203. # super + {_,shift + }x
  204. #   bspc node -{c,k}
  205.  
  206.  
  207. #
  208. # state/flags
  209. #
  210.  
  211. # set the window state
  212. super + F1; {t,r,f,g}
  213.     bspc node -t {tiled,pseudo_tiled,floating,fullscreen}
  214.  
  215. # set the node flags
  216. super + F1; {m,l,s,p}
  217.     bspc node -g {marked,locked,sticky,private}
  218.  
  219. # toggle all hidden
  220. super + d
  221.     bspwm-helper.sh showdesktop
  222.  
  223. # hide window
  224. super + F4
  225.     bspc node -g hidden
  226.  
  227. # unhide window
  228. super + shift + F4
  229.     bspc node $(bspc query -N -n .hidden | tail -n1) -g hidden=off
  230.  
  231. # toggle floating
  232. super + f
  233.     bspwm-helper.sh togglefloating
  234. #   bspc node -t ~floating
  235.  
  236. # toggle fullscreen
  237. super + shift+ F1
  238.     bspc node -t ~fullscreen
  239. #   bspwm-helper.sh togglefullscreen
  240.  
  241. #
  242. # layout
  243. #
  244.  
  245. # alternate between the tiled and monocle layout
  246. super + F1; F1
  247.     bspc desktop -l next
  248.  
  249. #
  250. # cross-desktop control
  251. #
  252.  
  253. # super+x/z to move between desktops in the current monitor
  254. super + {x,z}
  255.     bspc desktop -f {next,prev}.local
  256. #   bspc desktop -f {next,prev}
  257. super + shift + {x,z}
  258.     bspc node --to-desktop {next,prev}.local --follow
  259.  
  260. # super+scroll to move between desktops
  261. super + button{4,5}
  262.     bspc desktop -f {next,prev}
  263. super + shift + button{4,5}
  264.     bspc node --to-desktop {next,prev} --follow
  265.  
  266. # focus desktop (if selecting the same desktop, go to recent desktop)
  267. super + {1-9,0}
  268.     a='^{1-9,10}'; \
  269.     [ "$(bspc query -D -d "$a")" != "$(bspc query -D -d)" ] \
  270.     && bspc desktop -f "$a" || bspc desktop -f last
  271.  
  272. # send to the given desktop
  273. super + shift + {1-9,0}
  274.     bspc node -d '^{1-9,10}'
  275.  
  276. super + shift + Tab
  277.     bspc node -d last --follow
  278.  
  279. #
  280. # focus
  281. #
  282.  
  283. # focus the node in the given direction
  284. super + {Left,Down,Up,Right}
  285.     bspc node -f {west,south,north,east}
  286.  
  287. # focus the older or newer node in the focus history (a bit different from alt-tab)
  288. # super + {g,f}
  289. alt + {Tab,shift + Tab}
  290.     bspc wm -h off; \
  291.     bspc node {older,newer} -f; \
  292.     bspc wm -h on
  293.  
  294. # focus the last node/desktop
  295. super + {grave,Tab}
  296.     bspc {node,desktop} -f last
  297.  
  298. # focus the next/previous node in the current desktop
  299. super + {_,shift + }c
  300.     bspc node -f {next,prev}.local
  301.  
  302. # focus the node for the given path jump
  303. # super + {p,b,comma,period}
  304. #   bspc node -f @{parent,brother,first,second}
  305.  
  306.  
  307.  
  308. #
  309. # node movement
  310. #
  311.  
  312. # rotate/circulate
  313. super + shift + {a,d}
  314.     bspc node @parent -R {-90,90}
  315. super + shift + {f,s}
  316.     bspc node @parent -C {forward,backward}
  317. super + ctrl + shift + {a,d}
  318.     bspc node @/ -R {90,-90}
  319. super + ctrl + shift + {f,s}
  320.     bspc node @/ -C {forward,backward}
  321.  
  322. # swap the current node and the biggest node
  323. super + shift + b
  324.     bspc node -s biggest
  325.  
  326. # swap the node in the given direction
  327. # super + shift + {Left,Down,Up,Right}
  328. #   bspc node -s {west,south,north,east}
  329.  
  330. # swap tile / move a floating window
  331. super + shift + {Left,Down,Up,Right}
  332.     if bspwm-helper.sh caps_enabled; then step=50; else step=20; fi; \
  333.     [ -z "$(bspc query -N -n .focused.floating)" ] && {\
  334.         bspc node -s west  || bspc node -v -$step 0,\
  335.         bspc node -s south || bspc node -v 0   $step,\
  336.         bspc node -s north || bspc node -v 0   -$step,\
  337.         bspc node -s east  || bspc node -v $step  0}
  338.  
  339. # move left upper corner
  340. super + alt + {Left,Down,Up,Right}
  341.     if bspwm-helper.sh caps_enabled; then step=50; else step=20; fi; \
  342.     bspc node -z {left -$step 0,top 0 $step,top 0 -$step,left $step 0}
  343.  
  344. # move right bottom corner
  345. super + alt + shift + {Left,Down,Up,Right}
  346.     if bspwm-helper.sh caps_enabled; then step=50; else step=20; fi; \
  347.     bspc node -z {right -$step 0,bottom 0 $step,bottom 0 -$step,right $step 0}
  348.  
  349.  
  350.  
  351. #
  352. # preselect
  353. #
  354.  
  355. super + ctrl + w; space
  356.     bspc node -n newest.!automatic.local; bspc node -p cancel
  357. super + ctrl + w: {Left,Down,Up,Right}
  358.     bspc node -p ~{west,south,north,east}
  359. super + ctrl + w: {1-9}
  360.     bspc node -o 0.{1-9}
  361. super + ctrl + w; q
  362.     bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel
  363.  
  364. # send focused to preselected
  365. super + ctrl + space
  366.     bspc node -n newest.!automatic.local
  367. # send the newest marked node to the newest preselected node
  368. # super + ctrl + space
  369. #   bspc node newest.marked.local -n newest.!automatic.local
  370.  
  371. # preselect the direction or cancel preselection if same direction is chosen twice
  372. super + ctrl + {Left,Down,Up,Right}
  373.     bspc node -p ~{west,south,north,east}
  374.  
  375. # preselect the ratio
  376. super + ctrl + {1-9}
  377.     bspc node -o 0.{1-9}
  378.  
  379. # cancel the preselection for the focused desktop
  380. super + ctrl + z
  381.     bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel
  382.  
  383. # cancel the preselection for the focused node
  384. # super + ctrl + shift + z
  385. #   bspc node -p cancel
  386.  
  387.  
  388. 2019-09-17 22:40           scripts/.local/bin/wm-switch           Page 1
  389.  
  390.  
  391. #!/usr/bin/env bash
  392. # set -x
  393.  
  394. function kill_wms_and_bars() {
  395.     killall kwin_x11
  396.     killall bspwm
  397.     killall awesome
  398.     killall polybar
  399.     killall compton
  400.     sleep 0.1
  401. }
  402.  
  403. function reload_plasma() {
  404.     killall plasmashell
  405.     killall redshift # redshift would flicker if we don't kill it. it gets restarted with plasma
  406.     sleep 0.1
  407.     plasmashell --replace &
  408.  
  409.     # kquitapp5 plasmashell && kstart5 plasmashell
  410. }
  411.  
  412. function reload_hotkeys() {
  413.     local type="$1"
  414.  
  415.     if [ -z "$type" ]; then
  416.         if pgrep bspwm &>/dev/null; then
  417.             type="bspwm"
  418.         fi
  419.     fi
  420.  
  421.     # ungrab plasma hotkeys so that they don't conflict
  422.     qdbus org.kde.plasmanetworkmanagement /modules/khotkeys quit
  423.     qdbus org.kde.keyboard /modules/khotkeys reread_configuration
  424.     kquitapp5 kglobalaccel
  425.  
  426.     # ungrab sxhkd
  427.     killall sxhkd
  428.  
  429.     notify "reloading hotkeys"
  430.     sleep 0.1
  431.  
  432.     # grab sxhkd first so that they override all other hotkeys
  433.     case "$type" in
  434.     "kwin")
  435.         sxhkd 1>/dev/null &
  436.         ;;
  437.     "bspwm")
  438.         # sxhkd -c <(cat "$HOME"/.config/sxhkd/sxhkdrc "$HOME"/.config/sxhkd/sxhkdrc-bspwm) 1>/dev/null &
  439.         sxhkd -c "$HOME/.config/sxhkd/sxhkdrc" "$HOME/.config/sxhkd/sxhkdrc-bspwm" 1>/dev/null &
  440.         ;;
  441.     esac
  442.  
  443.     sleep 0.1
  444.  
  445.     # regrab plasma hotkeys
  446.     kglobalaccel5 >/dev/null 2>&1 &
  447.  
  448. }
  449.  
  450. function notify() {
  451.     notify-send "$@" &
  452. }
  453.  
  454. function to_bspwm() {
  455.     notify "activating bspwm"
  456.  
  457.     kill_wms_and_bars
  458.     sleep 0.1
  459.  
  460.     bspwm &#1>/dev/null &
  461.  
  462.     # plasma must be alive when launching bspwm so that it doesn't occupy the panel space
  463.     # after launching bspwm, reload plasma to fix some random plasmashell windows being visible, etc
  464.     notify "reloading plasma"
  465.     sleep 0.5
  466.     reload_plasma
  467.     sleep 2
  468.  
  469.     # fix plasma panel being on top of fullscreen windows
  470.     notify "fixing fullscreen panel"
  471.     bspwm_root_id=$(xdo id -N Bspwm -n root | sort | head -n 1)
  472.     for wid in $(xdotool search --class plasmashell); do
  473.         xdo below -t "$bspwm_root_id" "$wid"
  474.     done
  475.  
  476.     # xdo lower -N plasmashell
  477.  
  478.     # xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" $wid
  479.  
  480.     killall compton
  481.     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'"
  482.     # compton -b --blur-method kawase --blur-strength 3
  483. }
  484.  
  485. function to_kwin() {
  486.     notify "activating kwin"
  487.     kill_wms_and_bars
  488.     kwin_x11 --replace 1>/dev/null &
  489.     reload_hotkeys
  490.  
  491.     # recover windows that were lost when switching
  492.     xdo show -d
  493.     xdo show -D
  494. }
  495.  
  496. function help() {
  497.     echo 'usage: wm-switch.sh [OPTION]
  498.    A script to switch between WMs.
  499.  
  500. OPTIONS:
  501.    -h, --help              show this help
  502.    kwin                    switch to kwin
  503.    bspwm                   switch to bspwm
  504.    sxhkd                   reload sxhkd
  505. '
  506. }
  507.  
  508. function main() {
  509.     case "$1" in
  510.     bspwm) to_bspwm ;;
  511.     kwin) to_kwin ;;
  512.     reload-hotkeys) shift && reload_hotkeys "$@" ;;
  513.     -h | --help) help ;;
  514.     *) echo "No such command: $*" && help ;;
  515.     esac
  516. }
  517.  
  518. main "$@"
  519.  
  520. 2019-09-15 03:49        scripts/.local/bin/bspwm-helper.sh        Page 1
  521.  
  522.  
  523. #!/usr/bin/env bash
  524.  
  525. #region utils
  526.  
  527. function notify() {
  528.     timeout 0.5 notify-send "$@"
  529. }
  530.  
  531. function hextodec() {
  532.     # convert hex to dec
  533.     printf "%d\n" "$1"
  534. }
  535.  
  536. function hextodec_strip() {
  537.     # convert hex prefixed with 0x to dec
  538.     num=$(echo "$1" | cut -b 3-) # strip 0x part
  539.     hextodec "$num"
  540. }
  541.  
  542. function dectohex() {
  543.     # convert dec to hex
  544.     out=$(printf '%08x\n' "$1") # convert to hex padded to 8 digits with 0s
  545.     out=${out^^}                # make uppercase
  546.     out="0x$out"                # add 0x prefix
  547.     echo "$out"
  548. }
  549.  
  550. function hexify() {
  551.     # convert number to hex if not prefixed with 0x
  552.     if [[ $1 == 0x* ]]; then #todo: posixfy
  553.         echo "$1"
  554.     else
  555.         dectohex "$1"
  556.     fi
  557. }
  558.  
  559. #endregion
  560. #region bspwm utils
  561.  
  562. function get_focused_node() {
  563.     bspc query -N -n focused
  564. }
  565.  
  566. function fix_node_id() {
  567.     # attempt to convert to hex if value seems like a decimal id
  568.     # if no id, get focused node id. because empty id in quotes will break bspwm's implied focused node
  569.     # and i'd like to leave quotes because shellcheck is nagging
  570.     hexify "${1:-$(get_focused_node)}"
  571. }
  572.  
  573. function node_is() {
  574.     local selector="$1"
  575.     local hexid="$2" # id in form of 0x0000000A
  576.  
  577.     [ -n "$(bspc query -N -n "$hexid$selector")" ]
  578. }
  579.  
  580. function is_hidden() {
  581.     node_is ".hidden" "$1"
  582. }
  583.  
  584. #endregion
  585.  
  586. function printkeynames() {
  587.     cat /usr/include/X11/keysymdef.h
  588. }
  589.  
  590. function togglehidden() {
  591.     # toggle hidden state by id. focus the unhidden node
  592.     if [ -z "$1" ]; then
  593.         notify "can't hide node: no node provided"
  594.         return
  595.     fi
  596.  
  597.     local hexid
  598.     hexid=$(hexify "$1")
  599.  
  600.     # bspc node "$hexid" -g hidden
  601.     if is_hidden "$hexid"; then
  602.         bspc node "$hexid" -g hidden=off
  603.         bspc node -f "$hexid"
  604.     else
  605.         bspc node "$hexid" -g hidden=on
  606.     fi
  607. }
  608.  
  609. function showdesktop() {
  610.     # hide/unhide all windows on current desktop
  611.     bspc node @/.local -g hidden
  612.     return
  613.  
  614.     if [ -z "$(bspc query -N -n .local.hidden)" ]; then
  615.         # hide all
  616.         # bspc node any.local.\!hidden -g hidden=on
  617.         bspc node @/.local.\!hidden -g hidden=on
  618.         # for id in $(bspc query -N -n .local.\!hidden); do
  619.         #     bspc node "$id" -g hidden=on
  620.         # done
  621.     else
  622.         # bspc node any.local.hidden -g hidden=off
  623.         bspc node @/.local.hidden -g hidden=off
  624.         #unhide all
  625.         # for id in $(bspc query -N -n .local.hidden); do
  626.         #     bspc node "$id" -g hidden=off
  627.         # done
  628.     fi
  629. }
  630.  
  631. function togglefloating() {
  632.     # toggle between floating and tiled state by id. with no id default to focused.
  633.     # it's possible to use `bspc node -t ~floating` but if you make a floating node fullscreen,
  634.     # then it will be switching between fullscreen and floating mode.
  635.     # requiring you to specifically select tiled
  636.  
  637.     local hexid
  638.     hexid=$(fix_node_id "$1")
  639.  
  640.     if node_is ".floating" "$hexid"; then
  641.         bspc node "$hexid" -t tiled
  642.         echo "tiling"
  643.     else
  644.         bspc node "$hexid" -t floating
  645.         echo "floating"
  646.     fi
  647. }
  648.  
  649. function togglefullscreen() {
  650.     # toggle between fullscreen and tiled state by id. with no id default to focused
  651.     # refer to togglefloating() why it's not `bspc node -t ~fullscreen`
  652.  
  653.     local hexid
  654.     hexid=$(fix_node_id "$1")
  655.  
  656.     if node_is ".fullscreen" "$hexid"; then
  657.         bspc node "$hexid" -t tiled
  658.         echo "tiling"
  659.     else
  660.         bspc node "$hexid" -t fullscreen
  661.         echo "fullscreen"
  662.     fi
  663. }
  664.  
  665. function togglehiddenbyname() {
  666.     hexid=$(jumpapp -L "$1" | sed -n 2p | cut -b -10)
  667.     bspc node "$hexid" -g hidden=off
  668.     # bspwm-helper.sh togglehidden "$a"
  669. }
  670.  
  671. function caps_enabled() {
  672.     [ "$(xset -q | grep Caps | sed -e 's/.*Caps Lock:\s*//g' | cut -b -2)" = "on" ]
  673. }
  674.  
  675. # function dynamicmove() {
  676. #     desktopnames=(I II III IV V VI VII VIII IX X)
  677. #     desktops=$(bspc query -D)
  678. #     if [ $1 -gt ${#desktops[@]} ]; then
  679. #         bspc monitor -d ${desktopnames[@]:0:$1}
  680. #     fi
  681. #     bspc node -d "^$1"
  682. # }
  683. # function preselect() {
  684. #     local node
  685. #     node=$(bspc query -N -n focused.\!automatic.local)
  686. #     if [ -z "$node" ]; then
  687. #         bspc node -p "$1"
  688. #     else
  689. #         bspc node -p cancel
  690. #     fi
  691. # }
  692.  
  693. function help() {
  694.     echo 'usage: bspwm-helper.sh OPTION
  695.    A helper script for bspwm actions that are a pain to remember how to write properly.
  696.  
  697. OPTIONS:
  698.    -h, --help              show this help
  699.    togglehidden (id)           toggle hidden flag on a window
  700.    togglefloating [id]         toggle between tiled and floating state. id defaults to focused node.
  701.    togglefullscreen [id]       toggle between tiled and fullscreen state. id defaults to focused node.
  702.    togglehiddenbyname [name]   toggle between tiled and fullscreen state. id defaults to focused node.
  703.    showdesktop                 a
  704.    printkeynames               a
  705. '
  706. }
  707.  
  708. case "$1" in
  709. -h | --help) help ;;
  710. togglehidden) shift && togglehidden "$1" ;;
  711. togglefloating) shift && togglefloating "$1" ;;
  712. togglefullscreen) shift && togglefullscreen "$1" ;;
  713. showdesktop) showdesktop ;;
  714. printkeynames) printkeynames ;;
  715. togglehiddenbyname) shift && togglehiddenbyname "$1" ;;
  716. caps_enabled) caps_enabled ;;
  717. # preselect) shift && preselect "$1" ;;
  718. *) echo "No such command $1" && help ;;
  719. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement