How to check how many devices are connecting my hotspot?

I am using 5.15.93-1-MANJARO with Plasma 5.26.5, and I set up a Wi-Fi hotspot in my Manjaro for other devices to connect the Wi-Fi network.

I would like to know how to check how many devices are connecting this hotspot. And if possible, can I check out those devices names like I can do in a router’s admin management page?

I found a feasible solution. First, to obtain the Wi-Fi interface name (say, it is wlo1) by ip link. Next, to filter all neighbors by filtering:

ip neigh | grep wlo1
1 Like

Use nmap and put something like this:

${color0}${font DroidSans:size=8}Devices on Studio-wifi:
${color0}${font DroidSans:size=8}${execpi 120 nmap -sP -oG - 10.42.0.0/24 | awk '/Host:/{ print $2," "," " substr($3, 2, length($3) - 2) }'}

in a conky and the ip numbers will show on your desktop, enter known devices in your hosts file and you get the full device names.
Conky Showcase 2022 - #23 by 6x12 .

1 Like

I wrote a shell to obtain those information by using iw, ip and avahi-resolve command:

wifiInterface=$(iw dev | grep Interface | awk '{print $2}')
ssid=$(iw dev $wifiInterface info | grep ssid | awk '{print $2}')
echo "Your SSID is $ssid."
connections=$(ip neigh | grep $wifiInterface)

ips=()
macs=()
devices=()
while IFS= read -r conn;
do 
  lladdr=$(echo $conn | awk '{print $4}')
  if [[ $lladdr == "lladdr" ]];
  then
    ip=$(echo $conn | awk '{print $1}')
    mac=$(echo $conn | awk '{print $5}')
    name=$(avahi-resolve --address $ip)
    if [[ $name != "" ]];
    then
      device=$(echo $name | awk '{print $2}')
      ips+=($ip)
      macs+=($mac)
      devices+=($device)
    fi
  fi
done <<< "$connections"

num=${#ips[@]}

plural() {
  local dn="device"
  if [[ num -gt 1 ]];
  then
    dn+="s"
  fi
  printf "%s" "$dn"
}

printf "$num $(plural) connecing to your hotspot!\n\n"

printf "%-15s %-25s %-20s\n" "IP" "MAC" "Device"

for (( i=0; i<${num}; i++ ));
do
  printf "%-15s %-25s %-20s\n" "${ips[$i]}" "${macs[$i]}" "${devices[$i]}"
done

Feedback is welcomed.

I added it at gist.