From 936ab71626c480d80be31ab61b932b0b94a1ee61 Mon Sep 17 00:00:00 2001 From: Midgard <2885-Midgard@users.noreply.framagit.org> Date: Wed, 10 Jul 2024 07:01:42 +0200 Subject: [PATCH] [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 --- i3/terminal.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/i3/terminal.sh b/i3/terminal.sh index 2c404d3..39248f5 100755 --- a/i3/terminal.sh +++ b/i3/terminal.sh @@ -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