summaryrefslogtreecommitdiffstats
path: root/src/smartauth_displayfinder
blob: cbe9decee15193e0755875939c74fc5669d26e00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash								

mkdir -p /tmp/smartauthmon/						
ls /var/run/xdmctl > /tmp/smartauthmon/originalxdm			
										
# Set loop separator to end of line					
BAKIFS=$IFS								
IFS=$(echo -en "\n\b")						
exec 3<&0								
exec 0</tmp/smartauthmon/originalxdm					
newdisplayfound=0							
newdisplay=-1								
while read -r line							
do									
	# use $line variable to process lines				
	line=$(echo $line | grep 'xdmctl-:' | sed -e 's/xdmctl-://')	
	if [ "`expr $line - $line 2>/dev/null`" == "0" ]; then	
		echo "Found active display on $line"			
		if [[ $newdisplayfound -eq 0 ]]; then			
			tempnewdisplay=$((newdisplay + 1))		
			if [[ $line -eq $tempnewdisplay ]]; then	
				echo "Sequential display $line found after display $newdisplay..."
				newdisplay=$line			
			fi						
		fi							
	fi								
done									
exec 0<&3								
newdisplay=$(($newdisplay + 1))					
rm -rf /tmp/smartauthmon/