install: write Hyprland integration to bindings.lua on Omarchy 4+
Omarchy 4 replaced the sourced ~/.config/hypr/*.conf files with a Lua config chain, so the float rule and SUPER+SHIFT+V clipboard keybind written to windows.conf/bindings.conf were silently ignored. Detect hyprland.lua and write an idempotent o.window/o.bind block to bindings.lua instead, keeping the .conf path for older installs.
This commit is contained in:
parent
6b6dd9f239
commit
1f83d8a54b
1 changed files with 40 additions and 2 deletions
42
install.sh
42
install.sh
|
|
@ -142,12 +142,48 @@ EOF
|
||||||
bold "Omarchy detected — added floating Walker entry (with icon)."
|
bold "Omarchy detected — added floating Walker entry (with icon)."
|
||||||
echo " Launch it from Walker by searching 'omagrab'."
|
echo " Launch it from Walker by searching 'omagrab'."
|
||||||
|
|
||||||
|
# Omarchy 4+ replaced the sourced ~/.config/hypr/*.conf files with a Lua
|
||||||
|
# config chain (~/.config/hypr/hyprland.lua); anything written to the old
|
||||||
|
# .conf files is silently ignored there. Detect which world we're in and
|
||||||
|
# write the float rule + clipboard keybind to the file that's actually loaded.
|
||||||
|
if [ -f "$HOME/.config/hypr/hyprland.lua" ]; then
|
||||||
|
bindings_lua="$HOME/.config/hypr/bindings.lua"
|
||||||
|
lua_begin="-- >>> omagrab begin"
|
||||||
|
lua_end="-- <<< omagrab end"
|
||||||
|
if [ -f "$bindings_lua" ] && grep -qF "$lua_begin" "$bindings_lua"; then
|
||||||
|
echo " Hyprland rules + clipboard keybind already present — left as-is."
|
||||||
|
elif [ -f "$bindings_lua" ] && grep -Eq 'bind\("SUPER \+ SHIFT \+ V"' "$bindings_lua" && ! grep -q omagrab "$bindings_lua"; then
|
||||||
|
warn " SUPER+SHIFT+V is already bound to something else — skipping the keybind."
|
||||||
|
echo " To use it anyway, add this to ~/.config/hypr/bindings.lua yourself:"
|
||||||
|
echo " o.bind(\"SUPER + SHIFT + V\", \"omagrab (clipboard URL)\", \"xdg-terminal-exec --app-id=omagrab -e omagrab --clip\")"
|
||||||
|
else
|
||||||
|
mkdir -p "$(dirname "$bindings_lua")"
|
||||||
|
[ -f "$bindings_lua" ] && cp "$bindings_lua" "$bindings_lua.omagrab-bak"
|
||||||
|
{
|
||||||
|
printf '\n%s\n' "$lua_begin"
|
||||||
|
printf -- '-- omagrab — copy a link, press SUPER+SHIFT+V, omagrab opens with it pre-filled.\n'
|
||||||
|
printf 'o.window({ class = "^omagrab$" }, { float = true })\n'
|
||||||
|
printf 'o.window({ class = "^omagrab$" }, { center = true })\n'
|
||||||
|
printf 'o.window({ class = "^omagrab$" }, { size = { 520, 260 } })\n'
|
||||||
|
printf 'o.bind("SUPER + SHIFT + V", "omagrab (clipboard URL)", "xdg-terminal-exec --app-id=omagrab -e omagrab --clip")\n'
|
||||||
|
printf '%s\n' "$lua_end"
|
||||||
|
} >> "$bindings_lua"
|
||||||
|
echo " Added floating window rule + SUPER+SHIFT+V keybind to ~/.config/hypr/bindings.lua."
|
||||||
|
command -v hyprctl >/dev/null 2>&1 && hyprctl reload >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
skip_conf_integration=1
|
||||||
|
else
|
||||||
|
skip_conf_integration=0
|
||||||
|
fi
|
||||||
|
|
||||||
# Write a small floating window rule, idempotently, between markers we own so
|
# Write a small floating window rule, idempotently, between markers we own so
|
||||||
# re-running the installer never duplicates it. Back the file up first.
|
# re-running the installer never duplicates it. Back the file up first.
|
||||||
windows_conf="$HOME/.config/hypr/windows.conf"
|
windows_conf="$HOME/.config/hypr/windows.conf"
|
||||||
begin="# >>> omagrab windowrules begin"
|
begin="# >>> omagrab windowrules begin"
|
||||||
end="# <<< omagrab windowrules end"
|
end="# <<< omagrab windowrules end"
|
||||||
if [ -f "$windows_conf" ] && grep -qF "$begin" "$windows_conf"; then
|
if [ "$skip_conf_integration" = 1 ]; then
|
||||||
|
: # Lua config handled above; the .conf files aren't loaded on Omarchy 4+.
|
||||||
|
elif [ -f "$windows_conf" ] && grep -qF "$begin" "$windows_conf"; then
|
||||||
echo " Hyprland float rule already present — left as-is."
|
echo " Hyprland float rule already present — left as-is."
|
||||||
else
|
else
|
||||||
mkdir -p "$(dirname "$windows_conf")"
|
mkdir -p "$(dirname "$windows_conf")"
|
||||||
|
|
@ -171,7 +207,9 @@ EOF
|
||||||
kb_begin="# >>> omagrab keybind begin"
|
kb_begin="# >>> omagrab keybind begin"
|
||||||
kb_end="# <<< omagrab keybind end"
|
kb_end="# <<< omagrab keybind end"
|
||||||
keybind_line="bindd = SUPER SHIFT, V, omagrab, exec, xdg-terminal-exec --app-id=omagrab -e omagrab --clip"
|
keybind_line="bindd = SUPER SHIFT, V, omagrab, exec, xdg-terminal-exec --app-id=omagrab -e omagrab --clip"
|
||||||
if [ -f "$bindings_conf" ] && grep -qF "$kb_begin" "$bindings_conf"; then
|
if [ "$skip_conf_integration" = 1 ]; then
|
||||||
|
: # Lua config handled above; the .conf files aren't loaded on Omarchy 4+.
|
||||||
|
elif [ -f "$bindings_conf" ] && grep -qF "$kb_begin" "$bindings_conf"; then
|
||||||
echo " Clipboard keybind already present — left as-is."
|
echo " Clipboard keybind already present — left as-is."
|
||||||
elif [ -f "$bindings_conf" ] && grep -Eq '^[[:space:]]*bind[a-z]*[[:space:]]*=[[:space:]]*SUPER[[:space:]]+SHIFT[[:space:]]*,[[:space:]]*V[[:space:]]*,' "$bindings_conf"; then
|
elif [ -f "$bindings_conf" ] && grep -Eq '^[[:space:]]*bind[a-z]*[[:space:]]*=[[:space:]]*SUPER[[:space:]]+SHIFT[[:space:]]*,[[:space:]]*V[[:space:]]*,' "$bindings_conf"; then
|
||||||
warn " SUPER+SHIFT+V is already bound to something else — skipping the keybind."
|
warn " SUPER+SHIFT+V is already bound to something else — skipping the keybind."
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue