[terminal.sh] Use lswt instead of swaymsg

to support all compositors that support either
ext-foreign-toplevel-list-v1 or
wlr-foreign-toplevel-management-unstable-v1
This commit is contained in:
Midgard 2024-07-10 07:01:42 +02:00
parent cf073c7e92
commit 936ab71626
Signed by untrusted user who does not match committer: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -15,11 +15,15 @@ fi
# location as working directory. Like this, terminals are opened in the same
# directory as the currently focused one.
sway_focused_window() {
swaymsg -t get_tree | jq -r '.. | select(.focused?) | .name'
focused_window_title() {
if [ -n "${WAYLAND_DISPLAY:-}" ]; then
lswt -j | jq -r '.toplevels | map(select(.activated?))[0] | .title'
else
xtitle
fi
}
title="$(sway_focused_window || xtitle)"
title="$(focused_window_title)"
path=""
if [[ $title =~ (in|^.*@$(hostname):)(~?)(/.*) ]]; then