From: Stephen Jianu Date: Sun, 26 Nov 2023 04:46:45 +0000 (-0600) Subject: Output HTML when not running under CLI in order to get a web-based version of the... X-Git-Url: https://stephenjianu.com/gitweb/?a=commitdiff_plain;ds=inline;p=steam_shader_stats.git Output HTML when not running under CLI in order to get a web-based version of the script --- diff --git a/steam_shader_stats.php b/steam_shader_stats.php index 2b08a90..1259901 100755 --- a/steam_shader_stats.php +++ b/steam_shader_stats.php @@ -12,8 +12,10 @@ exec("ps ax | grep shadercache | grep -v grep", $fossilizeList); // if the process list ends up returning nothing, Steam isn't currently processing shaders if (empty($fossilizeList)) { $output = "Steam is not currently processing shaders in the background.\n"; - exec ("notify-send \"".$output."\""); - echo $output; + if (defined('STDIN')) { + exec ("notify-send \"".$output."\""); + echo $output; + } } // get each matching appid from the process list output and put it into a list @@ -35,8 +37,28 @@ if (!empty($appList)) { $json = json_decode(file_get_contents($url), true); $gameName = $json[$appList[0]]['data']['name']; $output = "Steam is processing shaders for app ID ".$appList[0]." (".$gameName.") in the background.\n"; - exec ("notify-send \"".$output."\""); - echo $output; + if (defined('STDIN')) { + exec ("notify-send \"".$output."\""); + echo $output; + } +} + +// if we're not running in the CLI, output HTML +// to get a web-based version of this script. +// obviously, the web server needs to run on a machine that has Steam running. +if (!defined('STDIN')) { + echo ''; + echo ''; + echo ''; + echo 'Steam Shader Stats'; + echo ''; + echo ''; + echo '

Steam Shader Stats

'; + echo '

This page displays the current status of Steam shader processing.'; + echo '
The page will be auto-refreshed every minute.

'; + echo '

'.$output.'

'; + echo ''; + echo ''; } ?>