Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit e897e34

Browse files
Merge pull request #7 from afwolfe/rcs_path
Replace manual RCS_PATH variable with automatic detection using RiotClientInstalls.json
2 parents b4f80b4 + 1210e32 commit e897e34

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

README.md

+1-26
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,7 @@ NOTE: Antivirus/Windows Defender might mark the executable as a **potentially un
2424

2525
3. Copy the path to the executable for a later step
2626
- if the folder was made under "C:\Program Files\valorant-rpc", the path would be "C:\Program Files\valorant-rpc\valorant-rpc.exe"
27-
28-
### Part 2: Finding the RiotClientServices.exe path
29-
1. Search for the installation location of RiotClientServices.exe
30-
- it is typically installed in C:\Riot Games\Riot Client\
31-
- ex. C:\Riot Games\Riot Client\RiotClientServices.exe
32-
2. Copy the path for the next part
33-
34-
### Part 3: Creating the system environment variable for RiotClientServices.exe path
35-
Creating this system variable will allow the extension to launch VALORANT
36-
1. In the **Windows Search Bar**, search for "environment" and select the *Edit the system environment variables* option
37-
38-
![image](https://user-images.githubusercontent.com/42125428/109581495-61ef7e80-7aca-11eb-82aa-0566caf33e3f.png)
39-
40-
2. In the **System Properties** window, select *Environment Variables*
41-
42-
![image](https://user-images.githubusercontent.com/42125428/109581512-69168c80-7aca-11eb-9eb2-8b8bb2e6f2ab.png)
43-
44-
3. In the **Environment Variables** window, select *New* under *System variables*
45-
46-
![image](https://user-images.githubusercontent.com/42125428/109581530-6f0c6d80-7aca-11eb-95de-05ce21f5e1a8.png)
47-
48-
4. Using the path copied in [part 2, step 2](https://github.com/colinhartigan/valorant-rich-presence/blob/main/README.md#part-2-finding-the-riotclientservicesexe-path), create a new system variable called **RCS_PATH** and click *OK*
49-
50-
![image](https://user-images.githubusercontent.com/42125428/109582065-7718dd00-7acb-11eb-9476-121bb0de9c4c.png)
51-
52-
### Part 4: Changing the VALORANT launch target
27+
### Part 2: Changing the VALORANT launch target
5328

5429
1. Locate the VALORANT shortcut
5530
- if you typically launch from your desktop, locate the VALORANT icon

main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def listen():
234234
#check if val is open
235235
if not is_process_running():
236236
print("valorant not opened, attempting to run...")
237-
subprocess.Popen([os.environ['RCS_PATH'], "--launch-product=valorant", "--launch-patchline=live"])
237+
subprocess.Popen([utils.get_rcs_path(), "--launch-product=valorant", "--launch-patchline=live"])
238238
while not is_process_running():
239239
print("waiting for valorant...")
240240
launch_timer += 1

utils.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import iso8601
2+
import os
3+
import json
24

35
maps = {
46
"Port":"Icebox",
@@ -36,5 +38,18 @@ def parse_time(time):
3638
split = iso8601.parse_date(split).timestamp()
3739
return split
3840

41+
def get_rcs_path():
42+
"""Attempts to use the RiotClientInstalls.json file to detect the location of RiotClientServices.
43+
Returns the absolute path if found or None if not."""
44+
RIOT_CLIENT_INSTALLS_PATH = os.path.expandvars("%PROGRAMDATA%\\Riot Games\\RiotClientInstalls.json")
45+
try:
46+
with open(RIOT_CLIENT_INSTALLS_PATH, "r") as file:
47+
client_installs = json.load(file)
48+
rcs_path = os.path.abspath(client_installs["rc_default"])
49+
if not os.access(rcs_path, os.X_OK):
50+
return None
51+
return rcs_path
52+
except FileNotFoundError:
53+
return None
3954

4055
validate_party_size = lambda data : data["isPartyOwner"] == True and data["partySize"] > 1

0 commit comments

Comments
 (0)