feat(hypr): auto-swap-to-master on fetch/focus, use --persistent dispatches
fetch_or_launch and focus_or_launch now swap the target client to master layout position when it is not already the master. Scripts switched from raw hl.dsp.* calls to --persistent lua function dispatches (fetch_or_launch / focus_or_launch), and both now guard against empty rofi selection.
This commit is contained in:
@@ -209,10 +209,14 @@ function focus_or_launch(opts)
|
|||||||
on_current_monitor = true,
|
on_current_monitor = true,
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
hl.dispatch(hl.dsp.focus({
|
hl.dispatch(hl.dsp.focus({
|
||||||
window = "address:" .. client.address
|
window = "address:" .. client.address
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
local layout = client.layout
|
||||||
|
if not (layout and layout.name == "master" and layout.is_master) then
|
||||||
|
hl.dispatch(hl.dsp.layout("swapwithmaster"))
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -235,14 +239,18 @@ function fetch_or_launch(opts)
|
|||||||
if value and string.find(string.lower(value), string.lower(match), 1, true) then
|
if value and string.find(string.lower(value), string.lower(match), 1, true) then
|
||||||
if use_workspace and client.workspace and client.workspace.id then
|
if use_workspace and client.workspace and client.workspace.id then
|
||||||
hl.dispatch(hl.dsp.window.move({
|
hl.dispatch(hl.dsp.window.move({
|
||||||
workspace = active_workspace.id,
|
workspace = active_workspace,
|
||||||
on_current_monitor = true,
|
on_current_monitor = true,
|
||||||
|
window = client,
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
hl.dispatch(hl.dsp.focus({
|
hl.dispatch(hl.dsp.focus({window = client}))
|
||||||
window = "address:" .. client.address
|
|
||||||
}))
|
local layout = client.layout
|
||||||
|
if not (layout and layout.name == "master" and layout.is_master) then
|
||||||
|
hl.dispatch(hl.dsp.layout("swapwithmaster"))
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
chooser="rofi -i -dmenu -display-columns 1"
|
chooser="rofi -i -dmenu -display-columns 1"
|
||||||
workspace=$(hyprctl activeworkspace -j | jq -r '.id')
|
workspace=$(hyprctl activeworkspace -j | jq -r '.id')
|
||||||
selected=$(hyprctl clients -j | jq -r 'to_entries | .[] | select(.value.hidden == false) | "\(.value.title)\t\(.value.class)::\(.value.address)"' | $chooser -p 'Client to Fetch')
|
selected=$(hyprctl clients -j | jq -r 'to_entries | .[] | select(.value.hidden == false) | "\(.value.title)\t\(.value.class)::\(.value.address)"' | $chooser -p 'Client to Fetch')
|
||||||
#address=$(hyprctl clients -j | jq -r "to_entries | .[] | select(.value.title == \"$selected\") | \"\(.value.address)\"")
|
|
||||||
address=$(echo "$selected" | awk -F '::' '{print $NF}')
|
address=$(echo "$selected" | awk -F '::' '{print $NF}')
|
||||||
#hyprctl dispatch movetoworkspace "$workspace,address:$address"
|
if [ -z "$address" ]; then
|
||||||
hyprctl dispatch "hl.dsp.window.move({workspace = $workspace, follow = true, window = \"address:$address\"})"
|
notify-send "No client selected"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
hyprctl dispatch "fetch_or_launch({ match = '$address', field = 'address', cmd = 'notify-send \"$selected not found\"'})"
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
chooser="rofi -i -dmenu -display-columns 1"
|
chooser="rofi -i -dmenu -display-columns 1"
|
||||||
selected=$(hyprctl clients -j | jq -r 'to_entries | .[] | select(.value.hidden == false) | "\(.value.title) \t\(.value.class)::\(.value.address)"' | $chooser -p 'Client to Focus')
|
selected=$(hyprctl clients -j | jq -r 'to_entries | .[] | select(.value.hidden == false) | "\(.value.title) \t\(.value.class)::\(.value.address)"' | $chooser -p 'Client to Focus')
|
||||||
address=$(echo $selected | awk -F'::' '{print $NF}')
|
address=$(echo $selected | awk -F'::' '{print $NF}')
|
||||||
json=$(hyprctl clients -j | jq -r ".[] | select(.address == \"$address\")")
|
if [ -z "$address" ]; then
|
||||||
workspace=$(echo $json | jq -r '.workspace.id')
|
notify-send "No client selected"
|
||||||
hyprctl dispatch "hl.dsp.focus({workspace = $workspace , on_current_monitor = true})"
|
exit 1
|
||||||
hyprctl dispatch "hl.dsp.focus({ window = \"address:$address\" })"
|
fi
|
||||||
|
hyprctl dispatch "focus_or_launch({ match = '$address', field = 'address', cmd = 'notify-send \"$selected not found\"'})"
|
||||||
|
|||||||
Reference in New Issue
Block a user