Last active
December 19, 2024 21:27
-
-
Save VTSTech/465ef06994cfea462094c4ae6de3870d to your computer and use it in GitHub Desktop.
Raspberry Pi RPi Temperature Monitor by VTSTech
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<!-- If you get /dev/vcio error then 'sudo usermod -aG video www-data' --> | |
<!-- Refreshes every 10 seconds - www.vts-tech.org --> | |
<head> | |
<meta http-equiv="refresh" content="10"> | |
</head> | |
<?php | |
// Check for theme selection in GET or default to dark theme | |
$theme = isset($_GET['theme']) && $_GET['theme'] === 'light' ? 'light' : 'dark'; | |
// Define styles for light and dark themes | |
if ($theme === 'light') { | |
$bgColor = 'ffffff'; | |
$textColor = '000000'; | |
$linkColor = '0000ff'; | |
} else { | |
$bgColor = '000000'; | |
$textColor = 'ffffff'; | |
$linkColor = '00ff00'; | |
} | |
?> | |
<body bgcolor="<?php echo $bgColor; ?>" text="<?php echo $textColor; ?>" link="<?php echo $linkColor; ?>"> | |
<b><br>Raspberry Pi RPi Temperature Monitor</b> | |
<br>Written by <b><a href='https://www.vts-tech.org/' style="color:<?php echo $linkColor; ?>">VTSTech</a> | |
(<a href='https://github.com/VTSTech' style="color:<?php echo $linkColor; ?>">GitHub</a></b>) | |
<!-- Theme selection form --> | |
<form method="get"> | |
<label for="theme">Choose a theme:</label> | |
<select name="theme" id="theme" onchange="this.form.submit()"> | |
<option value="dark" <?php echo $theme === 'dark' ? 'selected' : ''; ?>>Dark</option> | |
<option value="light" <?php echo $theme === 'light' ? 'selected' : ''; ?>>Light</option> | |
</select> | |
</form> | |
<?php | |
echo '<font color="'.$bgColor.'"><pre>'; | |
$output = system("vcgencmd measure_temp"); | |
$temp = substr($output, 5); | |
echo '</pre></font>'; | |
echo '<title>RPi '.$temp.'</title>'; | |
echo '<font color="'.$textColor.'">RPi '.$temp; | |
?> | |
</body> | |
</html> |
Author
VTSTech
commented
Dec 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment