From f6573f2f4437b15a58632cd2efbb2f00c77ded38 Mon Sep 17 00:00:00 2001
From: kirbylife <gabriel13m@gmail.com>
Date: Sun, 23 Jun 2019 00:52:53 -0500
Subject: [PATCH] now search games in the extra folders and skip proton and
 steamworks items

---
 openbox-pipemenu-steam.py | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/openbox-pipemenu-steam.py b/openbox-pipemenu-steam.py
index f92e5d8..3165af4 100755
--- a/openbox-pipemenu-steam.py
+++ b/openbox-pipemenu-steam.py
@@ -42,8 +42,6 @@ def set_item(name, appid=None):
 
 
 def main(args):
-    games = []
-
     ### Header ###
     print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
     print("<openbox_pipe_menu>")
@@ -52,14 +50,30 @@ def main(args):
     if getstatusoutput("cd " + STEAM_URL)[0] == 1:
         set_item("Steam not installed")
     else:
-        games = getoutput("ls " + STEAM_URL + " | grep acf").split("\n")
+        folders = [STEAM_URL]
+        try:
+            # Search if you have games in other folders
+            with open(STEAM_URL + "/libraryfolders.vdf") as extras:
+                for line in extras:
+                    if "/" in line:
+                        folder = line.split("\t")[-1].strip()[1:-1]
+                        folder = folder + "/steamapps"
+                        folders.append(folder)
+        except Exception:
+            pass
+
+        games = []
+        for folder in folders:
+            library = getoutput("ls " + folder + " | grep acf").split("\n")
+            games.extend([folder + "/" + game for game in library])
+
         if not games:
             set_item("0 games installed")
         else:
-            for c in games:
+            for game in games:
                 appid = ""
                 name = ""
-                manifest = open(STEAM_URL + "/" + c, "r")
+                manifest = open(game, "r")
                 data = manifest.read().split("\n")
                 manifest.close()
                 for f in data:
@@ -67,7 +81,9 @@ def main(args):
                         appid = f.split('"')[3]
                     elif '"name"' in f:
                         name = f.split('"')[3]
-                set_item(name, appid)
+                        if "Proton" in name or "Steamworks" in name:
+                            continue
+                        set_item(name, appid)
 
     ### Footer ###
     print("</openbox_pipe_menu>")