高级配置
熟悉了配置基础后,这些模式可以帮助您进一步优化 Tsumiki。
兼容 Waybar 的自定义组件,可运行外部 shell 命令,支持可配置的输出解析和点击处理。
[[widgets.custom_widget]]id = "volume"exec = "pamixer --get-volume"format = " {}%"interval = 1on_scroll_up = "pamixer -i 5"on_scroll_down = "pamixer -d 5"exec_on_event = true
[layout]left_section = ["@custom_widget:volume", "workspaces"]完整配置选项:
| 键 | 类型 | 默认值 | 描述 |
|---|---|---|---|
id |
string | — | 在布局中引用的唯一标识符 (@custom_widget:my-id) |
exec |
string | 必需 | 要执行的 shell 命令 |
interval |
int | 0 |
刷新间隔(秒),0 = 仅执行一次 |
return_type |
string | "plain" |
输出格式:"plain" 或 "json" |
label_format |
string | "{}" |
格式字符串,{} 将被输出替换 |
exec_on_event |
bool | false |
点击/滚动后重新执行命令 |
max_length |
int | 0 |
最大文本长度(0 = 无限制) |
min_length |
int | 0 |
最小文本长度(用空格填充) |
rotate |
int | 0 |
文本旋转角度(度) |
tooltip |
bool | true |
显示带输出的工具提示 |
tooltip_format |
string | — | 工具提示格式字符串 |
on_click |
string | — | 左键单击命令 |
on_click_right |
string | — | 右键单击命令 |
on_click_middle |
string | — | 中键单击命令 |
on_scroll_up |
string | — | 向上滚动命令 |
on_scroll_down |
string | — | 向下滚动命令 |
signal |
int | — | sig* 事件触发器的信号编号 |
restart_interval |
int | — | 持久脚本的重启间隔 |
将具有共享间距和样式的组件分组:
在布局中使用 @group:N(从零开始的索引)或 @group:id(文本 ID)引用组:
[[widget_groups]]id = "sys-group"widgets = ["updates", "battery"]spacing = 4style_classes = ["bordered"]在布局中使用 @group:sys-group 引用。
[layout]right_section = ["@group:sys-group", "system_tray"]将较少使用的组件隐藏在切换按钮后面:
[[collapsible_groups]]id = "utility-tools"widgets = ["ocr", "screenshot", "recorder"]spacing = 4icon = ""tooltip = "工具"style_classes = ["utility-tools"]在布局中使用 @collapsible:utility-tools 引用。
right_section = ["@collapsible:utility-tools", "system_tray"]点击时执行 shell 命令的独立自定义按钮。在布局部分直接使用其名称引用。
[widgets.custom_button]command = "firefox"icon = ""label_text = "Firefox"tooltip_text = "打开 Firefox 浏览器"show_icon = truelabel = falsetooltip = true像任何普通组件一样将其放置在布局中:
[layout]left_section = ["custom_button", "workspaces"]自定义按钮组
Section titled “自定义按钮组”一组自定义命令按钮。组中的每个按钮可以通过 @custom_button:N 或 @custom_button:id 引用:
[widgets.custom_button_group]spacing = 4
[[widgets.custom_button_group.buttons]]id = "firefox"command = "firefox"icon = ""label_text = "Firefox"tooltip_text = "打开 Firefox 浏览器"show_icon = truelabel = falsetooltip = true
[layout]left_section = ["@custom_button:firefox"]