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
Key | Values | Default |
---|---|---|
format | A string to customise the output of this block. See below for available placeholders | " $icon " |
command_on | Shell command to enable the toggle | Required |
command_off | Shell command to disable the toggle | Required |
command_state | Shell command to determine the state. Empty output => No, otherwise => Yes. | Required |
icon_on | Icon override for the toggle button while on | "toggle_on" |
icon_off | Icon override for the toggle button while off | "toggle_off" |
interval | Update interval in seconds. If not set, command_state will run only on click. | None |
state_on | State (color) of this block while on | idle |
state_off | State (color) of this block while off | idle |
Placeholder | Value | Type | Unit |
---|---|---|---|
icon | Icon based on toggle’s state | Icon | - |
Action | Default button |
---|---|
toggle | Left |
§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