From: Stephen Jianu <stephen@stephenjianu.com> Date: Sat, 9 Sep 2023 22:02:34 +0000 (-0500) Subject: Initial commit X-Git-Url: https://www.stephenjianu.com/gitweb/?a=commitdiff_plain;h=02e47ec72717de4be55443c39527fc1c990ab81f;p=steam_shader_stats.git Initial commit --- 02e47ec72717de4be55443c39527fc1c990ab81f diff --git a/steam_shader_stats.php b/steam_shader_stats.php new file mode 100755 index 0000000..643877d --- /dev/null +++ b/steam_shader_stats.php @@ -0,0 +1,42 @@ +<?php + +// steam_shader_stats.php - A small PHP script to display what apps Steam is +// currently processing shaders from, since with the new Steam UI update, +// this information is no longer visible in the Steam GUI + +$fossilizeList = []; +$appList = []; + +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; +} + +// get each matching appid from the process list output and put it into a list +foreach ($fossilizeList as $fossilize) { + preg_match('/\/\d*\//', $fossilize, $matches); + foreach ($matches as $match) { + $match = str_replace('/', '', $match); + array_push($appList, $match); + } +} + +// grab the game name using the unofficial Steam store API +// we can assume that since Steam only processes shaders for one game at a time +// that all appids in the list will match and we can just pull the first one +// Source: https://stackoverflow.com/questions/57031685/how-can-i-get-details-about-an-steam-appid-from-steam-web-api +// Source: https://wiki.teamfortress.com/wiki/User:RJackson/StorefrontAPI#appdetails +if (isset($appList)) { + $url = "https://store.steampowered.com/api/appdetails?appids=".$appList[0]; + $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; +} + +?>