Skip to content

Commit

Permalink
fix: remove default filepicker path hardcode
Browse files Browse the repository at this point in the history
  • Loading branch information
SheffeyG committed Sep 29, 2024
1 parent e14fa07 commit 9434ee3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import decky # type: ignore

# Setup environment variables
deckyHomeDir = decky.DECKY_HOME
settingsDir = decky.DECKY_PLUGIN_SETTINGS_DIR
loggingDir = decky.DECKY_PLUGIN_LOG_DIR
logger = decky.logger
Expand Down Expand Up @@ -59,3 +58,7 @@ async def settings_getSetting(cls, data: GetSettingOptions):
async def settings_setSetting(cls, data: SetSettingOptions):
logger.info('[backend] Set {}: {}'.format(data['key'], data['value']))
return settings.setSetting(data['key'], data['value'])

@classmethod
async def get_env(cls, env: str):
return getattr(decky, env)
6 changes: 6 additions & 0 deletions src/utils/Backend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ import {

export type FilePickerFilter = RegExp | ((file: File) => boolean) | undefined;

const envGetEnv = callable<[string], string>("get_env");
const settingsGetSettings = callable<[{ key: string; defaults: unknown }], unknown>("settings_getSetting");
const settingsSetSettings = callable<[{ key: string; value: unknown }], unknown>("settings_setSetting");
const settingsCommit = callable<[], unknown>("settings_commit");

export class Backend {
static async getEnv(env: string) {
const output = await envGetEnv(env);
return output;
}

static async getSetting(key: string, defaults: unknown) {
const output = await settingsGetSettings({ key, defaults });
return output;
Expand Down
2 changes: 1 addition & 1 deletion src/views/Advanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Advanced: FC<{ appid: number }> = ({ appid }) => {

const handleBrowse = async () => {
const prefixDir = options.getFieldValue("STEAM_COMPAT_DATA_PATH");
const defaultDir = prefixDir ? prefixDir : "/home/deck";
const defaultDir = prefixDir ? prefixDir : await Backend.getEnv("DECKY_USER_HOME");
const filePickerRes = await Backend.openFilePicker(defaultDir, false);
const prefixPath = filePickerRes.path;
const newOptions = new Options(options.getOptionsString());
Expand Down
2 changes: 1 addition & 1 deletion src/views/Normal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Normal: FC<{ appid: number }> = ({ appid }) => {

const handleBrowse = async () => {
const cheatDir = options.getFieldValue("PRESSURE_VESSEL_FILESYSTEMS_RW");
const defaultDir = cheatDir ? cheatDir : "/home/deck";
const defaultDir = cheatDir ? cheatDir : await Backend.getEnv("DECKY_USER_HOME");
const filePickerRes = await Backend.openFilePicker(defaultDir, true, ["exe", "bat"]);
const cheatPath = filePickerRes.path;
const newOptions = new Options(options.getOptionsString());
Expand Down

0 comments on commit 9434ee3

Please sign in to comment.