From 78594e9aee877cad58375434b23a6d71cc249e95 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Sat, 17 Aug 2024 23:14:36 +0200 Subject: [PATCH] susepaste: handle multiple login sessions The script would return something like ``` Failed to get path for session '1 2': No session '1 2' known Graphics server not found. Copying to clipboard is not possible. ``` if multiple login sessions matching the username are found. This is mostly caused by the list-sessions output being passed to the show-session query including line breaks. Repair this by: - querying only seat sessions, those are most likely to be graphical - stopping after the first match, instead of adding line breaks and additional session IDs to the type query (show-session does support passing multiple session IDs, but our case-logic would not handle the result) This might still be error prone, as someone could theoretically have multiple graphical sessions with a mix of X11 and Wayland launched, but I deem it already better than not handling multiple active login sessions at all. Signed-off-by: Georg Pfuetzenreuter --- script/susepaste | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/susepaste b/script/susepaste index 0ce919c..8ce69d9 100755 --- a/script/susepaste +++ b/script/susepaste @@ -136,8 +136,8 @@ if expr "$URL" : "^${SCHEMA}://paste.opensuse.org/[0-9a-f]\+" > /dev/null; then if [ -x /usr/bin/loginctl ] then - session_id=$(loginctl list-sessions --no-legend | awk "/$SELF/{print \$1}") - session_type=$(loginctl show-session "$session_id" -P Type) + session_id=$(loginctl list-sessions --no-legend | awk "/$SELF seat[0-9]* /{ print \$1 ; exit }") + session_type=$(loginctl show-session -PType "$session_id") case "$session_type" in "x11")