Compare commits

..

7 commits

Author SHA1 Message Date
6f5dc01876
Changes for Anatase compatibility 2026-09-09 14:28:31 -05:00
sakanaa
f912f491e2
Add deprecation notice 2025-12-01 04:36:04 +01:00
Fisch03
13d5c3c75e bump version 2025-12-01 04:00:12 +01:00
Andrii Malytskyi
105cbaffb6
fix(#15): Fix get_flatpaks function; (#17) 2025-12-01 03:55:59 +01:00
Fisch03
bf767ad808 Bump Version 2024-02-09 17:10:54 +01:00
Fisch03
ba5cc801c5 Add decky user flatpaks to list 2024-02-09 17:00:32 +01:00
Lars
82b4160655
Custom file support, global DFL (#11)
* Minimally Functional Custom File Shortcut Creation (#9)

* Add method to get decky user home

* Add shortcut options modal

* Split newShortcut to insert custom file codepath

* Integrate file picker a bit better into the rest

* switch to global DFL, better compat tool support, fix shortcut parameters being overwritten

* Actually move DFL to devDependencies

---------

Co-authored-by: jurassicplayer <jurassicplayer75@gmail.com>
2024-02-09 16:58:22 +01:00
11 changed files with 1103 additions and 761 deletions

View file

@ -1,3 +1,6 @@
> [!TIP]
> This is a fork of [Quick Launch by Fisch03](https://github.com/Fisch03/SDH-QuickLaunch) that has been modified to work on [Anatase](https://anatase.org/). Since Anatase runs Steam in a Flatpak, launching other Flatpaks and apps doesn't normally work. The purpose of this fork is to replace calls to /usr/bin/flatpak to /app/bin/flatpak, which is a wrapper that allows launching other Flatpaks within Anatase's Steam package.
# SDH-QuickLaunch # SDH-QuickLaunch
[Decky Loader](https://github.com/SteamDeckHomebrew/PluginLoader) Plugin to quickly launch Apps from the Quick Access Menu without adding them as shortcuts, and add new shortcuts entirely [Decky Loader](https://github.com/SteamDeckHomebrew/PluginLoader) Plugin to quickly launch Apps from the Quick Access Menu without adding them as shortcuts, and add new shortcuts entirely

67
main.py
View file

@ -10,6 +10,8 @@ from subprocess import Popen, PIPE
from urllib.error import HTTPError from urllib.error import HTTPError
from urllib.request import urlopen, Request from urllib.request import urlopen, Request
FLATPAK_RUNNER = "flatpak" # or explicitly: /app/bin/flatpak
HOST_RUNNER = "hrun" # or explicitly: /app/bin/hrun
confdir = os.environ["DECKY_PLUGIN_SETTINGS_DIR"] confdir = os.environ["DECKY_PLUGIN_SETTINGS_DIR"]
@ -24,22 +26,58 @@ def split_string(string):
class Plugin: class Plugin:
async def get_flatpaks(self): async def get_flatpaks(self):
proc = Popen( def list_flatpaks(cmd):
'flatpak list --app --columns="name,application" | awk \'BEGIN {FS="\\t"} {print "{\\"name\\":\\""$1"\\",\\"exec\\":\\"/usr/bin/flatpak run "$2"\\"},"}\\\'', flatpaks = []
stdout=PIPE,
stderr=None, clean_env = os.environ.copy()
shell=True, clean_env["LD_LIBRARY_PATH"] = ""
) with Popen(cmd, stdout=PIPE, stderr=None, env=clean_env, text=True) as p:
packages = proc.communicate()[0] for line in p.stdout:
packages = packages.decode("utf-8") if '\t' not in line:
packages = packages[:-2] continue
return "[" + packages + "]"
name, app_id = line.strip().split('\t', 1)
name = name.strip()
app_id = app_id.strip()
if not name or not app_id:
continue
flatpaks.append({
"id": app_id,
"name": name,
"exec": f"{FLATPAK_RUNNER} run {app_id}"
})
return flatpaks
global_flatpaks = list_flatpaks([
'flatpak', 'list', '--app', '--columns=name,application'
])
local_flatpaks = list_flatpaks([
'runuser', '-l', decky_plugin.DECKY_USER, '-c',
'flatpak list --app --columns=name,application'
])
seen = set()
unique_flatpaks = []
for flatpak in global_flatpaks + local_flatpaks:
if flatpak["id"] not in seen:
seen.add(flatpak["id"])
unique_flatpaks.append(flatpak)
sorted_items = sorted(unique_flatpaks, key=lambda x: x.get("name", "").lower())
return jsonDumps(sorted_items)
async def get_desktops(self): async def get_desktops(self):
packages = [] packages = []
for desktopFile in chain( for desktopFile in chain(
Path("/usr/share/applications").glob("*.desktop"), Path("/usr/share/applications").glob("*.desktop"),
Path(f"{decky_plugin.DECKY_USER_HOME}/.local/share/applications/").glob("*.desktop"), Path(f"{decky_plugin.DECKY_USER_HOME}/.local/share/applications/").glob("*.desktop"),
Path("/var/usrlocal/share/applications").glob("*.desktop"),
): ):
if not desktopFile.is_file(): if not desktopFile.is_file():
continue continue
@ -53,13 +91,20 @@ class Plugin:
package["name"] = line[5:] package["name"] = line[5:]
elif line.startswith("Exec="): elif line.startswith("Exec="):
foundExec = True foundExec = True
package["exec"] = line[5:] execTarget = line[5:].split(" ", 1)
decky_plugin.logger.info("- Exec path: " + str(execTarget))
runner = FLATPAK_RUNNER if execTarget[0].endswith("flatpak") else HOST_RUNNER
package["exec"] = f"{runner} {execTarget[1]}"
if foundName and foundExec: if foundName and foundExec:
decky_plugin.logger.info("+ Desktop app: " + package["name"])
packages.append(package) packages.append(package)
break break
return jsonDumps(packages) return jsonDumps(packages)
async def get_DECKY_USER_HOME(self):
return decky_plugin.DECKY_USER_HOME
async def get_config(self): async def get_config(self):
with open(os.path.join(confdir, "config.json"), "r") as f: with open(os.path.join(confdir, "config.json"), "r") as f:
return json.load(f) return json.load(f)

View file

@ -1,7 +1,7 @@
{ {
"name": "sdh-quicklaunch", "name": "sdh-quicklaunch-anatase",
"version": "1.1.1", "version": "1.2.1",
"description": "Quickly Launch Apps from the Steam Deck Quick Access Menu without adding them as Shortcuts", "description": "Quickly launch apps from the Steam Deck Quick Access Menu without adding them as shortcuts",
"scripts": { "scripts": {
"build": "shx rm -rf dist && rollup -c", "build": "shx rm -rf dist && rollup -c",
"watch": "rollup -c -w", "watch": "rollup -c -w",
@ -9,7 +9,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/Fisch03/SDH-QuickLaunch.git" "url": "git+https://gitdab.com/dj/SDH-QuickLaunch-Anatase.git"
}, },
"keywords": [ "keywords": [
"decky", "decky",
@ -17,12 +17,12 @@
"steam-deck", "steam-deck",
"deck" "deck"
], ],
"author": "Fisch03", "author": "Fisch03 & djsime1",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"bugs": { "bugs": {
"url": "https://github.com/Fisch03/SDH-QuickLaunch/issues" "url": "https://gitdab.com/dj/SDH-QuickLaunch-Anatase/issues"
}, },
"homepage": "https://github.com/Fisch03/SDH-QuickLaunch#readme", "homepage": "https://gitdab.com/dj/SDH-QuickLaunch-Anatase",
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^21.1.0", "@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-json": "^4.1.0", "@rollup/plugin-json": "^4.1.0",
@ -31,6 +31,7 @@
"@rollup/plugin-typescript": "^8.3.3", "@rollup/plugin-typescript": "^8.3.3",
"@types/react": "16.14.0", "@types/react": "16.14.0",
"@types/webpack": "^5.28.0", "@types/webpack": "^5.28.0",
"decky-frontend-lib": "^3.24.5",
"rollup": "^2.77.1", "rollup": "^2.77.1",
"rollup-plugin-import-assets": "^1.1.1", "rollup-plugin-import-assets": "^1.1.1",
"shx": "^0.3.4", "shx": "^0.3.4",
@ -38,14 +39,14 @@
"typescript": "^4.7.4" "typescript": "^4.7.4"
}, },
"dependencies": { "dependencies": {
"decky-frontend-lib": "^3.21.8",
"react-icons": "^4.8.0" "react-icons": "^4.8.0"
}, },
"pnpm": { "pnpm": {
"peerDependencyRules": { "peerDependencyRules": {
"ignoreMissing": [ "ignoreMissing": [
"react", "react",
"react-dom" "react-dom",
"decky-frontend-lib"
] ]
} }
} }

View file

@ -1,11 +1,10 @@
{ {
"name": "Quick Launch", "name": "Quick Launch",
"author": "Fisch03", "author": "Fisch03 & djsime1",
"flags": ["root"], "flags": ["root"],
"publish": { "publish": {
"discord_id": "431374517462499328",
"description": "Quickly Launch Non-Steam-Apps from the Quick Access menu without adding them as Shortcuts, or add them to the Steam Library.", "description": "Quickly Launch Non-Steam-Apps from the Quick Access menu without adding them as Shortcuts, or add them to the Steam Library.",
"tags": [ "utility" ], "tags": [ "utility" ],
"image": "https://raw.githubusercontent.com/Fisch03/SDH-QuickLaunch/master/ui_full.png" "image": "https://gitdab.com/dj/SDH-QuickLaunch-Anatase/raw/branch/master/ui_full.png"
} }
} }

1546
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -24,12 +24,13 @@ export default defineConfig({
}) })
], ],
context: 'window', context: 'window',
external: ['react', 'react-dom'], external: ['react', 'react-dom', 'decky-frontend-lib'],
output: { output: {
file: 'dist/index.js', file: 'dist/index.js',
globals: { globals: {
react: 'SP_REACT', react: 'SP_REACT',
'react-dom': 'SP_REACTDOM', 'react-dom': 'SP_REACTDOM',
'decky-frontend-lib': 'DFL',
}, },
format: 'iife', format: 'iife',
exports: 'default', exports: 'default',

47
src/appoperations.tsx Normal file
View file

@ -0,0 +1,47 @@
import { ServerAPI } from "decky-frontend-lib";
import { App, getLaunchOptions, getTarget } from "./apptypes";
import { getImagesForGame } from "./steamgriddb";
import { gameIDFromAppID, getShortcutID, createShortcut } from "./utils";
import { Settings } from "./settings";
export async function launchApp(sAPI: ServerAPI, app: App) {
let id: number = await getShortcutID(sAPI);
SteamClient.Apps.SetShortcutName(id, `[QL] ${app.name}`)
SteamClient.Apps.SetShortcutLaunchOptions(id, getLaunchOptions(app))
SteamClient.Apps.SetShortcutExe(id, `"${getTarget(app)}"`)
SteamClient.Apps.SetShortcutStartDir(id, "/app/bin")
SteamClient.Apps.SpecifyCompatTool(id, app.compatTool === undefined ? "" : app.compatTool)
setTimeout(() => {
let gid = gameIDFromAppID(id);
SteamClient.Apps.RunGame(gid,"",-1,100);
}, 500)
}
export function createAppShortcut(sAPI: ServerAPI, app: App, settings: Settings, launchOptions?: string, target?: string) {
let shortcutLaunchOptions = launchOptions === undefined ? getLaunchOptions(app) : launchOptions
let shortcutTarget = target === undefined ? getTarget(app) : target
createShortcut(app.name, shortcutLaunchOptions, shortcutTarget).then((id:number) => {
if(settings.get("useGridDB")) {
getImagesForGame(sAPI, settings.get("gridDBKey") ,app.name)
.then(images => {
if(images.Grid !== null) SteamClient.Apps.SetCustomArtworkForApp(id, images.Grid, "png", 0);
if(images.Hero !== null) SteamClient.Apps.SetCustomArtworkForApp(id, images.Hero, "png", 1);
if(images.Logo !== null) SteamClient.Apps.SetCustomArtworkForApp(id, images.Logo, "png", 2);
//if(images.Grid !== null) SteamClient.Apps.SetCustomArtworkForApp(id, images.GridH, "png", 3);
})
.catch(() => {}); //Maybe display error to the user in the future?
}
//This should theoretically not be needed with the new SteamClient.Apps.AddShortcut params but they seem to be pretty broken rn. It's not like it hurts either.
setTimeout(() => {
SteamClient.Apps.SetShortcutName(id, app.name);
SteamClient.Apps.SetShortcutLaunchOptions(id, shortcutLaunchOptions);
SteamClient.Apps.SetShortcutExe(id, `"${shortcutTarget}"`);
SteamClient.Apps.SetShortcutStartDir(id, "/app/bin")
SteamClient.Apps.SpecifyCompatTool(id, app.compatTool === undefined ? "" : app.compatTool);
}, 500)
})
}

View file

@ -1,6 +1,7 @@
export interface App { export interface App {
name: string; name: string;
exec: string; exec: string;
compatTool?: string;
} }
export function getLaunchOptions(app: App) { export function getLaunchOptions(app: App) {

101
src/fileoptions.tsx Normal file
View file

@ -0,0 +1,101 @@
import {
ServerAPI,
ConfirmModal,
ToastData,
TextField,
FilePickerRes,
ToggleField
} from "decky-frontend-lib"
import { useEffect, useState } from "react"
import { App } from "./apptypes"
import { createAppShortcut, launchApp } from "./appoperations"
import { Settings } from "./settings"
export const FileOptionsModal = (props: {closeModal?: CallableFunction, settings: Settings, starApp: CallableFunction, filepath: FilePickerRes, serverAPI: ServerAPI}) => {
const closeModal = () => { if (props.closeModal) {props.closeModal()} }
const {settings, starApp, filepath, serverAPI} = props
const [appName, setAppName] = useState<string>(filepath.path)
const [compatTool, setCompatTool] = useState<string|undefined>()
const [addToFavorites, setAddToFavorites] = useState<boolean>(false)
const [addAsShortcut, setAddAsShortcut] = useState<boolean>(false)
useEffect(()=>{
let filenameWithExtension = filepath.realpath.split(/[\\\/]/).pop() // potentially has an extension
let filename = filenameWithExtension
let fileext = ''
if (filenameWithExtension) {
filename = filenameWithExtension.slice(0, filenameWithExtension.lastIndexOf('.'))
fileext = filenameWithExtension.slice(filenameWithExtension.lastIndexOf('.')+1, filenameWithExtension.length).toLowerCase()
}
let path = filepath.realpath.substring(0, filepath.realpath.length - (filenameWithExtension ? filenameWithExtension.length : 0))
localStorage.setItem('decky-addtosteam', path)
let appName = filename || filenameWithExtension || 'MissingAppName'
setAppName(appName)
if (['exe', 'bat'].includes(fileext)) setCompatTool('proton-experimental')
},[])
const onOK = () => {
let app: App = {
name: appName,
exec: filepath.realpath,
compatTool: compatTool
}
if (addAsShortcut) {
createAppShortcut(serverAPI, app, settings, "", app.exec)
let toastData: ToastData = {
title: 'Added Shortcut',
body: appName,
playSound: true,
showToast: true
}
serverAPI.toaster.toast(toastData)
} else if (addToFavorites) {
//TODO: Doing this looses information about the compat tool. An app should also be able to store data about compat tools.
starApp(app);
} else {
launchApp(serverAPI, app);
}
}
const nameField = <TextField
label='Name'
focusOnMount={true}
value={appName}
onChange={(e) => setAppName(e.currentTarget.value)}
/>
return (
<ConfirmModal
strTitle='File Options'
strOKButtonText={addAsShortcut ? 'Add Shortcut' : addToFavorites ? 'Add to starred Apps' : 'Launch'}
closeModal={closeModal}
onOK={onOK}
onCancel={closeModal}
onEscKeypress={closeModal}
>
<ToggleField
label='Add to favorites'
checked={addToFavorites}
onChange={addToFavorites => {
setAddToFavorites(addToFavorites);
if(addToFavorites) setAddAsShortcut(false);
}}
/>
<ToggleField
label='Add as shortcut'
checked={addAsShortcut}
onChange={addAsShortcut => {
setAddAsShortcut(addAsShortcut);
if(addAsShortcut) setAddToFavorites(false);
}}
/>
{ (addToFavorites || addAsShortcut) && nameField }
</ConfirmModal>
)
}

View file

@ -12,16 +12,23 @@ import {
SingleDropdownOption, SingleDropdownOption,
DropdownOption, DropdownOption,
DialogButton, DialogButton,
Focusable Focusable,
FileSelectionType
} from "decky-frontend-lib"; } from "decky-frontend-lib";
import { Fragment, useEffect } from "react"; import { Fragment, useEffect } from "react";
import { VFC, useState } from "react"; import { VFC, useState } from "react";
import { FaRocket, FaStar, FaRegStar } from "react-icons/fa"; import { FaRocket, FaStar, FaRegStar } from "react-icons/fa";
import { App, getLaunchOptions, getTarget } from "./apptypes"; import { App } from "./apptypes";
import { Settings } from "./settings"; import { Settings } from "./settings";
import { GridDBPanel, getImagesForGame } from "./steamgriddb"; import { GridDBPanel } from "./steamgriddb";
import { fetchApps, launchApp, createShortcut } from "./utils"; import { fetchApps } from "./utils";
import { FileOptionsModal } from "./fileoptions";
import { launchApp, createAppShortcut } from "./appoperations";
enum SpecialSelections {
FileShortcut = -1,
}
let appList: App[] = []; let appList: App[] = [];
@ -81,6 +88,7 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({ serverAPI }) => {
} }
}) })
.finally(() => { .finally(() => {
if(settings.get("enableAll")) newDropdownOptions.push({label: "Choose a file...", data: SpecialSelections.FileShortcut} as SingleDropdownOption);
setDropdownOptions(newDropdownOptions); setDropdownOptions(newDropdownOptions);
resolve(); resolve();
}) })
@ -97,29 +105,46 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({ serverAPI }) => {
} }
function newShortcut() { async function createFileShortcut() {
if(selectedApp === null) return; let lastUsedPath = localStorage.getItem('decky-addtosteam')
let deckyUserHome = (await serverAPI.callPluginMethod('get_DECKY_USER_HOME', {})).result
let path: string
if (lastUsedPath != null) {
path = lastUsedPath
} else if (typeof deckyUserHome === 'string') {
path = deckyUserHome
} else {
return
}
let filepath = await serverAPI.openFilePickerV2(
FileSelectionType.FILE,
path,
true,
undefined,
undefined,
undefined,
false,
true
)
if (!filepath) { return }
let app = appList[selectedApp]; const starApp = async (app: App) => {
createShortcut(app.name, getLaunchOptions(app), getTarget(app)).then((id:number) => { let starredApps = settings.get("starredApps");
if(settings.get("useGridDB")) { if(!starredApps.find((a: App) => a.name === app.name && a.exec === app.exec))
getImagesForGame(serverAPI, settings.get("gridDBKey"),app.name) starredApps.push(app);
.then(images => { settings.set("starredApps", starredApps);
if(images.Grid !== null) SteamClient.Apps.SetCustomArtworkForApp(id, images.Grid, "png", 0);
if(images.Hero !== null) SteamClient.Apps.SetCustomArtworkForApp(id, images.Hero, "png", 1); await buildAppList();
if(images.Logo !== null) SteamClient.Apps.SetCustomArtworkForApp(id, images.Logo, "png", 2); setSelectedApp(appList.findIndex((a: App) => a.name === app.name && a.exec === app.exec));
//if(images.Grid !== null) SteamClient.Apps.SetCustomArtworkForApp(id, images.GridH, "png", 3);
})
.catch(() => {}); //Maybe display error to the user in the future?
} }
//This should teoretically not be needed with the new SteamClient.Apps.AddShortcut params but they seem to be pretty broken rn. It's not like it hurts either. showModal(<FileOptionsModal filepath={filepath} starApp={starApp} settings={settings} serverAPI={serverAPI}/>)
setTimeout(() => { }
SteamClient.Apps.SetShortcutName(id, app.name);
SteamClient.Apps.SetShortcutLaunchOptions(id, getLaunchOptions(app)); function newShortcut() {
SteamClient.Apps.SetShortcutExe(id, `"${getTarget(app)}"`); if(selectedApp != null){
}, 500) createAppShortcut(serverAPI, appList[selectedApp], settings)
}) }
} }
return ( return (
@ -134,7 +159,11 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({ serverAPI }) => {
selectedOption={selectedApp} selectedOption={selectedApp}
onChange={(e: SingleDropdownOption) => { onChange={(e: SingleDropdownOption) => {
setIsStarred(e.data < settings.get("starredApps").length); setIsStarred(e.data < settings.get("starredApps").length);
setSelectedApp(e.data); if(e.data === SpecialSelections.FileShortcut) {
createFileShortcut();
setSelectedApp(null);
}
else setSelectedApp(e.data);
}} }}
/> />
</div> </div>

View file

@ -1,6 +1,6 @@
import { ServerAPI } from "decky-frontend-lib"; import { ServerAPI } from "decky-frontend-lib";
import { App, getLaunchOptions, getTarget } from "./apptypes"; import { App } from "./apptypes";
export const createShortcut = (name: string, launchOptions: string = "", target:string = "") => { export const createShortcut = (name: string, launchOptions: string = "", target:string = "") => {
return SteamClient.Apps.AddShortcut(name,"/usr/bin/ifyouseethisyoufoundabug", target, launchOptions); //The Part after the last Slash does not matter because it should always be replaced when launching an app return SteamClient.Apps.AddShortcut(name,"/usr/bin/ifyouseethisyoufoundabug", target, launchOptions); //The Part after the last Slash does not matter because it should always be replaced when launching an app
@ -35,19 +35,6 @@ export async function fetchApps(sAPI: ServerAPI, type: string): Promise<App[]> {
return apps return apps
} }
export const launchApp = async (sAPI: ServerAPI, app: App) => {
let id: number = await getShortcutID(sAPI);
SteamClient.Apps.SetShortcutName(id, `[QL] ${app.name}`)
SteamClient.Apps.SetShortcutLaunchOptions(id, getLaunchOptions(app))
SteamClient.Apps.SetShortcutExe(id, `"${getTarget(app)}"`)
setTimeout(() => {
let gid = gameIDFromAppID(id);
SteamClient.Apps.RunGame(gid,"",-1,100);
}, 500)
}
export const getShortcutID = async (sAPI: ServerAPI) => { export const getShortcutID = async (sAPI: ServerAPI) => {
const result = await sAPI.callPluginMethod<any, number>("get_id", {}) const result = await sAPI.callPluginMethod<any, number>("get_id", {})