From c479300999784776479a8dc9edfc54a1c043e007 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 18 Sep 2024 11:04:21 +0200 Subject: [PATCH] =?UTF-8?q?qb:=20Add=20some=20exit=20if=20error=20?= =?UTF-8?q?=F0=9F=91=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qb | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/qb b/qb index e396d62..36cc8ef 100755 --- a/qb +++ b/qb @@ -133,22 +133,25 @@ focus_to_qutebrowser() { # {{{ qutebrowser_window_id=$(command wmctrl -l | grep --max-count=1 -E -- "${QUTEBROWSER_WINDOW_TITLE}" | cut -d" " -f1) debug_message "focus_to_qutebrowser − \ -Qutebrowser window ID : ${RED}${qutebrowser_window_id}${COLOR_DEBUG} on desktop ID : ${RED}${qutebrowser_desktop_id}${COLOR_DEBUG}." +Qutebrowser window ID (window title: ${QUTEBROWSER_WINDOW_TITLE}) : ${RED}${qutebrowser_window_id}${COLOR_DEBUG} on desktop ID : ${RED}${qutebrowser_desktop_id}${COLOR_DEBUG}." ### Switch to Qutebrowser desktop - command wmctrl -s "${qutebrowser_desktop_id}" + command wmctrl -s "${qutebrowser_desktop_id}" \ + || error_message "focus_to_qutebrowser - Fail to switch to desktop ID of Qutebrowser (${qutebrowser_desktop_id})." 90 ## If HerstluftWM is available if [ "$(command -v herbstclient)" ]; then debug_message "focus_to_qutebrowser − \ Focus with herbstclient." ### Focus to the window id - herbstclient jumpto "${qutebrowser_window_id}" + herbstclient jumpto "${qutebrowser_window_id}" \ + || error_message "focus_to_qutebrowser - Fail to switch to Qutebrowser Window ID (${qutebrowser_window_id}) with herbstclient." 91 else debug_message "focus_to_qutebrowser − \ Focus with wmctrl." ### Switch expected window - command wmctrl -i -R "${qutebrowser_window_id}" + command wmctrl -i -R "${qutebrowser_window_id}" \ + || error_message "focus_to_qutebrowser - Fail to switch to Qutebrowser Window ID (${qutebrowser_window_id}) with wmctrl." 92 fi } @@ -160,7 +163,8 @@ get_qutebrowser_buffers() { # {{{ ## Run save_buffers.py in Qutebrowser echo '{"args":[":save-window-and-buffers"], "target_arg":"", "protocol_version":1}' |\ - socat - UNIX-CONNECT:"$QUTEBROWSER_SOCKET_FILE" + socat - UNIX-CONNECT:"$QUTEBROWSER_SOCKET_FILE" \ + || error_message "get_qutebrowser_buffers - Fail to contact ${QUTEBROWSER_SOCKET_FILE} socket file." 20 ## Wait to get the buffers list i="0" @@ -173,7 +177,8 @@ get_qutebrowser_buffers() { # {{{ i=$((i+1)) done - sed "s/^/ff /g" "${QUTEBROWSER_SESSION_FILE}" >> "${QUTEBROWSER_GLOBAL_CONTENT}" + sed "s/^/ff /g" "${QUTEBROWSER_SESSION_FILE}" >> "${QUTEBROWSER_GLOBAL_CONTENT}" \ + || error_message "get_qutebrowser_buffers - Fail on removing 'ff ' buffer prefix." 21 } # }}} @@ -183,8 +188,13 @@ get_qutebrowser_content() { # {{{ get_qutebrowser_searchengine - [ -f "${QUTEBROWSER_QUICKMARK_FILE}" ] && sed "s/^/qq /g" "${QUTEBROWSER_QUICKMARK_FILE}" >> "${QUTEBROWSER_GLOBAL_CONTENT}" - [ -f "${QUTEBROWSER_BOOKMARK_FILE}" ] && sed "s/^/bb /g" "${QUTEBROWSER_BOOKMARK_FILE}" >> "${QUTEBROWSER_GLOBAL_CONTENT}" + [ -f "${QUTEBROWSER_QUICKMARK_FILE}" ] \ + && sed "s/^/qq /g" "${QUTEBROWSER_QUICKMARK_FILE}" >> "${QUTEBROWSER_GLOBAL_CONTENT}" \ + || error_message "get_qutebrowser_content - Fail on removing 'qq ' quickmark prefix" 22 + + [ -f "${QUTEBROWSER_BOOKMARK_FILE}" ] \ + && sed "s/^/bb /g" "${QUTEBROWSER_BOOKMARK_FILE}" >> "${QUTEBROWSER_GLOBAL_CONTENT}" \ + || error_message "get_qutebrowser_content - Fail on removing 'bb ' bookmark prefix" 23 } # }}} @@ -219,7 +229,8 @@ goto_qutebrowser_content() { # {{{ debug_message "goto_qutebrowser_content − \ Search in Qutebrowser's content ${QUTEBROWSER_GLOBAL_CONTENT} file." - rofi -theme solarized_alternate -dmenu -location 6 -l 15 -theme-str 'window {width: 80%;}' -p 'Qutebrowser' > "${choice_temp_file}" < "${QUTEBROWSER_GLOBAL_CONTENT}" + rofi -theme solarized_alternate -dmenu -location 6 -l 15 -theme-str 'window {width: 80%;}' -p 'Qutebrowser' > "${choice_temp_file}" < "${QUTEBROWSER_GLOBAL_CONTENT}" \ + || error_message "goto_qutebrowser_content - Fail to display ${QUTEBROWSER_GLOBAL_CONTENT} with Rofi." 24 if [ -s "${choice_temp_file}" ]; then debug_message "goto_qutebrowser_content − \