Added environment variables
This commit is contained in:
@ -45,8 +45,8 @@ def createNewPictureObserver(callback: callable) -> Observer:
|
|||||||
if a new picture was found.
|
if a new picture was found.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if os.environ.get('VRC_PICTURES_DIR', None) is not None:
|
if os.environ.get('VRCCO_PICTURES_DIR', None) is not None:
|
||||||
path = os.environ.get('VRC_PICTURES_DIR')
|
path = os.environ.get('VRCCO_PICTURES_DIR')
|
||||||
elif platform.system() == 'Linux':
|
elif platform.system() == 'Linux':
|
||||||
path = '~/.local/share/Steam/steamapps/compatdata/438100/pfx'
|
path = '~/.local/share/Steam/steamapps/compatdata/438100/pfx'
|
||||||
path += '/drive_c/users/steamuser/Pictures/VRChat/'
|
path += '/drive_c/users/steamuser/Pictures/VRChat/'
|
||||||
|
|||||||
21
main.py
21
main.py
@ -1,15 +1,26 @@
|
|||||||
"""
|
"""
|
||||||
VRCCC (VRChat Custom Camera) is a simple Python script to
|
VRCCC (VRChat Custom Camera) is a simple Python script to
|
||||||
override camera options in VRChat using OSC.
|
override camera options in VRChat using OSC.
|
||||||
|
|
||||||
|
Environment variables:
|
||||||
|
VRCCO_OSCServerBind: The IP address for the OSC server to bind to, default is '127.0.0.1'.
|
||||||
|
VRCCO_OSCServerPort: The port the OSC server listenes on, default is 9001.
|
||||||
|
VRCCO_OSCClientBind: The IP address of VRChat's OSC server, default is '127.0.0.1'.
|
||||||
|
VRCCO_OSCClientPort: The port of VRChat's OSC server, default is 9000.
|
||||||
|
VRCCO_PICTURES_DIR: A manual override for where your VRChat pictures are stored.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
from pythonosc import udp_client, osc_server
|
from pythonosc import udp_client, osc_server
|
||||||
from pythonosc.dispatcher import Dispatcher
|
from pythonosc.dispatcher import Dispatcher
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
from camera import Camera
|
from camera import Camera
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
overrides = {}
|
overrides = {}
|
||||||
|
|
||||||
def onCameraEnabled(cam: Camera):
|
def onCameraEnabled(cam: Camera):
|
||||||
@ -24,10 +35,16 @@ def onCameraEnabled(cam: Camera):
|
|||||||
with open('cameraOverrides.json', 'r', encoding='utf-8') as f:
|
with open('cameraOverrides.json', 'r', encoding='utf-8') as f:
|
||||||
overrides = json.loads(f.read())
|
overrides = json.loads(f.read())
|
||||||
|
|
||||||
client = udp_client.SimpleUDPClient('127.0.0.1', 9000, timeout=2.5)
|
clientIP = os.environ.get('VRCCO_OSCClientBind', '127.0.0.1')
|
||||||
|
clientPort = os.environ.get('VRCCO_OSCClientPort', 9000)
|
||||||
|
client = udp_client.SimpleUDPClient(clientIP, clientPort, timeout=2.5)
|
||||||
|
|
||||||
dispatcher = Dispatcher()
|
dispatcher = Dispatcher()
|
||||||
|
serverIP = os.environ.get('VRCCO_OSCServerBind', '127.0.0.1')
|
||||||
|
serverPort = os.environ.get('VRCCO_OSCServerPort', 9001)
|
||||||
|
server = osc_server.ThreadingOSCUDPServer((serverIP, serverPort), dispatcher, timeout=2.5)
|
||||||
|
|
||||||
camera = Camera(dispatcher, client, onCameraEnabled)
|
camera = Camera(dispatcher, client, onCameraEnabled)
|
||||||
server = osc_server.ThreadingOSCUDPServer(('127.0.0.1', 9001), dispatcher, timeout=2.5)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
server.serve_forever() # Serve, queen 💅
|
server.serve_forever() # Serve, queen 💅
|
||||||
|
|||||||
@ -1,2 +1,3 @@
|
|||||||
|
python-dotenv
|
||||||
python-osc
|
python-osc
|
||||||
watchdog
|
watchdog
|
||||||
Reference in New Issue
Block a user