#!/bin/bash # raise.sh # Focus the app if it already has a window (also switches workspace/monitor). Pressing again while # it is focused cycles through its other windows. If it is not running, launch . # RAISE_DRY=1 only prints what would happen. re=$1; shift act=$(hyprctl activewindow -j 2>/dev/null | jq -r '.address // ""') target=$(hyprctl clients -j | jq -r --arg re "$re" --arg act "$act" ' [.[] | select(.class | test($re)) | select(.workspace.name | startswith("special") | not)] | sort_by(.focusHistoryID) as $w | if ($w | length) == 0 then "" elif $w[0].address == $act and ($w | length) > 1 then $w[1].address else $w[0].address end') if [ -z "$target" ]; then [ -n "$RAISE_DRY" ] && { echo "launch: $*"; exit 0; } exec "$@" fi [ -n "$RAISE_DRY" ] && { echo "focus: $target"; exit 0; } hyprctl dispatch "hl.dsp.focus({ window = \"address:$target\" })" >/dev/null