0

i want to get info via ssh-session, which user is currently using the machine. i get the users which are logged in with "w" or "who" but how can i see which one has currently the desktop open to send him a message using yad?

edit: i found a dirty code.. but works for now:

#!/bin/bash
tty=$(cat /sys/class/tty/tty0/active)
active_user=$(w | grep $tty | awk '{print $1;}')

#to get the display also:
disp=$(who | awk -v term="$tty" '/\(:/ $0 ~ term { gsub(/\(|\)/, "", $0); print $5 }')
sil_el_mot
  • 11
  • 2
  • after trying around i came to the added option. not very clean but works for now – sil_el_mot Feb 20 '18 at 15:18
  • 2
    Welcome to Ask Ubuntu. This is a question answer site. Please don't put the answer to your question in the question part. Feel free to answer your own question. The answer should go in the bottom, where it says **Your Answer**. Please return after the wait period and mark your answer (or the answer that you think is the best) as the correct answer by clicking on the green check mark next to the answer. – user68186 Feb 20 '18 at 15:26

1 Answers1

1

i found a dirty code.. but works for now:

#!/bin/bash
tty=$(cat /sys/class/tty/tty0/active)
active_user=$(w | grep $tty | awk '{print $1;}')

#to get the display also:
disp=$(who | awk -v term="$tty" '/\(:/ $0 ~ term { gsub(/\(|\)/, "", $0); print $5 }')
sil_el_mot
  • 11
  • 2