install: auto-write the floating window rule on Omarchy

Both the Walker entry and the optional clipboard keybind now use the dedicated
'omagrab' app-id, and the installer writes the float/center/size rule to
windows.conf (idempotent, backed up, reloads Hyprland). No manual window-rule
step left — only the optional keybind is printed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
28allday 2026-06-08 19:03:51 +01:00
parent 522eef4b9e
commit 4ce4856134
2 changed files with 42 additions and 28 deletions

View file

@ -43,8 +43,8 @@ sudo pacman -S yt-dlp ffmpeg wl-clipboard
## Install
One line — pulls in `yt-dlp`, `ffmpeg` and `wl-clipboard` via pacman if they're
missing, installs the binary to `~/.local/bin`, and (on Omarchy) adds a floating
Walker entry:
missing, installs the binary to `~/.local/bin`, and (on Omarchy) adds a Walker
entry plus the Hyprland rule that makes omagrab float small and centered:
```bash
curl -fsSL https://raw.githubusercontent.com/28allday/omagrab/main/install.sh | bash
@ -59,8 +59,8 @@ cd omagrab
./install.sh
```
Make sure `~/.local/bin` is on your `PATH`. The installer prints the optional
`SUPER+SHIFT+V` clipboard keybind for you to add.
Make sure `~/.local/bin` is on your `PATH`. The installer also prints an optional
`SUPER+SHIFT+V` clipboard keybind for you to add (see below).
## Usage
@ -87,28 +87,26 @@ In the config view: `↑↓` move, `←→` change a value, `Esc` saves and retu
> Single-letter commands (`c`, `d`, `q`) only act when the URL box is empty — so
> they never get swallowed while you're typing or pasting a link.
## Clipboard keybind (recommended)
## Clipboard keybind (optional)
The smoothest flow on Omarchy: copy a link in your browser, then summon omagrab as
a floating window with the URL already filled in.
Add to `~/.config/hypr/bindings.conf`:
The installer already added the floating window rule (`omagrab` floats small and
centered however it's launched), so all you need is the keybind. Add to
`~/.config/hypr/bindings.conf`:
```ini
bindd = SUPER SHIFT, V, omagrab, exec, xdg-terminal-exec --app-id=omagrab -e omagrab --clip
```
And a floating rule in `~/.config/hypr/windows.conf` (Hyprland ≥ 0.55 syntax):
```ini
windowrule = float on, match:class ^(omagrab)$
windowrule = center on, match:class ^(omagrab)$
windowrule = size 520 260, match:class ^(omagrab)$
```
Reload Hyprland (`hyprctl reload`). Now: **copy a link → `SUPER+SHIFT+V`
omagrab floats with the URL ready → `Tab` to pick mode → `Enter`.**
> Both the Walker entry and this keybind use the `omagrab` app-id, so the single
> window rule the installer wrote to `~/.config/hypr/windows.conf` covers them
> both. If you ever want to tweak the size, edit the `windowrule` block there.
## Configuration
`~/.config/omagrab/config.json`:

View file

@ -107,9 +107,10 @@ install -Dm755 "$TMPBIN" "$BIN"
bold "Installed: $BIN"
# ---- Omarchy desktop integration -----------------------------------------
# Only on Omarchy: add a Walker entry that opens omagrab in a floating window.
# The TUI.float app-id is matched by Omarchy's stock floating-window rule, so
# no Hyprland configuration is required (same approach as tsplay / omarchy-send).
# Only on Omarchy: add a Walker entry that opens omagrab, and a Hyprland window
# rule so it floats small and centered. Both the Walker entry and the optional
# clipboard keybind use the dedicated "omagrab" app-id, so this one rule covers
# every launch path.
if command -v omarchy-launch-tui >/dev/null 2>&1 || [ -d "$HOME/.local/share/omarchy" ]; then
mkdir -p "$APP_DIR"
@ -131,7 +132,7 @@ SVG
[Desktop Entry]
Name=omagrab
Comment=yt-dlp TUI — paste a URL, pick Audio or Video, download
Exec=xdg-terminal-exec --app-id=TUI.float -e $BIN
Exec=xdg-terminal-exec --app-id=omagrab -e $BIN
Icon=omagrab
Terminal=false
Type=Application
@ -141,20 +142,35 @@ EOF
bold "Omarchy detected — added floating Walker entry (with icon)."
echo " Launch it from Walker by searching 'omagrab'."
# Write a small floating window rule, idempotently, between markers we own so
# re-running the installer never duplicates it. Back the file up first.
windows_conf="$HOME/.config/hypr/windows.conf"
begin="# >>> omagrab windowrules begin"
end="# <<< omagrab windowrules end"
if [ -f "$windows_conf" ] && grep -qF "$begin" "$windows_conf"; then
echo " Hyprland float rule already present — left as-is."
else
mkdir -p "$(dirname "$windows_conf")"
[ -f "$windows_conf" ] && cp "$windows_conf" "$windows_conf.omagrab-bak"
{
printf '\n%s\n' "$begin"
printf '# omagrab — small floating window, centered.\n'
printf 'windowrule = float on, match:class ^(omagrab)$\n'
printf 'windowrule = center on, match:class ^(omagrab)$\n'
printf 'windowrule = size 520 260, match:class ^(omagrab)$\n'
printf '%s\n' "$end"
} >> "$windows_conf"
echo " Added floating window rule to ~/.config/hypr/windows.conf (520x260, centered)."
command -v hyprctl >/dev/null 2>&1 && hyprctl reload >/dev/null 2>&1 || true
fi
cat <<EOF
Optional: bind clipboard-launch to a key. Copy a link, hit the key, and omagrab
opens with the URL pre-filled. Add to ~/.config/hypr/bindings.conf:
Optional clipboard keybind: copy a link, hit the key, and omagrab opens with the
URL pre-filled (it already floats — the rule above covers it). Add to
~/.config/hypr/bindings.conf:
bindd = SUPER SHIFT, V, omagrab, exec, xdg-terminal-exec --app-id=omagrab -e omagrab --clip
and a floating rule to ~/.config/hypr/windows.conf (Hyprland >= 0.55):
windowrule = float on, match:class ^(omagrab)\$
windowrule = center on, match:class ^(omagrab)\$
windowrule = size 520 260, match:class ^(omagrab)\$
then run 'hyprctl reload'.
EOF
fi