mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 12:56:06 +00:00
Feature adding custom Linux applications (#130)
* Add your own apps to the Desktop page An Add tile on Desktop takes a .sh script, an AppImage, a GitHub repo (newest ARM64 AppImage release) or a Flatpak ID, with an optional name and icon. Script folders are linked into the session, or copied when they hold Linux programs (shared storage is noexec); folders outside internal storage are bound at their own path. Each app's page opens it under gamescope, edits its name and icon (with icons suggested from its GitHub repo), checks a GitHub app for a newer release and updates it in place, or removes it. Replaces the beta AppImages section. * Put Add at the end of the installable emulators Installed emulators and added apps keep the top section, shown once there is one. Add closes the installable grid, or the installed one when nothing is left to install. * Import DwarFS AppImages and their SVG icons uruntime images built with sharun keep one program under several names as hard links, which Android denies apps, so dwarfsextract aborted. The extraction runs with proot's link2symlink, and each linked name becomes a file of its own afterwards; their AppDir is followed through the squashfs-root link. An image's icon is a PNG of at least 128 px from the name its entry gives, else its SVG (drawn with AndroidSVG), else the largest PNG, else .DirIcon. * Give AppImages the session's pads sharun images start the app through their own ld.so, patched not to read /etc/ld.so.preload, and drop LD_PRELOAD unless allowed, so the app never loaded libfakeinput and saw no controller. The launcher now hands the preload list over in LD_PRELOAD with SHARUN_ALLOW_LD_PRELOAD set. Pad defaults also put Player 1 on the controller for yuzu-family emulators, once, while it is still on the keyboard. * Redesign the Add and Edit app dialogs Source and appearance sit in two panels side by side, with a live preview of the Desktop tile. A disabled primary button keeps an outline so it still reads as a button.
This commit is contained in:
1 parent
aa05ab03fa
commit
1c161a76dd
22 files changed
+1589
-265
No files matched your search
@@ -24,6 +24,12 @@ fi
|
||||
# X11, which it picks from the session type.
|
||||
export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1
|
||||
export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1
|
||||
# sharun images start the app through their own ld.so, patched not to read /etc/ld.so.preload, and
|
||||
# drop LD_PRELOAD unless allowed: without this the app never gets the session's pads.
|
||||
if [ -s /etc/ld.so.preload ]; then
|
||||
preload=$(tr -s '\n' ':' < /etc/ld.so.preload)
|
||||
export LD_PRELOAD="${preload%:}${LD_PRELOAD:+:$LD_PRELOAD}" SHARUN_ALLOW_LD_PRELOAD=1
|
||||
fi
|
||||
flags=()
|
||||
if [ -e "$APPDIR/chrome-sandbox" ] || compgen -G "$APPDIR/*/chrome-sandbox" >/dev/null; then
|
||||
flags+=(--no-sandbox)
|
||||
|
||||
@@ -1044,7 +1044,56 @@ def retroarch():
|
||||
print(f"bannerlator-pad-defaults: RetroArch: joypad driver udev -> sdl2 ({cfg})")
|
||||
|
||||
|
||||
for step in (rpcs3, duckstation, pcsx2, armsx2, dolphin, cemu, melonds, ppsspp, retroarch):
|
||||
# yuzu and its forks: Player 1 in [Controls] of <name>/qt-config.ini, which each writes at its first
|
||||
# start with the keyboard bound. Bindings are input_common ParamPackages, laid out by position as the
|
||||
# frontend's own auto-map does (sdl_driver.cpp GetDefaultButtonBinding); the guid is SDL's with the
|
||||
# name CRC cleared (GetGUID). A key is only read while its \default is false. Done once per emulator,
|
||||
# and only while Player 1 is still on the keyboard.
|
||||
SWITCH_PAD = "engine:sdl,port:0,guid:030000005e0400008e02000010010000,"
|
||||
SWITCH_PLAYER1 = {
|
||||
"button_a": "button:1", "button_b": "button:0", "button_x": "button:3", "button_y": "button:2",
|
||||
"button_lstick": "button:9", "button_rstick": "button:10", "button_l": "button:4", "button_r": "button:5",
|
||||
"button_zl": "axis:2,threshold:0.5,invert:+", "button_zr": "axis:5,threshold:0.5,invert:+",
|
||||
"button_plus": "button:7", "button_minus": "button:6", "button_home": "button:8",
|
||||
"button_dleft": "hat:0,direction:left", "button_dup": "hat:0,direction:up",
|
||||
"button_dright": "hat:0,direction:right", "button_ddown": "hat:0,direction:down",
|
||||
"lstick": "axis_x:0,axis_y:1,offset_x:0,offset_y:0,invert_x:+,invert_y:+",
|
||||
"rstick": "axis_x:3,axis_y:4,offset_x:0,offset_y:0,invert_x:+,invert_y:+",
|
||||
}
|
||||
|
||||
|
||||
def switch_emulators():
|
||||
for name in sorted(os.listdir(CONFIG)) if os.path.isdir(CONFIG) else ():
|
||||
cfg = os.path.join(CONFIG, name, "qt-config.ini")
|
||||
marker = os.path.join(CONFIG, name, ".droiddeck-pad")
|
||||
if os.path.exists(marker) or not os.path.isfile(cfg):
|
||||
continue
|
||||
with open(cfg, encoding="utf-8", errors="replace") as f:
|
||||
lines = f.read().splitlines()
|
||||
span = ini_section(lines, "Controls")
|
||||
if not span:
|
||||
continue
|
||||
current = {l.split("=", 1)[0]: l.split("=", 1)[1] for l in lines[span[0]:span[1]] if "=" in l}
|
||||
if "engine:keyboard" not in current.get("player_0_button_a", ""):
|
||||
continue
|
||||
wanted = {"player_0_connected": "true", "player_0_type": "0"}
|
||||
for key, binding in SWITCH_PLAYER1.items():
|
||||
wanted[f"player_0_{key}"] = f'"{SWITCH_PAD}{binding}"'
|
||||
body = [l for l in lines[span[0]:span[1]]
|
||||
if l.split("=", 1)[0].removesuffix("\\default") not in wanted]
|
||||
while body and not body[-1].strip():
|
||||
body.pop()
|
||||
for key, value in wanted.items():
|
||||
body += [f"{key}\\default=false", f"{key}={value}"]
|
||||
lines[span[0]:span[1]] = body + [""]
|
||||
with open(cfg + ".tmp", "w", encoding="utf-8") as f:
|
||||
f.write("\n".join(lines) + "\n")
|
||||
os.replace(cfg + ".tmp", cfg)
|
||||
open(marker, "w").close()
|
||||
print(f"bannerlator-pad-defaults: {name}: Player 1 on the controller ({cfg})")
|
||||
|
||||
|
||||
for step in (rpcs3, duckstation, pcsx2, armsx2, dolphin, cemu, melonds, ppsspp, retroarch, switch_emulators):
|
||||
try:
|
||||
step()
|
||||
except Exception as e:
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
# A script added on the Desktop page (UserApps), run from its own folder:
|
||||
# bannerlator-script-run /opt/droiddeck-apps/<id> [args...]
|
||||
set -u
|
||||
dir=${1:?usage: bannerlator-script-run <added app directory> [args...]}
|
||||
shift
|
||||
entry=$(cat "$dir/entry" 2>/dev/null) || { echo "bannerlator-script-run: $dir has no entry" >&2; exit 127; }
|
||||
cd -P "$dir/files" 2>/dev/null || { echo "bannerlator-script-run: $dir/files is missing; add the script again" >&2; exit 127; }
|
||||
folder=$PWD
|
||||
# Shared storage is noexec, so the script is handed to its interpreter rather than executed.
|
||||
first=
|
||||
IFS= read -r first < "$entry"
|
||||
first=${first%$'\r'}
|
||||
interp=(/bin/bash)
|
||||
case $first in '#!'*) read -r -a interp <<< "${first#'#!'}" ;; esac
|
||||
echo "== script $entry in $folder (${interp[*]})"
|
||||
case ${DBUS_SESSION_BUS_ADDRESS:-} in
|
||||
unix:*) "${interp[@]}" "./$entry" "$@" ;;
|
||||
*) unset DBUS_SESSION_BUS_ADDRESS
|
||||
if command -v dbus-run-session >/dev/null 2>&1; then
|
||||
dbus-run-session -- "${interp[@]}" "./$entry" "$@"
|
||||
else
|
||||
"${interp[@]}" "./$entry" "$@"
|
||||
fi ;;
|
||||
esac
|
||||
rc=$?
|
||||
# A launcher script often starts the game and returns; the session lasts while it runs.
|
||||
running() {
|
||||
local p exe
|
||||
for p in /proc/[0-9]*; do
|
||||
exe=$(readlink "$p/exe" 2>/dev/null) || continue
|
||||
case $exe in "$folder"/*) return 0 ;; esac
|
||||
done
|
||||
return 1
|
||||
}
|
||||
while running; do sleep 2; done
|
||||
exit $rc
|
||||
Reference in new issue
Block a user