2个不稳定版本
0.2.0-alpha.1 | 2024年5月12日 |
---|---|
0.1.0 | 2023年7月16日 |
#83 in 命令行工具
每月 22 次下载
17KB
102 行
假设您已安装 Rust,运行
$ cargo install yambar-hyprland-wses
然后使用README中更下面的Yambar配置。您需要调整 脚本
路径。
为什么?
Yambar 目前没有 显示Hyprland工作空间的机制。至少有一个 轮询脚本 可以做到这一点,但由于它是轮询的,所以感觉比较慢,效率也不够高。
此工具通过 Hyprland IPC接口 和 hyprland crate 查询并显示工作空间列表,并在发生变化时进行 监听。它以与 Yambar脚本模块 兼容的方式执行,以便Yambar配置可以可视化始终更新的Hyprland工作空间列表。
输出
脚本运行时,以以下格式输出(使用Yambar脚本模块输出格式)
workspace_N|string|The Hyprland name of the workspace
workspace_N_windows|int|The number of windows on the workspace
workspace_N_index_on_monitor|int|The index of the workspace on its monitor
workspace_N_monitor|string|The name of the monitor the workspace is on
workspace_N_active|bool|Whether the workspace is active on _a_ monitor
workspace_N_focused|bool|Whether the workspace is active _and_ its monitor has focus
workspace_count|int|The total number of workspaces
注意事项
在Hyprland中,空工作空间 不存在,因此您只会看到上面有内容的那些工作空间出现在您的栏中。为了使这种情况不那么突兀,此工具还会将空工作空间填充到最后一个已填充的工作空间。如果您希望所有工作空间都始终列出,则需要稍微调整建议的Yambar配置(请参阅以下注释)。
由于Yambar对插件的支持非常简单,并且其 "粒子" 相对有限,因此Yambar配置非常冗长且重复(见下文)。由于某种原因,它似乎还会在脚本模块发出第一个标签之前渲染粒子,因此启动yambar时最初会收到一些警告,然后消失。
我目前没有多显示器设置,所以没有测试过它在那里是否工作得很好。可能已经损坏了。这个工具尝试根据工作空间所在的显示器从左到右列出工作空间,并且尝试突出显示在非焦点显示器上处于活动状态的工作空间,但我不确定这些功能是否目前都工作正常。请告诉我!
我还没有为以下配置设置on-click
处理器。请随意这样做。你可能想调用
hyprctl dispatch workspace N
在多显示器设置中进行一些特殊处理?如果你做出了好东西,请告诉我!
Yambar配置文件
- script:
path: /home/yourusernamehere/.cargo/bin/yambar-hyprland-wses
anchors:
ws_focused: &ws_focused fba922ff
ws_active: &ws_active ffaa00ff
ws_empty: &ws_empty 555555ff
ws_other: &ws_other bbbbbbff
# you can use `{workspace_N}` here to use the workspace name
# assigned by Hyprland instead of hard-coding one here. That
# name is, as far as I can tell, always just the index of the
# workspace though, so not all that valuable.
ws_1: &ws_1 "I"
ws_2: &ws_2 "II"
ws_3: &ws_3 "III"
ws_4: &ws_4 "IV"
ws_5: &ws_5 "V"
ws_6: &ws_6 "VI"
ws_7: &ws_7 "VII"
ws_8: &ws_8 "VIII"
ws_9: &ws_9 "IX"
content:
list:
spacing: 6
items:
- map:
default:
string: { text: *ws_1, foreground: *ws_other }
conditions:
workspace_count < 2:
# if you replace all of these empty: entries with
#
# string: { text: *ws_N, foreground: *ws_empty }
#
# instead, then you'll always see the full
# workspace list. however, you'll be unable to use
# `{workspace_N}` as the workspace names in the
# anchors list above.
empty: {}
workspace_1_focused:
string: { text: *ws_1, foreground: *ws_focused }
workspace_1_active:
string: { text: *ws_1, foreground: *ws_active }
workspace_1_windows == 0:
string: { text: *ws_1, foreground: *ws_empty }
# All of the maps below are identical to the one above,
# except with N++.
- map:
default:
string: { text: *ws_2, foreground: *ws_other }
conditions:
workspace_count < 3:
empty: {}
workspace_2_focused:
string: { text: *ws_2, foreground: *ws_focused }
workspace_2_active:
string: { text: *ws_2, foreground: *ws_active }
workspace_2_windows == 0:
string: { text: *ws_2, foreground: *ws_empty }
- map:
default:
string: { text: *ws_3, foreground: *ws_other }
conditions:
workspace_count < 4:
empty: {}
workspace_3_focused:
string: { text: *ws_3, foreground: *ws_focused }
workspace_3_active:
string: { text: *ws_3, foreground: *ws_active }
workspace_3_windows == 0:
string: { text: *ws_3, foreground: *ws_empty }
- map:
default:
string: { text: *ws_4, foreground: *ws_other }
conditions:
workspace_count < 5:
empty: {}
workspace_4_focused:
string: { text: *ws_4, foreground: *ws_focused }
workspace_4_active:
string: { text: *ws_4, foreground: *ws_active }
workspace_4_windows == 0:
string: { text: *ws_4, foreground: *ws_empty }
- map:
default:
string: { text: *ws_5, foreground: *ws_other }
conditions:
workspace_count < 6:
empty: {}
workspace_5_focused:
string: { text: *ws_5, foreground: *ws_focused }
workspace_5_active:
string: { text: *ws_5, foreground: *ws_active }
workspace_5_windows == 0:
string: { text: *ws_5, foreground: *ws_empty }
- map:
default:
string: { text: *ws_6, foreground: *ws_other }
conditions:
workspace_count < 7:
empty: {}
workspace_6_focused:
string: { text: *ws_6, foreground: *ws_focused }
workspace_6_active:
string: { text: *ws_6, foreground: *ws_active }
workspace_6_windows == 0:
string: { text: *ws_6, foreground: *ws_empty }
- map:
default:
string: { text: *ws_7, foreground: *ws_other }
conditions:
workspace_count < 8:
empty: {}
workspace_7_focused:
string: { text: *ws_7, foreground: *ws_focused }
workspace_7_active:
string: { text: *ws_7, foreground: *ws_active }
workspace_7_windows == 0:
string: { text: *ws_7, foreground: *ws_empty }
- map:
default:
string: { text: *ws_8, foreground: *ws_other }
conditions:
workspace_count < 9:
empty: {}
workspace_8_focused:
string: { text: *ws_8, foreground: *ws_focused }
workspace_8_active:
string: { text: *ws_8, foreground: *ws_active }
workspace_8_windows == 0:
string: { text: *ws_8, foreground: *ws_empty }
- map:
default:
string: { text: *ws_9, foreground: *ws_other }
conditions:
workspace_count < 10:
empty: {}
workspace_9_focused:
string: { text: *ws_9, foreground: *ws_focused }
workspace_9_active:
string: { text: *ws_9, foreground: *ws_active }
workspace_9_windows == 0:
string: { text: *ws_9, foreground: *ws_empty }
许可证
根据您选择的以下任一许可证:
- Apache许可证2.0版本(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证(LICENSE-MIT 或 http://opensource.org/licenses/MIT)
任选其一。
贡献
除非您明确表示,否则您提交给作品包含在内的任何贡献,根据Apache-2.0许可证的定义,将按照上述方式双重许可,不附加任何额外条款或条件。
依赖
~7–17MB
~209K SLoC