How to use the command bspc (with examples)
- Linux
- December 25, 2023
The bspc
command is a tool used to control bspwm
, a tiling window manager for X11. It provides various functionalities to manage virtual desktops, windows, and monitors. This article will illustrate each of the following use cases of the bspc
command.
Use case 1: Define two virtual desktops
Code:
bspc monitor --reset-desktops 1 2
Motivation:
You may want to define and assign virtual desktops to individual monitors. This use case enables you to create two virtual desktops and assign them to the specified monitor.
Explanation:
bspc
is the command-line tool used to controlbspwm
.monitor
is the command to manipulate monitors.--reset-desktops
is an option used to remove all existing desktops on the specified monitor and create new ones.1 2
are the arguments that represent the names or numbers of the virtual desktops to be created.
Example output:
Virtual desktops 1 and 2 created on the specified monitor.
Use case 2: Focus the given desktop
Code:
bspc desktop --focus number
Motivation:
When working with multiple virtual desktops, it is helpful to be able to switch focus between them easily. This use case allows you to focus on the specified desktop, making it the active one.
Explanation:
bspc
is the command-line tool used to controlbspwm
.desktop
is the command to manipulate virtual desktops.--focus
is an option used to set the focus to a particular desktop.number
is the argument that represents the name or number of the desktop to be focused.
Example output:
The specified desktop is now focused and active.
Use case 3: Close the windows rooted at the selected node
Code:
bspc node --close
Motivation:
There may be situations where you want to close all windows within a particular node. This use case enables you to close all windows rooted at the selected node.
Explanation:
bspc
is the command-line tool used to controlbspwm
.node
is the command to manipulate the nodes (windows).--close
is an option used to close the windows rooted at the selected node.
Example output:
All windows rooted at the selected node have been closed.
Use case 4: Send the selected node to the given desktop
Code:
bspc node --to-desktop number
Motivation:
Being able to move windows between virtual desktops can help you better organize your workspace. This use case allows you to send the selected node (window) to the specified virtual desktop.
Explanation:
bspc
is the command-line tool used to controlbspwm
.node
is the command to manipulate the nodes (windows).--to-desktop
is an option used to send the selected node to a particular virtual desktop.number
is the argument that represents the name or number of the desktop to which the node should be sent.
Example output:
The selected node has been moved to the specified virtual desktop.
Use case 5: Toggle full screen mode for the selected node
Code:
bspc node --state ~fullscreen
Motivation:
Switching windows to full screen mode can provide a distraction-free working environment. This use case allows you to toggle the full screen mode for the selected node.
Explanation:
bspc
is the command-line tool used to controlbspwm
.node
is the command to manipulate the nodes (windows).--state
is an option used to modify the state of a node.~fullscreen
is the argument that represents the desired state of the node. Using a tilde (~) before the state means to toggle it.
Example output:
The selected node is now in full screen mode.
Conclusion:
The bspc
command provides a range of functionalities to control bspwm
and manage virtual desktops and windows. By using the various options and arguments, you can customize your workspace and improve your productivity.