5cb8e4f832ad2372a71800c52d77ddfd5fad04ed
[progcomp2013.git] / qchess_login.sh
1 #!/bin/bash
2
3 # Qchess login script
4 # Only works with GDM
5 # WARNING: Don't use on systems without GDM, because it will probably break everything
6 # Add to root's crontab to run every minute
7
8 # Check qchess isn't already running
9 if [ "$(ps aux | grep -v grep | grep "qchess\.py" | wc -l)" != "0" ]; then
10         echo "qchess already running" 1>&2
11         (ps aux | grep -v grep | grep qchess) 1>&2
12         exit 0
13 fi
14
15 # Check that only GDM is running gnome-session
16 # This should indicate that the login selection is being shown
17 session_types="gnome-session\|kdeinit"
18 non_gdm_sessions=$(ps aux | grep -v grep | grep "$session_types" | awk '{print $1}' | grep -v gdm | wc -l)
19
20 if [ "$non_gdm_sessions" != 0 ]; then
21         echo "$non_gdm_sessions non gdm sessions running" 1>&2
22         exit 0
23 fi
24
25 # OK, go ahead and do evil stuff
26
27 export DISPLAY=:1
28 p=$(pwd)
29 cd /home/wheel/matches/progcomp2013/qchess
30 win="black"
31
32 #espeak "I challenge you to a duel!"
33 while [ "$win" == "black" ]; do
34         win=$(./qchess.py @human @internal:AgentBishop)
35 done
36
37 #if [ "$win" == "white" ]; then
38 #       espeak "I'll beat you next time."
39 #else
40 #       espeak "You dirty, cheating, human."
41 #fi
42 cd $p

UCC git Repository :: git.ucc.asn.au