Просмотр исходного кода

Correctly handle headless system detection

Zachary Kotlarek 13 лет назад
Родитель
Сommit
8d4f4e4837
1 измененных файлов с 7 добавлено и 7 удалено
  1. 7 7
      dmx/state.pl

+ 7 - 7
dmx/state.pl

@@ -18,7 +18,7 @@ sub mtime($);
 # User config
 # User config
 my $MEDIA_PATH    = `~/bin/video/mediaPath`;
 my $MEDIA_PATH    = `~/bin/video/mediaPath`;
 my %DISPLAY_DEVS  = ('TV' => 1, 'PROJECTOR' => 1);
 my %DISPLAY_DEVS  = ('TV' => 1, 'PROJECTOR' => 1);
-my $DISPLAY       = '<NONE>';
+my $DISPLAY       = undef();
 my $STATE_TIMEOUT = 180;
 my $STATE_TIMEOUT = 180;
 my %MON_FILES     = ();
 my %MON_FILES     = ();
 
 
@@ -160,7 +160,7 @@ foreach my $name (keys(%MON_FILES)) {
 		$attr{'exists'} = 1;
 		$attr{'exists'} = 1;
 	}
 	}
 	if ($file{'type'} =~ /\bVALUE\b/i) {
 	if ($file{'type'} =~ /\bVALUE\b/i) {
-		$attr{'value'}  = 1;
+		$attr{'value'} = 1;
 	}
 	}
 	if ($file{'type'} =~ /\bCLEAR\b/i) {
 	if ($file{'type'} =~ /\bCLEAR\b/i) {
 		$attr{'clear'} = 1;
 		$attr{'clear'} = 1;
@@ -172,12 +172,12 @@ foreach my $name (keys(%MON_FILES)) {
 		$attr{'mtime'} = 1;
 		$attr{'mtime'} = 1;
 	}
 	}
 	if ($file{'type'} =~ /\bGUI\b/i) {
 	if ($file{'type'} =~ /\bGUI\b/i) {
-		$attr{'gui'}    = 1;
+		$attr{'gui'} = 1;
 	}
 	}
 	if ($file{'type'} =~ /\bPLAYING\b/i) {
 	if ($file{'type'} =~ /\bPLAYING\b/i) {
 		$attr{'playing'} = 1;
 		$attr{'playing'} = 1;
 	}
 	}
-	
+
 	# Cross-match some data types for easy of use
 	# Cross-match some data types for easy of use
 	if ($attr{'value'} || $attr{'gui'} || $attr{'playing'}) {
 	if ($attr{'value'} || $attr{'gui'} || $attr{'playing'}) {
 		$attr{'status'} = 1;
 		$attr{'status'} = 1;
@@ -185,7 +185,7 @@ foreach my $name (keys(%MON_FILES)) {
 	if ($attr{'status'} || $attr{'exists'}) {
 	if ($attr{'status'} || $attr{'exists'}) {
 		$attr{'mtime'} = 1;
 		$attr{'mtime'} = 1;
 	}
 	}
-	
+
 	# Push ATTR into the file hash
 	# Push ATTR into the file hash
 	$file{'attr'} = \%attr;
 	$file{'attr'} = \%attr;
 
 
@@ -423,7 +423,7 @@ while (1) {
 
 
 	# Calculate the new state
 	# Calculate the new state
 	$stateLast = $state;
 	$stateLast = $state;
-	if (!$DISPLAY) {
+	if (!defined($DISPLAY) || !exists($files{$DISPLAY})) {
 
 
 		# If there's no display the state is always PLAY or PAUSE, as indicated by the master
 		# If there's no display the state is always PLAY or PAUSE, as indicated by the master
 		if ($playing) {
 		if ($playing) {
@@ -432,7 +432,7 @@ while (1) {
 			$state = 'PAUSE';
 			$state = 'PAUSE';
 		}
 		}
 
 
-	} elsif ($DISPLAY && exists($files{$DISPLAY}) && $files{$DISPLAY}->{'value'}) {
+	} elsif ($files{$DISPLAY}->{'value'}) {
 
 
 		# If a display exists and is on:
 		# If a display exists and is on:
 		# PLAY when video is active and playing
 		# PLAY when video is active and playing