@@ -79,10 +79,14 @@ extract_exe_icon() {
7979}
8080
8181# Create a .desktop shortcut and a wrapper launcher script for an app.
82- # Usage: create_shortcut "app-key" [display_name]
82+ # Usage: create_shortcut [--profile NAME] <app-key> [display_name]
83+ # When --profile is given, the shortcut is suffixed (key-profile.desktop) so
84+ # multiple profile-specific shortcuts can coexist for one app.
8385create_shortcut () {
84- local app_key=" $1 "
85- local display_name=" ${2:- } "
86+ _parse_profile_flag " $@ "
87+ local app_key=" ${WG_PARSED_ARGS[0]:- } "
88+ local display_name=" ${WG_PARSED_ARGS[1]:- } "
89+ local profile_name=" ${WG_PARSED_PROFILE} "
8690
8791 parse_app_config " $app_key " || return 1
8892
@@ -94,6 +98,7 @@ create_shortcut() {
9498 fi
9599
96100 display_name=" ${display_name:- $APP_NAME } "
101+ [ -n " $profile_name " ] && display_name=" $display_name ($profile_name )"
97102
98103 # Attempt to extract the app icon from the installed exe for a better desktop shortcut.
99104 local app_icon=" application-x-ms-dos-executable"
@@ -106,16 +111,23 @@ create_shortcut() {
106111 print_warning " Icon extraction failed — using default icon. Re-run after: sudo apt install icoutils"
107112 fi
108113
109- local launcher=" $BIN_DIR /$app_key "
110- local desktop=" $APPS_DIR /${app_key} .desktop"
114+ local file_suffix=" "
115+ [ -n " $profile_name " ] && file_suffix=" -${profile_name} "
116+ local launcher=" $BIN_DIR /${app_key}${file_suffix} "
117+ local desktop=" $APPS_DIR /${app_key}${file_suffix} .desktop"
111118 local setup_script_path
112119 setup_script_path=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd) /setup"
113120
121+ # PROFILE_OVERRIDE is baked into the wrapper so the .desktop loads the named profile.
122+ local profile_export=" "
123+ [ -n " $profile_name " ] && profile_export=" WG_PROFILE_OVERRIDE=\" $profile_name \" "
124+
114125 # Generate a standalone wrapper script that sources this project's libs.
115126 cat > " $launcher " << 'LAUNCHER_EOF '
116127#!/bin/bash
117128# Auto-generated launcher for Wine Proton app — do not edit manually.
118129APP_KEY="%APP_KEY%"
130+ WG_PROFILE_OVERRIDE="%PROFILE_OVERRIDE%"
119131WINE_DIR="%WINE_DIR%"
120132WINEPREFIX="%WINEPREFIX%"
121133PROTON_DIR="%PROTON_DIR%"
@@ -131,7 +143,7 @@ export WINEDLLOVERRIDES="winemenubuilder.exe=d"
131143export VKD3D_SHADER_VERBOSE=0
132144
133145# Source lib modules to get parse_app_config / find_app_exe / load_profile
134- for _lib in config utils registry profile; do
146+ for _lib in config utils registry profile user_registry ; do
135147 # shellcheck source=/dev/null
136148 source "$SCRIPT_DIR/lib/${_lib}.sh"
137149done
@@ -140,7 +152,12 @@ unset _lib
140152parse_app_config "$APP_KEY" || exit 1
141153
142154# Apply default + per-app profile (FPS cap, HUD, FSR, NVAPI, gamemode, …)
143- load_profile "$APP_KEY"
155+ # If WG_PROFILE_OVERRIDE was baked in by --profile, that named profile wins.
156+ if [ -n "$WG_PROFILE_OVERRIDE" ]; then
157+ load_profile "$WG_PROFILE_OVERRIDE"
158+ else
159+ load_profile "$APP_KEY"
160+ fi
144161
145162EXE_PATH=$(find_app_exe "$APP_KEY")
146163if [ -z "$EXE_PATH" ]; then
@@ -153,7 +170,7 @@ EXE_BIN=$(basename "$EXE_PATH")
153170
154171cd "$EXE_DIR" || { echo "Error: Cannot cd to $EXE_DIR" >&2; exit 1; }
155172
156- LOG_FILE="$WINE_DIR/${APP_KEY}.log"
173+ LOG_FILE="$WINE_DIR/${APP_KEY}${WG_PROFILE_OVERRIDE:+-$WG_PROFILE_OVERRIDE} .log"
157174if [ -x "$PROTON_DIR/proton" ]; then
158175 eval "${WG_LAUNCH_PREFIX}\"\$PROTON_DIR/proton\" run \"\$EXE_BIN\"" >"$LOG_FILE" 2>&1 &
159176else
162179LAUNCHER_EOF
163180
164181 sed -i " s|%APP_KEY%|$app_key |g" " $launcher "
182+ sed -i " s|%PROFILE_OVERRIDE%|$profile_name |g" " $launcher "
165183 sed -i " s|%WINE_DIR%|$WINE_DIR |g" " $launcher "
166184 sed -i " s|%WINEPREFIX%|$WINEPREFIX |g" " $launcher "
167185 sed -i " s|%PROTON_DIR%|$PROTON_DIR |g" " $launcher "
0 commit comments