Difference between revisions of "Bspwm"

From ArchWiki
Jump to: navigation, search
(Panels)
(reinstated internal rules)
Line 27: Line 27:
 
=== Rules ===
 
=== Rules ===
  
As of {{ic|948b804}} window-specific rules were externalized.
+
As of [https://github.com/baskerville/bspwm/commit/cd97a3290aa8d36346deb706fa307f5f8faa2f34 9a23707 ] there are two ways to set window rules.
Rules can be created in a few different ways. Two such methods are below:
 
  
# Using the example scripts provide in [https://github.com/baskerville/bspwm/blob/master/contrib/rules rules], place {{ic | rulc}} and {{ic | ruld}} in a folder that is in your $PATH and make them executable. Start {{ ic | ruld }} on login with something like {{ ic | rulc -l > /dev/null <nowiki>||</nowiki> ruld &}}. You can then use the rules in the example {{ic | bspwmrc }} These scripts require both [https://www.archlinux.org/packages/?sort=&q=lua-posix&maintainer=&flagged= lua-posix] and [https://www.archlinux.org/packages/?sort=&repo=Extra&q=lua&maintainer=&flagged= lua]
+
The first is by using the built in rule command, as shown in the example bspwmrc:
# Alternatively, create a script that is called in your bspwmrc file that forms the rules. See [https://bbs.archlinux.org/viewtopic.php?pid=1346272#p1346272 Stebalien's post] or [https://gist.github.com/windelicato/7348087 earsplit's config] for examples of how to accomplish this.
+
{{bc|<nowiki>
 +
bspc rule -a Gimp desktop=^8 follow=on floating=on
 +
bspc rule -a Chromium desktop=^2
 +
bspc rule -a mplayer2 floating=on
 +
bspc rule -a Kupfer.py focus=on
 +
bspc rule -a Screenkey manage=off
 +
</nowiki>}}
  
Both of these methods require installing '''xwinfo''' from the [https://aur.archlinux.org/packages/xwinfo-git AUR] or from [https://github.com/baskerville/xwinfo github]
+
The second option is to use an external rule command. This is more complex, but can allow you to craft more complex window rules.  See [https://github.com/baskerville/bspwm/tree/master/examples/external_rules these examples] for a sample rule command. These scripts require [https://www.archlinux.org/packages/?sort=&q=lua-posix&maintainer=&flagged= lua-posix], [https://www.archlinux.org/packages/?sort=&repo=Extra&q=lua&maintainer=&flagged= lua] and [https://aur.archlinux.org/packages/xwinfo-git xwinfo].
  
 
If a particular window does not seem to be behaving according to your rules, check the class name of the program. This can be accomplished by running {{ ic | xprop <nowiki>|</nowiki> grep WM_CLASS}} to make sure you're using the proper string.
 
If a particular window does not seem to be behaving according to your rules, check the class name of the program. This can be accomplished by running {{ ic | xprop <nowiki>|</nowiki> grep WM_CLASS}} to make sure you're using the proper string.
Line 68: Line 73:
 
== Example how to configure after install ==
 
== Example how to configure after install ==
 
{{warning | This not yet a finished guide}}
 
{{warning | This not yet a finished guide}}
{{warning | Please note that bspwm are under heavy development and can change a lot. This is how I did last time. If something is wrong please correct the faults of it.}}
+
{{warning | The rule command were made optional. This guide has not been updated to reflect this.}}
  
  
Line 91: Line 96:
 
  exec wm  
 
  exec wm  
  
:4. Add this line to {{ic|$XDG_CONFIG_HOME/bspwm/bspwmrc}}.
+
:4. Configure window rules. If you wish to use the rules scripts, add this line to {{ic|$XDG_CONFIG_HOME/bspwm/bspwmrc}}.
 
  {{ic|bspc config rule_command "$(command -v rule_command)"}}
 
  {{ic|bspc config rule_command "$(command -v rule_command)"}}
  

Revision as of 16:56, 12 December 2013

bspwm is a tiling window manager that represents windows as the leaves of a full binary tree. It has support for EWMH and multiple monitors, and is configured and controlled through messages.

Installation

Install bspwmAUR or bspwm-gitAUR from the AUR. You will also want to install sxhkdAUR or sxhkd-gitAUR, a simple X hotkey daemon used to communicate with bspwm through bspc as well as launch your applications of choice. With commit 948b804, xwinfo-gitAUR is also required by the example configuration files.

To start bspwm on login, add the following to your .xinitrc:

sxhkd &
exec bspwm

Configuration

Example configuration is found on GitHub.

Copy bspwmrc to ~/.config/bspwm/bspwmrc, sxhkdrc to ~/.config/sxhkd/sxhkdrc and make bspwmrc executable with chmod +x ~/.config/bspwm/bspwmrc.

Documentation for bspwm is found by running man bspwm.

There is also documentation for sxhkd found by running man sxhkd.

These two files are where you will be setting wm settings and keybindings, respectively.

Rules

As of 9a23707 there are two ways to set window rules.

The first is by using the built in rule command, as shown in the example bspwmrc:

bspc rule -a Gimp desktop=^8 follow=on floating=on
bspc rule -a Chromium desktop=^2
bspc rule -a mplayer2 floating=on
bspc rule -a Kupfer.py focus=on
bspc rule -a Screenkey manage=off

The second option is to use an external rule command. This is more complex, but can allow you to craft more complex window rules. See these examples for a sample rule command. These scripts require lua-posix, lua and xwinfo.

If a particular window does not seem to be behaving according to your rules, check the class name of the program. This can be accomplished by running xprop | grep WM_CLASS to make sure you're using the proper string.

Panels

Currently, bar and dzen2 are supported with bspwm. Check the examples folder on the GitHub page for ideas or the Bar wiki page. The panel will be executed by placing panel & for bar or panel dzen2 & for dzen2 in your bspwmrc. Check the opt-depends in the bspwm package for dependencies that may be required in either case.

To display system information on your status bar you can use various system calls. This example will show you how to edit your panel to get the volume status on your BAR:

panel_volume()
{
        volStatus=$(amixer get Master | tail -n 1 | cut -d '[' -f 4 | sed 's/].*//g')
        volLevel=$(amixer get Master | tail -n 1 | cut -d '[' -f 2 | sed 's/%.*//g')
        # is alsa muted or not muted?
        if [ "$volStatus" == "on" ]
        then
                echo "\f6"$volLevel
        else
                # If it is muted, make the font red
                echo "\f1"$volLevel
        fi
}

Next, we will have to make sure it is called and piped to $PANEL_FIFO:

while true; do
echo "S" "$(panel_volume) $(panel_clock) > "$PANEL_FIFO"
        sleep 1s
done &

Example how to configure after install

Warning: This not yet a finished guide
Warning: The rule command were made optional. This guide has not been updated to reflect this.


1. Copy the supplied bspwm_rules, rule_command, ruld and rulc scripts from Examples to $XDG_CONFIG_HOME/bspwm/ and ensure they are executable.
2. Edit $HOME/.profile to something similar to this:
PATH="/usr/games:$HOME/.config/bspwm:$PATH"

export XDG_CONFIG_HOME="/home/$USER/.config"

## Bspwm
export BSPWM_SOCKET="/tmp/bspwm-socket"
export BSPWM_TREE=/tmp/bspwm.tree
export BSPWM_HISTORY=/tmp/bspwm.history
export BSPWM_STACK=/tmp/bspwm.stack
export PANEL_FIFO=/tmp/panel-fifo
export PANEL_HEIGHT=14
3. Edit $HOME/.xinitrc and add.
source $HOME/.profile &
sxhkd -c $XDG_CONFIG_HOME/bspwm/sxhkdrc &
exec wm 
4. Configure window rules. If you wish to use the rules scripts, add this line to $XDG_CONFIG_HOME/bspwm/bspwmrc.
bspc config rule_command "$(command -v rule_command)"
5. Install xwinfo from AUR and lua-posix. Change the rules of $XDG_CONFIG_HOME/bspwm/bspwm_rules to your likening.
$ man bspc
...
rule_command
External command used to retrieve rule consequences. The command will receive the the ID of the
window being processed as its first argument. The output of that command must have the following
format: key1=value1 key2=value2 ..., where keyN is one of floating, fullscreen, locked, sticky,
private, frame, center, lower, follow, manage, focus, desktop or monitor.
...
To find out the window names you can use xorg-xprop. The lower-case 'vlc' is the instance and the upper-case 'Vlc' is the class.
$ xprop | grep WM_CLASS
WM_CLASS(STRING) = "vlc", "Vlc"
6. Restart bspwm and check so the rules have been applied.
$ rulc -l
class == "Gimp" =>floating=on
class == "Firefox" => desktop=^2
class == "Vlc" => desktop=^3
instance == "rtorrent" => desktop=^3
instance == "URthree" => desktop=^3

Troubleshooting

The following environmental variables may need to be defined:

echo $BSPWM_SOCKET
echo $XDG_CONFIG_HOME

If either of these do not respond with a value, then go to your ~/.profile and add the following lines:

export XDG_CONFIG_HOME="$HOME/.config"
export BSPWM_SOCKET="/tmp/bspwm-socket"
Note: You may put these anywhere that is sourced for your user. Another sane place to put these would be as part of your user's ~/.xinitrc, or zsh users might choose ~/.zshenv. User your best discretion.

See also