]> Stephen's Gitweb - steam_shader_stats.git/commitdiff
Initial commit
authorStephen Jianu <stephen@stephenjianu.com>
Sat, 9 Sep 2023 22:02:34 +0000 (17:02 -0500)
committerStephen Jianu <stephen@stephenjianu.com>
Sat, 9 Sep 2023 22:02:34 +0000 (17:02 -0500)
steam_shader_stats.php [new file with mode: 0755]

diff --git a/steam_shader_stats.php b/steam_shader_stats.php
new file mode 100755 (executable)
index 0000000..643877d
--- /dev/null
@@ -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;
+}
+
+?>