scripts

Assorted shell-scripts
Log | Files | Refs

lichess_status (554B)


      1 #!/bin/sh
      2 
      3 
      4 ###
      5 #	Tracks lichess-users, intended for status-bars. 
      6 #	-l : Echoes # of $usernames that are online
      7 #	-s : Echoes $usernames that are online
      8 ###
      9 
     10 usernames="ericrosen,alvinm"
     11 data="$(curl "https://lichess.org/api/users/status?ids="${usernames} | sed -E "s/\{/\\n/g" | grep -Eio '.*"online":true(,"playing":true)?')"
     12 while getopts 'ls' OPTION ; do
     13 case "$OPTION" in
     14 	l)
     15 		 [ -n "$data" ] && echo $data | tr " " "\n" | wc -l || echo "0"
     16 	;;
     17 	s) echo $data | grep -Eio '"name":"[-[:alnum:]_]*"' | cut -d ":" -f2 | tr -d '"' 
     18 	;;
     19 esac	
     20 done
     21 
     22 
     23 
     24