Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for Ubuntu 20.04 #5

Open
arnuschky opened this issue Mar 24, 2021 · 0 comments
Open

Changes for Ubuntu 20.04 #5

arnuschky opened this issue Mar 24, 2021 · 0 comments

Comments

@arnuschky
Copy link

arnuschky commented Mar 24, 2021

Use login-ctl to get username, use w instead of who to get display variable directly.

--- batify/xpub/src/xpub.sh	2021-03-24 20:46:54.288945317 +0100
+++ /usr/local/bin/xpub	2021-03-24 21:22:25.474690184 +0100
@@ -66,7 +66,7 @@
 
     ${tFlag} && xtty="${tArg}" || xtty="$(cat /sys/class/tty/tty0/active)"
 
-    xuser="$(who | grep "${xtty}" | head -n 1 | cut -d' ' -f1)"
+    xuser="$(loginctl list-sessions | grep "${xtty}" | awk '{print $3}' )"
 
     [ -z "${xuser}" ] && { echo "No user found from ${xtty}." 1>&2; exit 1; }
 
@@ -75,7 +75,7 @@
 
     if [ -n "${xpids}" ]; then
         for xpid in ${xpids}; do
-            xdisplay="$(ps -o cmd= "${xpid}" | grep "${vterm}" | grep -E -o ':[0-9]')"
+            xdisplay="$(w | grep "${xuser}" | grep -E -o ':[0-9]' | sort -u)"
             if [ "$?" -eq 0 ]; then
                 xdisplay="$(echo "${xdisplay}" | head -n1)"
                 break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant