From cc67a57ee5015c4d71a2e36c784b8c5e1fb5bc84 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 18 Sep 2024 11:37:37 +0200 Subject: [PATCH] qb: Fix window focusing --- qb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qb b/qb index 36cc8ef..ecb65fc 100755 --- a/qb +++ b/qb @@ -129,8 +129,8 @@ No existing instance of Qutebrowser. Starting…" >> /tmp/qb.log focus_to_qutebrowser() { # {{{ ## Get desktop and window ID of the first "qutebrowser" window - qutebrowser_desktop_id=$(command wmctrl -l | grep --max-count=1 -E -- "${QUTEBROWSER_WINDOW_TITLE}" | cut -d" " -f3) - qutebrowser_window_id=$(command wmctrl -l | grep --max-count=1 -E -- "${QUTEBROWSER_WINDOW_TITLE}" | cut -d" " -f1) + qutebrowser_desktop_id=$(command wmctrl -l | grep --max-count=1 --extended-regexp -- "${QUTEBROWSER_WINDOW_TITLE}*" | cut --delimiter=" " --fields=3) + qutebrowser_window_id=$(command wmctrl -l | grep --max-count=1 --extended-regexp -- "${QUTEBROWSER_WINDOW_TITLE}*" | cut --delimiter=" " --fields=1) debug_message "focus_to_qutebrowser − \ Qutebrowser window ID (window title: ${QUTEBROWSER_WINDOW_TITLE}) : ${RED}${qutebrowser_window_id}${COLOR_DEBUG} on desktop ID : ${RED}${qutebrowser_desktop_id}${COLOR_DEBUG}." @@ -298,8 +298,11 @@ Try to switch to buffer id: ${buffer_id}." echo "{\"args\":[\":tab-select ${buffer_id}\"], \"target_arg\":\"\", \"protocol_version\":1}" |\ socat - UNIX-CONNECT:"${QUTEBROWSER_SOCKET_FILE}" - ## Ensure to focus on expected buffer - QUTEBROWSER_WINDOW_TITLE="${buffer_title}" + ## Use wanted buffer title as window title (for focusing) + ## Remove : + ## the first argument : Qutebrowser Window ID/Qutebrowser buffer ID + ## the last argument : PyQt6…('URL') + QUTEBROWSER_WINDOW_TITLE="$(echo ${buffer_title} | awk '{for(i=2; i2) ? OFS : "" ) $i) } ;}')" } # }}}