Guest User

Bspwm tutorial

a guest
May 22nd, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.71 KB | None | 0 0
  1. # Bspwm tutorial
  2.  
  3. By [**Chrysostomus**](https://classicforum.manjaro.org/index.php?action=profile;u=4519) From [classicforum.manjaro.org](https://classicforum.manjaro.org/index.php?topic=18970.0) 21/12/2014
  4.  
  5.  
  6.  
  7. ## **Table of contents**
  8.  
  9. [TOC]
  10.  
  11. ------
  12.  
  13.  
  14.  
  15. ## **What is it?**
  16.  
  17. Bspwm (binary space partitioning window manager) is fairly young window manager, and in active development. Like openbox, it can be used with desktop environment like xfce or lxqt, or on its own. It is particularly suited for people who don't have workflow set in stone.
  18.  
  19. It may not be the lightest nor the most stable window manager out there, but it makes up for it with ease of use and powerful features. That is not to say that it is heavy or unstable. I think it is lighter than openbox, just not as tiny and minimalistic as dwm or monsterwm or as unshakable as xmonad.
  20.  
  21. Bspwm is easy to configure, but tricky to setup if you don't know what you are doing. To remedy this, I wrote this little guide to help.
  22.  
  23. ### **Features:**
  24.  
  25. Watch this screencast to understand:
  26.  
  27. ![Image](https://raw.githubusercontent.com/windelicato/dotfiles/master/why_bspwm.gif)
  28.  
  29. Like herbstluftwm, bspwm is driven with terminal commands that can be bound to hotkeys. Also like herbstluftwm, the configuration file is just autostart file that runs commands for setting rules.
  30.  
  31. Bspwm is a tiling window manager like dwm, awesome, i3 or xmonad. This means that windows do not usually overlap with each other. Instead, all the available space on screen is automatically divided between them. This saves time and ensures that screen real-estate is used efficiently. Bspwm can also float windows. Unlike dwm or xmonad, you can move windows with mouse without making them floating. Unlike awesome wm, you can have tiled and floating windows in same workspace. Otherwise mouse controls are quite close to awesome wm.
  32.  
  33. Bspwm features a combination of automatic tiling (like awesome, dwm and xmonad) and manual tiling (like herbstluftwm, musca and i3). When you open a new window, one of the existing windows is divided in half (or whatever splitting ratio you have set) to make room for the new window. There are no predefined layouts. Open more windows, and they form a spiral. However, you can manually choose where the new window is created, or split existing window and move another window to the split.
  34.  
  35. Tiling window managers require you to use workspaces or tags actively, since everything is usually visible and not minimized. Moving things between them is usually easier than in most stacking wms. You can add and delete workspaces and give them names. You can also make windows 'sticky', which means they are visible in all workspaces.
  36.  
  37. Bspwm also has option to have gaps between the windows, which can be adjusted on the fly. It also has pseudo-floating windows, which are placed like tiling windows, but can have any size.
  38.  
  39. ### **Who should use bspwm?**
  40.  
  41. Many tiling wm users like to have very specific workflow. Browser always goes to "web" workspace and so on. While this is also possible with bspwm, its combination of manual and automatic tiling make it suited for unplanned or irregular workflow. Windows just go to a reasonable place, and adjusting things is intuitive, if something feels weird.
  42.  
  43. Tiling wms are good match for small screens, because all screen real-estate is used efficiently and managing maximized windows is simple.
  44. They are also suited for big screens, because they save time you would otherwise use moving windows around.
  45. In particular bspwm is suited for people who like tweak and tinker with stuff. You won't be getting out of the bix experience, but you'll be making things work just the way you like them.
  46. Also, it is quite light. It works very smoothly even on older hardware, and won't cause suicidal feelings if you run it on raspberry pi. I think.
  47.  
  48. ### **Who should steer clear of bspwm?**
  49.  
  50. \- The learning curve can be harsh if you are only used to running a full desktop environment. So if you dislike learning new stuff, bspwm probably is not for you.
  51. \- Bspwm sometimes crashes, if you have too many floating dialog windows open (for example, when editing colors of lxterminal or searching stuff with geany or extracting .tar files with fileroller). This can be a deal breaker for some people if you save your open text files rarely.
  52. \- Plugging in additional monitors or projectors requires some manual intervention or scripting. So if you are giving lectures often on varying locations, be aware that it can br more cumbersome with bspwm (requires two commands from commandline, or preconfigured script).
  53. \- If you dislike building stuff yourself and want things to just work, bspwm might not be your cup of tea.
  54.  
  55. ## **How to install bspwm:**
  56.  
  57. Manjaro devs have made this very easy for us.
  58.  
  59.  
  60.  
  61. ```bash
  62. sudo pacman -Syu bspwm
  63. ```
  64.  
  65. Bspwm does not provide panel or hotkeys by it self. For hotkeys you can use xbindkeys, but sxhkd is recommended instead. Following command installs some commonly used utilities:
  66.  
  67.  
  68.  
  69. ```bash
  70. sudo pacman -S sxhkd bar dmenu xdo xdotool xtitle sutils
  71. ```
  72.  
  73.  
  74. This includes sxhkd for hotkeys and dmenu for starting apps. The rest is for the example bar and some sxhkd functions.
  75.  
  76. If you wish to use latest version of bspwm, run instead
  77.  
  78.  
  79.  
  80. ```bash
  81. sudo yaourt -S bspwm-git
  82. ```
  83.  
  84. This can give you access to new features like mouse_follows_focus.
  85.  
  86. Bspwm does not automatically create desktop or session files that could be run from display manager (graphical login screen). These if you want to use dm, you need to manually copy them from
  87. https://github.com/baskerville/bspwm/tree/master/contrib/lightdm to
  88.  
  89.  
  90.  
  91. ```bash
  92. /usr/bin/bspwm-session
  93. ```
  94.  
  95. and
  96.  
  97.  
  98.  
  99. ```bash
  100. /usr/share/xsessions/bspwm.desktop
  101. ```
  102.  
  103. . Copying to this location requires sudo rights. After this, bspwm should be available as option in your login screen.
  104.  
  105. Alternatively, you can run bspwm from console with command startx. For that you need to create/configure
  106.  
  107.  
  108.  
  109. ```bash
  110. ~/.xinitrc
  111. ```
  112.  
  113. (script that is run when you isse command startx) to start bspwm (and any other programs you wish to run, such as nitrogen for bacground, xfsettingsd to make xfce4-settings-manager work and so on). An extremely minimal .xinitrc would contain just:
  114.  
  115.  
  116.  
  117.  
  118.  
  119. ```bash
  120. sxhkd &
  121. exec bspwm
  122. ```
  123.  
  124.  
  125. Make sure everything is placed before exec bspwm and had & after it like sxhkd does in the example.
  126.  
  127. Now you can launch bspwm (maybe), but it is really not usable yet. Copy
  128. https://github.com/baskerville/bspwm/blob/master/examples/bspwmrc to
  129.  
  130.  
  131.  
  132. ```bash
  133. ~/.config/bspwm/bspwmrc
  134. ```
  135.  
  136. and run
  137.  
  138.  
  139.  
  140. ```bash
  141. chmod +x ~/.config/bspwm/bspwmrc
  142. ```
  143.  
  144. This gives you the default configuration file of bspwm, and marks it executable.
  145. Also copy https://github.com/baskerville/bspwm/blob/master/examples/sxhkdrc to
  146.  
  147.  
  148.  
  149. ```bash
  150. ~/.config/sxhkd/sxhkdrc
  151. ```
  152.  
  153. to get default key bindings of bspwm. You can check the binds from here, and edit them as you wish. Syntax is really simple, just follow the pattern of the file.
  154.  
  155. ------
  156.  
  157. ## **How to use bspwm:**
  158.  
  159. \- mouse controls
  160. If you have
  161. `bspc config focus_follows_pointer true`
  162. In your bspwmrc, you can move focus by moving your mouse over them.
  163.  
  164. Otherwise your mouse controls depend on your sxhkdrc. If you have there
  165.  
  166. ```bash
  167. ~button1
  168. bspc pointer -g focus
  169. ```
  170.  
  171. You can focus windows by clicking them. A must have if you don't use focus_follows_pointer
  172.  
  173. You can focus windows by clicking them. A must have if you don't use focus_follows_pointer
  174.  
  175. Since you copied the default config, your sxhkdrc also has:
  176.  
  177. ```bash
  178. super + button{1-3}
  179. bspc pointer -g {move,resize_side,resize_corner}
  180.  
  181. super + !button{1-3}
  182. bspc pointer -t %i %i
  183.  
  184. super + @button{1-3}
  185. bspc pointer -u
  186. ```
  187.  
  188. This means that when you hold the super key, you can move windows with left mouse drag and resize them by dragging with other mouse buttons. Dragging tiled window over another switches their places, and floating windows just float like usual.
  189.  
  190. I personally use mygtkmenu to toggle window properties (tiled, floating, pseudo-floating, fullscreen, monocle) with mouse. My sxhkdrc something like
  191.  
  192. Mod5 + !button1
  193. mytgkmenu /path/to/menu/file/
  194.  
  195. So that when I hold alt_gr and click with mouse, a nice pops up. My menufile can be found from xxxxx
  196.  
  197. Keyboard controls:
  198. These are largely up to you and configs you copy. Most keybindings start wth super key. Default directions are h j k l, but I like to change them to w a s d or arrow keys. Super + direction moves focus between windows, super + number moves focus between desktops. If you also press shift, you move focused window instead of just focus. In default config super + alt (+shift) + direction resizes windows.
  199.  
  200. Super + x closes window,
  201. Super + space opens dmenu so you can run applications,
  202. Super + s toggles floating
  203. Super + f toggles fullscreen
  204.  
  205. Those are probably the most important things. The rest can be found in your sxhkdrc.
  206.  
  207. ------
  208.  
  209. Converting existing manjaro installation with desktop environment may produce usable and visually appealing results. In that case, you can skip creating bspwm-session file and use session of the desktop environment instead.
  210.  
  211. Bspwm integrates nicely with xfce, lxqt, lxde and probably kde. At least xfce and lxqt have nice session manager, that lets you configure what is autostarted. Remove openbox/xfwm4 from there and replace it with bspwm. Also add sxhkd to autostart list, so that you have your keybindings and mousebindings.
  212.  
  213. Desktops often come with a panel, so you should have in your bspwmrc
  214.  
  215.  
  216.  
  217. ```bash
  218. bspc config top_padding x
  219. ```
  220.  
  221. Replace top with bottom, left or right depending where you put your panel, and x with size of your panel in pixels.
  222.  
  223. ### **Some things to consider with xfce:**
  224.  
  225. \- whiskermenu and xfdesktop are not clickable if you use
  226.  
  227.  
  228.  
  229. ```bash
  230. bspc config focus_follows_pointer true
  231. ```
  232.  
  233. If you like them, you should remove this from your bspwmrc
  234.  
  235. \- xfdesktop and xfce4-panel have significant delay starting if you do not disable their window manager check. Try to modify their autostart commands to
  236.  
  237.  
  238.  
  239. ```bash
  240. xfce4-panel -d
  241. ```
  242.  
  243. and
  244.  
  245.  
  246.  
  247. ```bash
  248. xfdesktop -D
  249. ```
  250.  
  251.  
  252.  
  253. ### **Some things to consider with lxqt:**
  254.  
  255. \- by default, bspwm tiles the desktop created by lxqt-desktop. You probably don't want that.
  256.  
  257.  
  258.  
  259. ```bash
  260. bspc rule -a lxqt-desktop border=off manage=off
  261. ```
  262.  
  263. Might help. Check the window name with xprop.
  264.  
  265. ------
  266.  
  267. The lightest way to run bspwm is to run it as standalone window manager. This uses the least ram and boots the fastest.
  268.  
  269. ## **Settings daemon**
  270.  
  271. One of the decisions you need to make is whether or not to use settings-daemon. This blurs the line between using bspwm alone or with desktop environment. I recommend using this, especially for beginners, because it makes things much easier and adds only about 5mb ram usage. For me the benefits are:
  272. \- I can use xfce-settings-manager to configure screen, themes, printers and so on
  273. \- the touchpad on my laptop works better. Right click is easier to make, mouse is not too sensitive and wont go crazy. Palm detections works.
  274.  
  275. Options for settings daemon include:
  276. \- xfsettingsd
  277. \- gsettingsd
  278. \- whatever lxqt uses
  279. \- kde probably has one too
  280.  
  281. My advice: don't use gnome settings daemon. Sure, gnome control center is great and it will fix your mouse, but it will mess other things up and is a pain to configure. Also, many depencies. Worst, it uses much cpu, so it will drain your battery quickly.
  282.  
  283. xfsettingsd work well in my experience. I like the xfce4-settings-manager the least, but it is good enough and works. Haven't tried others so much. Anyway, to use it, install xfce4-settings and add
  284.  
  285.  
  286.  
  287. ```bash
  288. xfsettingsd &
  289. ```
  290.  
  291. to your autostart file (~/.config/bspwm/autostart if you are using the bspwm-session, ~/.xinitrc if you are using startx)
  292.  
  293. ## **Appearance**
  294.  
  295. If you don't use settings daemon, use lxappearance to configure appearance of your apps. This does not use extra ram.
  296.  
  297. ### **Pulseaudio**
  298.  
  299. If you want to use pulseaudio without DE, add
  300.  
  301.  
  302.  
  303. ```bash
  304. /usr/bin/start-pulseaudio-x11 &
  305. ```
  306.  
  307. your autostart file. You can install pulseaudio with
  308.  
  309.  
  310.  
  311. ```bash
  312. sudo pacman -S manjaro-pulse pavucontrol
  313. ```
  314.  
  315. I also recommend pulseaudio-ctl and pnmixer for managing volume from system tray and sxhkd.
  316.  
  317. ### **System tray**
  318.  
  319. If you use xfce4-panel, lxqt-panel, bmpanel2 or tint2, you have system tray by default. However, if you use bspwms default panel, it wont have one. You can add it with trayer, stalonetray or something like that. I use stalonetray, with same background color as my panel, so it looks like part of the panel. Configure ̃/.stalontrayrc to place the tray where you want it and add
  320.  
  321.  
  322.  
  323. ```bash
  324. stalonetray &
  325. ```
  326.  
  327. to your autostart.
  328.  
  329. ------
  330.  
  331.  
  332.  
  333. If you want to access bspwms functions with mouse, there are some options
  334. \- mygtkmenu
  335. \- 9menu
  336. \- gnome-pie
  337.  
  338. ### **Gnome-pie**
  339.  
  340. This is the heaviest option with most eyecandy. It is also easy to configure with gui. I like to bind one piemenu with window manager options to long pressing right click.
  341. One thing to consider: If you want to toggle window properties with gnome-pie, you need rule
  342.  
  343.  
  344.  
  345. ```bash
  346. bspc rule -a gnome-pie border=off manage=off
  347. ```
  348.  
  349. Otherwise any commands apply only to the pie menu itself, which is then closed instantly. However, this prevents you from editing settings from the gnome-pie system tray icon. So you might want to have pie item or hotkey to toggle this setting.
  350. You can install gnome-pie with
  351.  
  352.  
  353.  
  354. ```bash
  355. sudo pacman -S gnome-pie
  356. ```
  357.  
  358.  
  359.  
  360. ### **9menu**
  361.  
  362. 9menu is light, does not run on background and is very configurable. However, it does not handle submenus very well. Also, I know no way of making autoupdating appmenu with it. It can be good for desktop level menus, but I really don't recommend it, because mygtkmenu does same things better. If you are still interested and want to have some starting point, you can dig my configs from here: http://sourceforge.net/projects/manjarobspwmrespin/files/manjaroiso%20build/ (http://sourceforge.net/projects/manjarobspwmrespin/files/manjaroiso%20build/)
  363.  
  364. ### **Mygtkmenu**
  365.  
  366. It requires installing stuff from AUR and it has more depencies than 9menu, but it is very nice and my preferred choice. Unlike gnome-pie, it does not run on background, so it does not use resources if you are not using it.
  367. To install it:
  368.  
  369.  
  370.  
  371. ```bash
  372. yaourt -S mygtkmenu
  373. ```
  374.  
  375.  
  376. and for some additional functions
  377.  
  378.  
  379.  
  380. ```bash
  381. yaourt -S menumaker-compiz
  382. ```
  383.  
  384.  
  385. My menufiles can be found from here:
  386.  
  387.  
  388.  
  389. ```
  390. https://sourceforge.net/projects/manjarobspwmrespin/files/config%20files/Mygtkmenu/?
  391. ```
  392.  
  393. To use my menufiles, copy MouseLaunch and update_menu.sh to your scripts folder and everything else to ~/.config/GTKmenu . Then add things mentioned below to your sxhkdrc
  394.  
  395. There is desktop level menu, which is called by my panel with command
  396.  
  397.  
  398.  
  399. ```bash
  400. mygtkmenu ~/.config/GTKmenu/BspwmDesktopMenu
  401. ```
  402.  
  403.  
  404. There is window level menu, which is called sxhkd with alt + left click
  405.  
  406.  
  407.  
  408. ```bash
  409. mod1 + @button1
  410. mygtkmenu ~/.config/GTKmenu/BspwmWindowMenu
  411. ```
  412.  
  413. Finally, there is app menu that automatically tiles the next window where the menu was opened. This is the thing that requires menumaker-compiz to generate the menufile. I open the menu with alt_gr + left click. My sxhkd has
  414.  
  415.  
  416.  
  417. ```bash
  418. mod5 + @button1
  419. MouseLaunch
  420. ```
  421.  
  422.  
  423. I use termite as terminal, so you should either install that or edit update_menu.sh to have something else instead of termite. You should also probably add update_menu.sh to your autostart file.
  424.  
  425. ## **Useful scripts**
  426.  
  427. By default, you can't move or resize tiled, floating and pseudo-floating with same keybindings, because bspwm uses different commands for them. These scripts determine which type of window is in question, and apply the right command for it. I found one of these scripts from https://github.com/windelicato/dotfiles/blob/master/scripts/window_move.sh and edited it to have these two scripts:
  428.  
  429. bspwm_move.sh:
  430.  
  431.  
  432.  
  433. ```bash
  434. #!/bin/bash
  435.  
  436. # Sample sxhkd usage:
  437. #
  438. # alt + {a,f}
  439. # /home/sunn/scripts/bspwm_resize {-p,-n} -x -s 20
  440. #
  441. # alt + {s,d}
  442. # /home/sunn/scripts/bspwm_resize {-p,-n} -y -s 20
  443.  
  444. POSITIVE=false
  445. HORIZONTAL=false
  446. SIZE='20'
  447.  
  448. err() {
  449. echo "$1"
  450. exit 1
  451. }
  452.  
  453.  
  454. usage() {
  455. echo "usage: bspwm_resize [direction]"
  456. echo
  457. echo "Options:"
  458. echo " -p, --positive - resize in positively"
  459. echo " -n, --negative - resize in negatively"
  460. echo " -x, --xdir - resize in x direction"
  461. echo " -y, --ydir - resize in y dir"
  462. echo " -s, - number of pixels to resize or move"
  463. echo " -h, --help - display this"
  464. exit
  465. }
  466.  
  467. if [[ $# -eq 0 ]] ; then
  468. usage
  469. exit
  470. fi
  471.  
  472. for i in "$@"; do
  473. case $i in
  474. '-p'|'--positive')
  475. POSITIVE=true
  476. ;;
  477. '-n'|'--negative')
  478. POSITIVE=false
  479. ;;
  480. '-x'|'--xdir')
  481. HORIZONTAL=true
  482. ;;
  483. '-y'|'--ydir')
  484. HORIZONTAL=false
  485. ;;
  486. '-s')
  487. SIZE=$(echo $@ | sed 's/.*-s \([0-9]*\).*/\1/')
  488. [[ "$SIZE" == "$@" ]] && err "Must specify number of pixels"
  489. ;;
  490. ''|'-h'|'--help')
  491. usage
  492. exit
  493. ;;
  494. *)
  495. ;;
  496. esac
  497. done
  498.  
  499. # Find current window mode
  500. WINDOW_STATUS="$(bspc query -T -w | awk '/^.* [a-zA-Z\-]{8} \*$/{print $8}')"
  501. FLAGS="$(echo $WINDOW_STATUS | sed 's/-//g')";
  502.  
  503. # If the window is floating, move it
  504. if [[ "$FLAGS" =~ ^.*f.*$ ]]; then
  505. $HORIZONTAL && switch="-x" || switch="-y"
  506. $POSITIVE && sign="+" || sign="-"
  507. xdo move ${switch} ${sign}${SIZE}
  508.  
  509. # Otherwise, window is tiled change split ratio
  510. else
  511. $HORIZONTAL && switch=('left' 'right') || switch=('up' 'down')
  512. $POSITIVE && sign="+" || sign="-"
  513. bspc window -s ${switch[0]} || bspc window -s ${switch[1]}
  514. fi
  515. ```
  516.  
  517.  
  518.  
  519. bspwm_resize.sh:
  520.  
  521.  
  522.  
  523. ```bash
  524. #!/bin/bash
  525.  
  526. # Sample sxhkd usage:
  527. #
  528. # alt + {a,f}
  529. # /home/sunn/scripts/bspwm_resize {-p,-n} -x -s 20
  530. #
  531. # alt + {s,d}
  532. # /home/sunn/scripts/bspwm_resize {-p,-n} -y -s 20
  533.  
  534. POSITIVE=false
  535. HORIZONTAL=false
  536. SIZE='20'
  537.  
  538. err() {
  539. echo "$1"
  540. exit 1
  541. }
  542.  
  543.  
  544. usage() {
  545. echo "usage: bspwm_resize [direction]"
  546. echo
  547. echo "Options:"
  548. echo " -p, --positive - resize in positively"
  549. echo " -n, --negative - resize in negatively"
  550. echo " -x, --xdir - resize in x direction"
  551. echo " -y, --ydir - resize in y dir"
  552. echo " -s, - number of pixels to resize or move"
  553. echo " -h, --help - display this"
  554. exit
  555. }
  556.  
  557. if [[ $# -eq 0 ]] ; then
  558. usage
  559. exit
  560. fi
  561.  
  562. for i in "$@"; do
  563. case $i in
  564. '-p'|'--positive')
  565. POSITIVE=true
  566. ;;
  567. '-n'|'--negative')
  568. POSITIVE=false
  569. ;;
  570. '-x'|'--xdir')
  571. HORIZONTAL=true
  572. ;;
  573. '-y'|'--ydir')
  574. HORIZONTAL=false
  575. ;;
  576. '-s')
  577. SIZE=$(echo $@ | sed 's/.*-s \([0-9]*\).*/\1/')
  578. [[ "$SIZE" == "$@" ]] && err "Must specify number of pixels"
  579. ;;
  580. ''|'-h'|'--help')
  581. usage
  582. exit
  583. ;;
  584. *)
  585. ;;
  586. esac
  587. done
  588.  
  589. # Find current window mode
  590. WINDOW_STATUS="$(bspc query -T -w | awk '/^.* [a-zA-Z\-]{8} \*$/{print $8}')"
  591. FLAGS="$(echo $WINDOW_STATUS | sed 's/-//g')";
  592.  
  593. # If the window is floating, move it
  594. if [[ "$FLAGS" =~ ^.*f.*$ ]]; then
  595. $HORIZONTAL && switch="-w" || switch="-h"
  596. $POSITIVE && sign="+" || sign="-"
  597. xdo resize ${switch} ${sign}${SIZE}
  598. # If the window is pseudotiled, resize it
  599. elif [[ "$FLAGS" =~ ^.*d.*$ ]]; then
  600. $HORIZONTAL && switch="-w" || switch="-h"
  601. $POSITIVE && sign="+" || sign="-"
  602. xdo resize ${switch} ${sign}${SIZE}
  603. # Otherwise, window is tiled change split ratio
  604. else
  605. $HORIZONTAL && switch=('left' 'right') || switch=('down' 'up')
  606. $POSITIVE && sign="+" || sign="-"
  607. bspc window -e ${switch[0]} ${sign}${SIZE} || bspc window -e ${switch[1]} ${sign}${SIZE}
  608. fi
  609. ```
  610.  
  611.  
  612. Copy them to your scripts folder and mark them as executable with
  613.  
  614.  
  615.  
  616. ```bash
  617. chmod +x ~/scripts/bspwm_move.sh
  618. ```
  619.  
  620.  
  621. Then, put in your sxhkdrc
  622.  
  623.  
  624.  
  625. ```
  626. #move windows
  627. super + shift + {d,a}
  628. $HOME/scripts/bspwm_move.sh {-p,-n} -x -s 20
  629.  
  630. super + shift + {s,w}
  631. $HOME/scripts/bspwm_move.sh {-p,-n} -y -s 20
  632.  
  633. #multitool resize
  634. super + ctrl + {d,a}
  635. $HOME/scripts/bspwm_resize.sh {-p,-n} -x -s 20
  636.  
  637. super + ctrl + {s,w}
  638. $HOME/scripts/bspwm_resize.sh {-p,-n} -y -s 20
  639.  
  640. #multitool resize
  641. super + {Right,Left}
  642. $HOME/scripts/bspwm_resize.sh {-p,-n} -x -s 20
  643.  
  644. super + {Down,Up}
  645. $HOME/scripts/bspwm_resize.sh {-p,-n} -y -s 20
  646. ```
  647.  
  648.  
  649. You can now move and resize all types of windows with same keybindings.
  650.  
  651. ------
  652.  
  653.  
  654.  
  655. You probably want to have some sort of panel with bspwm. The following stuff just works:
  656. \- xfce4-panel
  657. \- bmpanel2
  658. \- tint2
  659. \- lxqt-panel
  660. You can add name of your panel to your bspwmrc with & in the end, and make a gap for the panel with
  661. bspc config top/bottom/left/right_padding x, where x is the soze of gap in pixels.
  662.  
  663. If you want more authentic and lightweight bswm experience, there is example bar script.
  664. If you wish to also use panel (that we actually already installed previously) with bspwm, you need to edit your ~/.profile or ~/.zprofile if you use zsh. Add in there
  665. export PANEL_FIFO="/tmp/panel-fifo"
  666. export PATH=$PATH:/path/to/panel/scripts
  667. PANEL_HEIGHT=24
  668. PANEL_FONT_FAMILY="-*-terminus-medium-r-normal-*-12-*-*-*-c-*-*-1"
  669. export PANEL_FIFO PANEL_HEIGHT PANEL_FONT_FAMILY
  670.  
  671. ( /path/to/panel/scripts is a folder where you can place scripts which are recognized as terminal commands because they are in your path. I recommend ~/.bin or ~/scripts , but it is really up to you)
  672.  
  673. Copy the example scripts (panel, panel_bar and panel_colors) from https://github.com/baskerville/bspwm/tree/master/examples/panel to your path folder and run chmod +x panel && chmod +x panel_bar. You can now put to the end of your bspwmrc
  674. panel &
  675. Panel should then appear when you launch bspwm.
  676.  
  677. ### **Clickable panel**
  678.  
  679. There are scripts with clickable workspaces and other functions available. For example this is the next panel script for manjaro bspwm respin. It also requires custom font benis-uushi and pipes conky to bar to display system information.
  680.  
  681. Panel:
  682.  
  683.  
  684.  
  685. ```bash
  686. #! /bin/sh
  687.  
  688. if [ $(pgrep -cx panel) -gt 1 ] ; then
  689. printf "%s\n" "The panel is already running." >&2
  690. exit 1
  691. fi
  692.  
  693. trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
  694.  
  695. flavor=${1:-bar}
  696.  
  697. [ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
  698. mkfifo "$PANEL_FIFO"
  699.  
  700. bspc config top_padding $PANEL_HEIGHT
  701.  
  702.  
  703. # Colorscheme for mocha
  704. #BLUE="%{F#FF8AB3B5}"
  705. #RED="%{F#FFCB6077}"
  706. #YELLOW="%{F#FFF4BC87}"
  707. #ORANGE="%{F#FFD28B71}"
  708. #MAGENTA="%{F#FFA89BB9}"
  709. #TEAL="%{F#FF7BBdA4}"
  710. #LIGHTGREY="%{F#FFb8AfAD}"
  711. #DARKGREY="%{F#FF7E705A}"
  712. #GREEN="%{F#FF90A950}"
  713. #PURPLE="%{F#FF9547C9}"
  714. #BG="%{F#FF3B3228}"
  715.  
  716. # Colorscheme for default-dark
  717. BLUE="%{F#FF6A9FB5}"
  718. RED="%{F#FFAC4142}"
  719. YELLOW="%{F#FFFF4BF75}"
  720. ORANGE="%{F#FFD28B71}"
  721. MAGENTA="%{F#FFAA759F}"
  722. TEAL="%{F#FF75B5AA}"
  723. LIGHTGREY="%{F#FFB0B0B0}"
  724. DARKGREY="%{F#FF505050}"
  725. GREEN="%{F#FF99CC99}"
  726. PURPLE="%{F#FF9547C9}"
  727. BG="%{F#FF151515}"
  728. INDIANRED="%{F#FFEE6363}"
  729.  
  730. bspc control --subscribe > "$PANEL_FIFO" &
  731. xtitle -sf 'T%s' > "$PANEL_FIFO" &
  732. conky -c ~/.config/bspwm/panel/conkyrc > "$PANEL_FIFO" &
  733.  
  734. panel_temperature()
  735. {
  736. temp=$((`sensors | grep "Physical id 0" | cut -d'+' -f2 | head -c2`))
  737. echo $GREEN " Temp" $temp°C;
  738. }
  739.  
  740. panel_memused()
  741. {
  742. read t f <<< `grep -E 'Mem(Total|Free)' /proc/meminfo |awk '{print $2}'`
  743. bc <<< "scale=2; 100 - $f / $t * 100" | cut -d. -f1
  744. }
  745.  
  746. panel_mem()
  747. {
  748. echo $GREEN " MEM:" $(panel_memused)%%
  749. }
  750. panel_cpuload()
  751. {
  752. LINE=`ps -eo pcpu |grep -vE '^\s*(0.0|%CPU)' |sed -n '1h;$!H;$g;s/\n/ +/gp'`
  753. bc <<< $LINE
  754. }
  755.  
  756. panel_cpu()
  757. {
  758. echo $GREEN " CPU:" $(panel_cpuload)%%
  759. }
  760. panel_volicon()
  761. {
  762. volStatus=$(pulseaudio-ctl | grep "muted" | less | cut -c 36-37)
  763. volLevel=$(pulseaudio-ctl | grep "Volume level" | less | cut -c 36-38)
  764.  
  765. if [ "$volStatus" == "no" ]
  766. then echo $GREEN " ⮞ ${volLevel}"
  767. elif [ "$volStatus" == "ye" ]
  768. then echo $RED " ⮝ ${volLevel}"
  769. else echo " ⮞"
  770. fi
  771. }
  772.  
  773.  
  774. panel_sigStrength()
  775. {
  776. signalStrength=$(cat /proc/net/wireless | awk 'NR==3 { print $3}' | sed 's/\.//')
  777.  
  778. if [ "$signalStrength" -gt 64 ]
  779. then
  780. echo ""$GREEN " ‗▬▪▮"
  781. elif [ "$signalStrength" -lt 65 ] && [ "$signalStrength" -gt 39 ]
  782. then
  783. echo ""$GREEN " ‗▬▪"$DARKGREY"▮"$ORANGE
  784. elif [ "$signalStrength" -lt 40 ]
  785. then
  786. echo ""$GREEN " ‗▬"$DARKGREY"▪▮"$ORANGE
  787. else
  788. echo ""$DARKGREY " ‗▬▪▮ Not connected"
  789. fi
  790. }
  791.  
  792. panel_essid()
  793. {
  794. echo $GREEN $(panel_sigStrength) $GREEN $(iwgetid -r)
  795. }
  796.  
  797. panel_battery()
  798. {
  799. batStats=$(cat /sys/class/power_supply/BAT0/status)
  800. if [ "$batStats" == "" ]
  801. then
  802. echo $LIGHTGREY " ⮎ AC"
  803. elif [ "$batStats" == "Charging" ]
  804. then
  805. echo $GREEN" ⮒" $(cat /sys/class/power_supply/BAT0/capacity)"+"
  806. elif [ "$batStats" == "Discharging" ]
  807. then
  808. echo $RED " ⮑" $(cat /sys/class/power_supply/BAT0/capacity)"-"
  809. elif [ "$batStats" == "Unknown" ]
  810. then
  811. echo $GREEN" ⮒" $(cat /sys/class/power_supply/BAT0/capacity)
  812. else echo $GREEN" ⮒" $(cat /sys/class/power_supply/BAT0/capacity)
  813. fi
  814. }
  815.  
  816. panel_clock()
  817. {
  818. echo $GREEN " ⭧ " $(clock -f '%a %d %I: %M')
  819. }
  820.  
  821. # Loop to check time, battery and volume statuses
  822. while true; do
  823. echo "S" $(panel_battery)%{A:nmcli_dmenu:}$(panel_essid)%{A} > "$PANEL_FIFO" &
  824. sleep 1s
  825. done &
  826.  
  827. . panel_colors
  828.  
  829. case "$flavor" in
  830. bar)
  831. FONT_FAMILY='-benis-uushi-medium-r-normal--11-90-75-75-p-58-iso10646-1'
  832. FONT_FAMILY2='-*-terminus-medium-r-normal-*-12-*-*-*-c-*-*-1'
  833. cat "$PANEL_FIFO" | panel_bar | bar -p -g x20 -f "$FONT_FAMILY2","$FONT_FAMILY" -u 2 -F "$BG" -B "$BG" | sh
  834. ;;
  835. dzen2)
  836. FONT_FAMILY='DejaVu Sans'
  837. FONT_SIZE=11
  838. cat "$PANEL_FIFO" | panel_dzen2 -f "$FONT_FAMILY" -s "$FONT_SIZE" | dzen2 -h $PANEL_HEIGHT -dock -ta l -title-name panel -fn "${FONT_FAMILY}:pixelsize=${FONT_SIZE}" -fg "$COLOR_FOREGROUND" -bg "$COLOR_BACKGROUND" &
  839. ;;
  840. esac
  841.  
  842. wait
  843. ```
  844.  
  845.  
  846. panel_bar
  847.  
  848.  
  849.  
  850. ```bash
  851. #! /bin/sh
  852.  
  853. CBR='%{B-}'
  854. CB1='%{B#FF99CC99}'
  855. CB2='%{B#FF4E4E4E}'
  856. CFR='%{F-}'
  857. CF1='%{F#FF000000}'
  858. CF2='%{F#FF99CC99}'
  859. CF3='%{F#FFD75F5F}'
  860. CF4='%{F#FF4E4E4E}'
  861. LA='%{l}'
  862. RA='%{r}'
  863. AC='%{A:'
  864. AB=':}'
  865. AE='%{A}'
  866. logo="${CB1}${CF1}${AC}dmenu_recent -l 10&disown${AB} $(hostname -s) %{B#FF000000}${CF2}${AE}"
  867. menu="${CF2}${AC}mygtkmenu ~/.config/GTKmenu/BspwmDesktopMenu${AB} menu ${AE}%{B#FF000000}${CF4}"
  868. while read -r line ; do
  869. case $line in
  870. S*)
  871. sys_infos="${RA}${line#?}"
  872. ;;
  873. C*)
  874. conky_infos="%{F#FF99CC99} ${line#?} "
  875. ;;
  876. T*)
  877. title="${CFR} ${AC}bspc desktop -l next${AB}${line#?}${AE} "
  878. ;;
  879. W*)
  880. wm_infos="%{B#FF000000}"
  881. IFS=':'
  882. set -- ${line#?}
  883. while [ $# -gt 0 ] ; do
  884. item=$1
  885. name=${item#?}
  886. case $item in
  887. [OFU]*)
  888. # active desktop
  889. wm_infos="${wm_infos}${CF2}${AC}bspc desktop -f ${name}${AB} • ${AE}${CFR}"
  890. ;;
  891. o*)
  892. # inactive but occupied desktop
  893. wm_infos="${wm_infos}${AC}bspc desktop -f ${name}${AB} • ${AE}"
  894. ;;
  895. f*)
  896. # inactive desktop
  897. wm_infos="${wm_infos}${AC}bspc desktop -f ${name}${AB} ○ ${AE}"
  898. ;;
  899. u*)
  900. # urgent desktop
  901. wm_infos="${wm_infos}${CF3}${AC}bspc desktop -f ${name}${AB} • ${AE}${CFR}"
  902. ;;
  903. L*)
  904. # layout
  905. case $name in
  906. t*)
  907. layout="T"
  908. ;;
  909. m*)
  910. layout="M"
  911. ;;
  912. esac
  913. wm_infos="${wm_infos} ${AC}bspc desktop -l next${AB}${layout}${AE} %{B#FF000000}${CF4}"
  914. ;;
  915. esac
  916. shift
  917. done
  918. ;;
  919. esac
  920. printf "%s\n" "$logo $wm_infos $menu %{c}$title $sys_infos ${conky_infos}"
  921. done
  922. ```
  923.  
  924.  
  925.  
  926. ~/.config/bspwm/panel/conkyrc:
  927.  
  928. ```bash
  929. background no
  930. out_to_console yes
  931. out_to_x no
  932. update_interval 5
  933. total_run_times 0
  934. short_units yes
  935. pad_percents 2
  936. override_utf8_locale yes
  937. times_in_seconds true
  938. #use_spacer left
  939. #~${fs_used /} \
  940. #s.${fs_used /data} \
  941. # ${mem} \
  942. #@ ${cpu}%
  943. #$if_mpd_playing ♪ ${if_match ${execi 5 expr length "`mpc --format %title% | head -n 1`"} >= 30}${scroll 30 3 ${mpd_title}}${else}${mpd_title}${endif} - ${if_match ${execi 5 expr length "`mpc --format %artist% | head -n 1`"} >= 30}${scroll 30 3 ${mpd_artist}}${else}${mpd_artist}${endif} |$endif \
  944. #Vol: ${exec amixer get Master | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p'| uniq}% | \
  945. #${battery_short BAT0} | \
  946. TEXT
  947. ${exec sleep 1}
  948. C RAM:${memperc}%% CPU:$cpu%% TEMP:$alignr${hwmon temp 1}°C | ⭧ ${time %H:%M}
  949. # ⮂ ⮀
  950. ```
  951.  
  952.  
  953.  
  954. #### For something more simple, you could try:
  955.  
  956. panel
  957.  
  958.  
  959.  
  960. ```bash
  961. #! /bin/sh
  962.  
  963. if [ $(pgrep -cx panel) -gt 1 ] ; then
  964. printf "%s\n" "The panel is already running." >&2
  965. exit 1
  966. fi
  967.  
  968. trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
  969.  
  970. [ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
  971. mkfifo "$PANEL_FIFO"
  972.  
  973. bspc config top_padding $PANEL_HEIGHT
  974. bspc control --subscribe > "$PANEL_FIFO" &
  975. xtitle -sf 'T%s' > "$PANEL_FIFO" &
  976. conky -c ~/.config/bspwm/panel/conkyrc > "$PANEL_FIFO" &
  977.  
  978. #panel_battery()
  979. #{
  980. # BATC=/sys/class/power_supply/BAT0/capacity
  981. # BATS=/sys/class/power_supply/BAT0/status
  982. #
  983. # test "`cat $BATS`" = "Charging" && echo -n '+' || echo -n '-'
  984. #
  985. # sed -n p $BATC
  986. #}
  987. #panel_temperature()
  988. #{
  989. # temp=$((`sensors | grep "Physical id 0" | cut -d'+' -f2 | head -c2`))
  990. # echo $temp°C;
  991. #}
  992. #
  993. #panel_cpuload()
  994. #{
  995. # LINE=`ps -eo pcpu |grep -vE '^\s*(0.0|%CPU)' |sed -n '1h;$!H;$g;s/\n/ +/gp'`
  996. # bc <<< $LINE
  997. #}
  998. #
  999. #panel_memused()
  1000. #{
  1001. # read t f <<< `grep -E 'Mem(Total|Free)' /proc/meminfo |awk '{print $2}'`
  1002. # bc <<< "scale=2; 100 - $f / $t * 100" | cut -d. -f1
  1003. #}
  1004. #panel_clock()
  1005. #{
  1006. # echo $(clock -f '%a %H:%M')
  1007. #}
  1008. #
  1009. # Loop to check time, battery and stuff
  1010. #while true; do
  1011. # echo "S" "TEMP:" $(panel_temperature) "BAT":$(panel_battery) "CPU:" $(panel_cpuload) "MEM:"$(panel_memused) $(panel_clock)%{A} > "$PANEL_FIFO" &
  1012. # sleep 1s
  1013. #done &
  1014.  
  1015.  
  1016. . panel_colors
  1017.  
  1018. cat "$PANEL_FIFO" | panel_barc | bar -g x$PANEL_HEIGHT -f "$PANEL_FONT_FAMILY" -F "$COLOR_FOREGROUND" -B "$COLOR_BACKGROUND" | sh &
  1019.  
  1020.  
  1021. wait
  1022. ```
  1023.  
  1024. panel_bar
  1025.  
  1026.  
  1027.  
  1028. ```bash
  1029. #! /bin/sh
  1030. #
  1031. # Example panel for LemonBoy's bar
  1032.  
  1033. . panel_colors
  1034.  
  1035. num_mon=$(bspc query -M | wc -l)
  1036.  
  1037. while read -r line ; do
  1038. case $line in
  1039. C*)
  1040. conky_infos="${line#?} %{B-}%{F-}"
  1041. ;;
  1042. T*)
  1043. # xtitle output
  1044. title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}"
  1045. ;;
  1046. W*)
  1047. # bspwm internal state
  1048. wm_infos=""
  1049. IFS=':'
  1050. set -- ${line#?}
  1051. while [ $# -gt 0 ] ; do
  1052. item=$1
  1053. name=${item#?}
  1054. case $item in
  1055. M*)
  1056. # active monitor
  1057. if [ $num_mon -gt 1 ] ; then
  1058. wm_infos="$wm_infos %{F$COLOR_ACTIVE_MONITOR_FG}%{B$COLOR_ACTIVE_MONITOR_BG}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-} "
  1059. fi
  1060. ;;
  1061. m*)
  1062. # inactive monitor
  1063. if [ $num_mon -gt 1 ] ; then
  1064. wm_infos="$wm_infos %{F$COLOR_INACTIVE_MONITOR_FG}%{B$COLOR_INACTIVE_MONITOR_BG}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-} "
  1065. fi
  1066. ;;
  1067. O*)
  1068. # focused occupied desktop
  1069. wm_infos="${wm_infos}%{F$COLOR_FOCUSED_OCCUPIED_FG}%{B$COLOR_FOCUSED_OCCUPIED_BG}%{U$COLOR_FOREGROUND}%{+u}%{A:bspc desktop -f ${name}:} ${name} %{A}%{-u}%{B-}%{F-}"
  1070. ;;
  1071. F*)
  1072. # focused free desktop
  1073. wm_infos="${wm_infos}%{F$COLOR_FOCUSED_FREE_FG}%{B$COLOR_FOCUSED_FREE_BG}%{U$COLOR_FOREGROUND}%{+u}%{A:bspc desktop -f ${name}:} ${name} %{A}%{-u}%{B-}%{F-}"
  1074. ;;
  1075. U*)
  1076. # focused urgent desktop
  1077. wm_infos="${wm_infos}%{F$COLOR_FOCUSED_URGENT_FG}%{B$COLOR_FOCUSED_URGENT_BG}%{U$COLOR_FOREGROUND}%{+u}%{A:bspc desktop -f ${name}:} ${name} %{A}%{-u}%{B-}%{F-}"
  1078. ;;
  1079. o*)
  1080. # occupied desktop
  1081. wm_infos="${wm_infos}%{F$COLOR_OCCUPIED_FG}%{B$COLOR_OCCUPIED_BG}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}"
  1082. ;;
  1083. f*)
  1084. # free desktop
  1085. wm_infos="${wm_infos}%{F$COLOR_FREE_FG}%{B$COLOR_FREE_BG}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}"
  1086. ;;
  1087. u*)
  1088. # urgent desktop
  1089. wm_infos="${wm_infos}%{F$COLOR_URGENT_FG}%{B$COLOR_URGENT_BG}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}"
  1090. ;;
  1091. L*)
  1092. # layout
  1093. wm_infos="$wm_infos %{F$COLOR_LAYOUT_FG}%{B$COLOR_LAYOUT_BG}%{A:bspc desktop -l next ${name}:} ${name} %{A}%{B-}%{F-}"
  1094. ;;
  1095. esac
  1096. shift
  1097. done
  1098. ;;
  1099. esac
  1100. printf "%s\n" "%{l}${wm_infos}%{c}${title}%{r}${conky_infos}%"
  1101. done
  1102. ```
  1103.  
  1104.  
  1105. This is basically the same as default panel, with clickable conky and clickable workspaces.
Add Comment
Please, Sign In to add comment