Module i3status_rs::blocks::toggle

source ·
Expand description

A Toggle block

You can add commands to be executed to disable the toggle (command_off), and to enable it (command_on). If these command exit with a non-zero status, the block will not be toggled and the block state will be changed to critical to give a visual warning of the failure. You also need to specify a command to determine the state of the toggle (command_state). When the command outputs nothing, the toggle is disabled, otherwise enabled. By specifying the interval property you can let the command_state be executed continuously.

To run those commands, the shell form $SHELL environment variable is used. If such variable is not presented, sh is used.

§Configuration

KeyValuesDefault
formatA string to customise the output of this block. See below for available placeholders" $icon "
command_onShell command to enable the toggleRequired
command_offShell command to disable the toggleRequired
command_stateShell command to determine the state. Empty output => No, otherwise => Yes.Required
icon_onIcon override for the toggle button while on"toggle_on"
icon_offIcon override for the toggle button while off"toggle_off"
intervalUpdate interval in seconds. If not set, command_state will run only on click.None
state_onState (color) of this block while onidle
state_offState (color) of this block while offidle
PlaceholderValueTypeUnit
iconIcon based on toggle’s stateIcon-
ActionDefault button
toggleLeft

§Examples

This is what can be used to toggle an external monitor configuration:

[[block]]
block = "toggle"
format = " $icon 4k "
command_state = "xrandr | grep 'DP1 connected 38' | grep -v eDP1"
command_on = "~/.screenlayout/4kmon_default.sh"
command_off = "~/.screenlayout/builtin.sh"
interval = 5
state_on = "good"
state_off = "warning"

§Icons Used

  • toggle_off
  • toggle_on

Structs§

Functions§