diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-14 05:57:34 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-14 05:57:34 +0800 |
| commit | 2030a14afc3753746aa2bd2f36e4b49f590063df (patch) | |
| tree | 4edc2a3fcbcdfcab6c12820fecc083067b6ff138 /scripts/toggle_float_center.sh | |
| parent | bc8a5889c4bb52405f2ac73d18a42ab43e93e867 (diff) | |
fix(config): update wallpaper and fix float toggle for Lua build
Update wallpaper to KON_2.png and rewrite toggle_float_center.sh
to use Lua syntax dispatchers, as old dispatcher names are
unavailable under hyprland.lua.
```
Diffstat (limited to 'scripts/toggle_float_center.sh')
| -rwxr-xr-x | scripts/toggle_float_center.sh | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/scripts/toggle_float_center.sh b/scripts/toggle_float_center.sh index 889430c..831f162 100755 --- a/scripts/toggle_float_center.sh +++ b/scripts/toggle_float_center.sh @@ -1,18 +1,30 @@ #!/bin/bash +# 切换窗口浮动:平铺 -> 浮动(缩放至 50%x75% 并居中) / 浮动 -> 平铺 +# +# 注意:Lua 配置(hyprland.lua)下,`hyprctl dispatch` 是 hl.dispatch(...) 的包装, +# 旧 dispatcher 名(togglefloating/resizeactive/centerwindow/movecursor)已不可用, +# 必须使用 Lua 语法(hl.dsp.*)。 + # 使用 grep 检查浮动状态 FLOATING=$(hyprctl activewindow | grep -oP 'floating:\s*\K\w+') if [ "$FLOATING" = "0" ] || [ -z "$FLOATING" ]; then # 平铺 -> 浮动 - hyprctl dispatch togglefloating + hyprctl dispatch "hl.dsp.window.float({ action = \"enable\" })" sleep 0.05 - hyprctl dispatch resizeactive exact 50% 75% - hyprctl dispatch centerwindow + + # 计算屏幕逻辑尺寸:逻辑 = 像素 / scale(取聚焦显示器) + eval "$(hyprctl monitors -j | jq -r '.[] | select(.focused == true) | "MW=\(.width / .scale) MH=\(.height / .scale) MX=\(.x) MY=\(.y)"')" + + W=$((MW * 50 / 100)) # 50% 宽 + H=$((MH * 75 / 100)) # 75% 高 + hyprctl dispatch "hl.dsp.window.resize({ x = $W, y = $H })" + hyprctl dispatch "hl.dsp.window.center()" sleep 0.05 - # 移动鼠标到屏幕中心(近似窗口中心) - hyprctl dispatch movecursor 50% 50% + # 移动鼠标到屏幕中心(对应原 movecursor 50% 50%) + hyprctl dispatch "hl.dsp.cursor.move({ x = $((MX + MW / 2)), y = $((MY + MH / 2)) })" else # 浮动 -> 平铺 - hyprctl dispatch togglefloating + hyprctl dispatch "hl.dsp.window.float({ action = \"disable\" })" fi |
