Home Packages Forums Wiki GitLab Security AUR Download
waybar-custom(5) File Formats Manual waybar-custom(5)
NAME
waybar - custom module
DESCRIPTION
The custom module displays either the output of a script or static text. To display static text, specify only the format field.
CONFIGURATION
Addressed by custom/
exec:
typeof: string The path to the script, which should be executed.
exec-if:
typeof: string
The path to a script, which determines if the script in exec should be executed.
exec will be executed if the exit code of exec-if equals 0.
hide-empty-text:
typeof: bool Disables the module when output is empty, but format might contain additional static content.
exec-on-event:
typeof: bool
default: true
If an event command is set (e.g. on-click or on-scroll-up) then re-execute the script after executing the event command.
return-type:
typeof: string
See return-type
interval:
typeof: integer
The interval (in seconds) in which the information gets polled.
Use once if you want to execute the module only on startup.
You can update it manually with a signal. If no interval or signal is defined, it is assumed that the out script loops itself.
If a signal is defined then the script will run once on startup and will only update with a signal.
restart-interval:
typeof: integer
The restart interval (in seconds).
Can't be used with the interval option, so only with continuous scripts.
Once the script exits, it'll be re-executed after the restart-interval.
signal:
typeof: integer
The signal number used to update the module.
The number is valid between 1 and N, where SIGRTMIN+N = SIGRTMAX. If no interval is defined then a signal will be the only way to update the module.
format:
typeof: string
default: {text} The format, how information should be displayed. On {text} data gets inserted.
format-icons:
typeof: array
Based on the set percentage, the corresponding icon gets selected. The order is low to high.
rotate:
typeof: integer Positive value to rotate the text label (in 90 degree increments).
max-length:
typeof: integer The maximum length in character the module should display.
min-length:
typeof: integer The minimum length in characters the module should accept.
align:
typeof: float The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
justify:
typeof: string The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
on-click:
typeof: string Command to execute when clicked on the module.
on-click-middle:
typeof: string Command to execute when middle-clicked on the module using mousewheel.
on-click-right:
typeof: string Command to execute when you right-click on the module.
on-update:
typeof: string Command to execute when the module is updated.
on-scroll-up:
typeof: string Command to execute when scrolling up on the module.
on-scroll-down:
typeof: string Command to execute when scrolling down on the module.
smooth-scrolling-threshold:
typeof: double Threshold to be used when scrolling.
tooltip:
typeof: bool
default: true Option to disable tooltip on hover.
tooltip-format:
typeof: string
The tooltip format. If specified, overrides any tooltip output from the script in exec.
Uses the same format replacements as format.
escape:
typeof: bool
default: false Option to enable escaping of script output.
menu:
typeof: string Action that popups the menu.
menu-file:
typeof: string Location of the menu descriptor file. There need to be an element of type
GtkMenu with id menu
menu-actions:
typeof: array The actions corresponding to the buttons of the menu.
expand:
typeof: bool
default: false Enables this module to consume all left over space dynamically.
RETURN-TYPE
When return-type is set to json, Waybar expects the exec-script to output its data in JSON format. This should look like this:
Powered by archmanweb, using mandoc for the conversion of manual pages.
The website is available under the terms of the GPL-3.0 license, except for the contents of the manual pages, which have their own license specified in the corresponding Arch Linux package.
Write simple module to show contents of file /tmp/capslock-status every 1 second
Assistant
You can create a simple Waybar custom module to display the contents of /tmp/capslock-status using the custom module. Since you want it updated every 1 second, use the interval option.
Here is a minimal example configuration snippet for your Waybar config (usually in ~/.config/waybar/config):
Add this to your Waybar config inside the custom modules section, restart Waybar, and it will show the contents of the file live.
User
[2025-07-09 15:57:12.395] [error] custom/capslock: argument not found
it appears when /tmp/capslock-status not empty
Assistant
The error [error] custom/capslock: argument not found usually indicates Waybar tried to run the exec command but encountered issues, possibly because the output contains special characters or format placeholders that Waybar tries to interpret.
If your /tmp/capslock-status contains any braces {}, percent signs %, or other characters that Waybar interprets as format placeholders, you need to escape the output properly or adjust the format.
Possible causes and solutions
Output containing curly braces {} or percent signs %
Waybar treats {text} as a placeholder. If your text contains {} or %, it might confuse Waybar.
Solution: Enable "escape": true in your config, so Waybar escapes special characters.
Empty or unexpected output
If the file is empty or contains unexpected characters, Waybar might error.
You can add "hide-empty-text": true to hide the module when output is empty.
Use a wrapper script
If you want to be strict, create a small wrapper script that reads the file and guarantees valid output.
Example script ~/scripts/capslock.sh:
bash
#!/bin/bash
if [ -s /tmp/capslock-status ]; then
cat /tmp/capslock-status | sed 's/{/\\{/g; s/}/\\}/g; s/%/%%/g'
else
echo ""
fi
Then restart Waybar and see if the error goes away.
If the problem persists, please share the exact content of /tmp/capslock-status or if it contains special characters.
User
what mean [ -f /tmp/capslock-status ] ?
Assistant
The expression [ -f /tmp/capslock-status ] is a test condition used in shell scripting to check if a file exists and is a regular file.
Breakdown:
[ and ] are shorthand for the test command in most shells.
-f is a test operator that returns true if the given file exists and is a regular file (not a directory or special file).
/tmp/capslock-status is the path to the file being checked.
What it does:
If the file /tmp/capslock-statusexists and is a regular file, the test returns true (exit status 0).
Otherwise, it returns false (non-zero exit status).
Usage in Waybar:
In the exec-if option:
json
"exec-if": "[ -f /tmp/capslock-status ]"
This means only run the exec script if the file /tmp/capslock-status exists.
If the file does not exist, Waybar will not execute the exec command, thus avoiding errors when the file is missing.
Summary
[ -f /tmp/capslock-status ] checks for the presence of the file /tmp/capslock-status.
It helps conditionally run a script or command only when the file exists.
User
what purpose of escape: true?
Assistant
The option "escape": true in Waybar’s custom module configuration tells Waybar to escape special characters in the script’s output before displaying it.
Why is this necessary?
Waybar’s output format supports markup (like Pango markup) to style the text (colors, font weight, etc). It also uses curly braces {} for placeholders, so if your script outputs characters like:
<, >, & (used in markup)
{, }, % (used in format placeholders)
other special characters
Waybar might misinterpret them as markup or formatting instructions, causing display issues or errors, like the one you saw:
code
custom/capslock: argument not found
What does "escape": true do?
It escapes these characters in your script’s output by converting them to safe strings that show up literally, for example:
< becomes <
> becomes >
& becomes &
{ and } are escaped so they are treated as normal characters, not format placeholders.
This ensures Waybar displays exactly what your script outputs, without trying to parse markup or placeholders inside it.
When to use "escape": true?
When your script outputs text containing special characters or markup-like symbols.
When you want to safely display arbitrary file contents or text without worrying about format conflicts.
When not to use it?
If your script deliberately outputs valid Pango markup, and you want Waybar to interpret that markup for styling.
If you only output simple plain text without any special characters.
Example
If /tmp/capslock-status contains:
code
Caps Lock: ON {enabled}
Without "escape": true, Waybar might try to treat {enabled} as a format placeholder.
With "escape": true, the curly braces are escaped, so Waybar just shows:
code
Caps Lock: ON {enabled}
Summary
escape: true protects your displayed text from being misinterpreted by Waybar by escaping special characters and markup. It helps avoid display issues and errors when your output contains characters Waybar treats specially.
User
how to get current keyboard layout on wayland ?
Assistant
To get the current keyboard layout on Wayland, you typically can't rely on setxkbmap or xkb-switch (X11-specific tools) because Wayland does not use X11 input methods.
Here are some ways to get the current keyboard layout under Wayland:
1. Using swaymsg (if using Sway wm or wlroots-based compositor)
If you are using Sway or a compositor compatible with wlroots, you can query the current keyboard layout via IPC:
bash
swaymsg -t get_inputs
This outputs JSON describing input devices; you can filter to find the keyboard device and check its layout.