mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-12-21 23:31:52 +01:00
Python Changes for Websites and Shortcuts
~fixed duplicates from being made when script is ran multiple times ~fixed websites to allow multiple "base url" creations
This commit is contained in:
parent
df1dc5a4ce
commit
b2e126ac1e
@ -2731,6 +2731,9 @@ if [ ${#custom_websites[@]} -gt 0 ]; then
|
|||||||
# Convert the custom_websites array to a string
|
# Convert the custom_websites array to a string
|
||||||
custom_websites_str=$(IFS=", "; echo "${custom_websites[*]}")
|
custom_websites_str=$(IFS=", "; echo "${custom_websites[*]}")
|
||||||
|
|
||||||
|
# Initialize an associative array to keep track of the number of entries for each base URL
|
||||||
|
declare -A base_url_counts
|
||||||
|
|
||||||
# Iterate over each custom website
|
# Iterate over each custom website
|
||||||
for custom_website in "${custom_websites[@]}"; do
|
for custom_website in "${custom_websites[@]}"; do
|
||||||
# Remove any leading or trailing spaces from the custom website URL
|
# Remove any leading or trailing spaces from the custom website URL
|
||||||
@ -2750,6 +2753,16 @@ if [ ${#custom_websites[@]} -gt 0 ]; then
|
|||||||
# Capitalize the first letter of the website name
|
# Capitalize the first letter of the website name
|
||||||
website_name="$(tr '[:lower:]' '[:upper:]' <<< "${website_name:0:1}")${website_name:1}"
|
website_name="$(tr '[:lower:]' '[:upper:]' <<< "${website_name:0:1}")${website_name:1}"
|
||||||
|
|
||||||
|
# Check if an entry has already been created for this base URL
|
||||||
|
if [[ ${base_url_counts[$website_name]} ]]; then
|
||||||
|
# An entry has already been created for this base URL, so increment the count and append it to the website name
|
||||||
|
((base_url_counts[$website_name]++))
|
||||||
|
website_name="${website_name} ${base_url_counts[$website_name]}"
|
||||||
|
else
|
||||||
|
# This is the first entry for this base URL, so initialize the count to 1
|
||||||
|
base_url_counts[$website_name]=1
|
||||||
|
fi
|
||||||
|
|
||||||
# Set the chromelaunchoptions variable for this website
|
# Set the chromelaunchoptions variable for this website
|
||||||
chromelaunchoptions="run --branch=stable --arch=x86_64 --command=/app/bin/chrome --file-forwarding com.google.Chrome @@u @@ --window-size=1280,800 --force-device-scale-factor=1.00 --device-scale-factor=1.00 --kiosk https://$clean_website/ --chrome-kiosk-type=fullscreen --no-first-run --enable-features=OverlayScrollbar"
|
chromelaunchoptions="run --branch=stable --arch=x86_64 --command=/app/bin/chrome --file-forwarding com.google.Chrome @@u @@ --window-size=1280,800 --force-device-scale-factor=1.00 --device-scale-factor=1.00 --kiosk https://$clean_website/ --chrome-kiosk-type=fullscreen --no-first-run --enable-features=OverlayScrollbar"
|
||||||
done
|
done
|
||||||
@ -3021,62 +3034,75 @@ def get_steam_shortcut_id(exe, appname):
|
|||||||
|
|
||||||
|
|
||||||
def create_new_entry(shortcutdirectory, appname, launchoptions, startingdir):
|
def create_new_entry(shortcutdirectory, appname, launchoptions, startingdir):
|
||||||
if shortcutdirectory != '' and launchoptions != '':
|
# Load the contents of the shortcuts.vdf file into a dictionary
|
||||||
exe = f'"{shortcutdirectory}"'
|
with open('$shortcuts_vdf_path', 'rb') as f:
|
||||||
if shortcutdirectory != chromedirectory:
|
existing_shortcuts = vdf.binary_load(f)
|
||||||
appid = get_steam_shortcut_id(exe, appname)
|
|
||||||
app_ids.append(appid)
|
|
||||||
else:
|
|
||||||
appid = None
|
|
||||||
|
|
||||||
# Create a new entry for the Steam shortcut
|
# Check if an entry with the same appname and exe values already exists
|
||||||
new_entry = {
|
entry_exists = False
|
||||||
'appid': f'{str(appid)}' if appid is not None else '',
|
for entry in existing_shortcuts['shortcuts']:
|
||||||
'appname': appname,
|
if entry['appname'] == appname and entry['exe'] == shortcutdirectory:
|
||||||
'exe': shortcutdirectory,
|
entry_exists = True
|
||||||
'StartDir': startingdir,
|
break
|
||||||
'icon': '',
|
|
||||||
'ShortcutPath': '',
|
# Only create a new entry if an existing entry was not found
|
||||||
'LaunchOptions': launchoptions,
|
if not entry_exists:
|
||||||
'IsHidden': 0,
|
if shortcutdirectory != '' and launchoptions != '':
|
||||||
'AllowDesktopConfig': 1,
|
exe = f'"{shortcutdirectory}"'
|
||||||
'AllowOverlay': 1,
|
if shortcutdirectory != chromedirectory:
|
||||||
'OpenVR': 0,
|
appid = get_steam_shortcut_id(exe, appname)
|
||||||
'Devkit': 0,
|
app_ids.append(appid)
|
||||||
'DevkitGameID': '',
|
else:
|
||||||
'LastPlayTime': 0,
|
appid = None
|
||||||
'tags': {
|
|
||||||
'0': 'favorite'
|
# Create a new entry for the Steam shortcut
|
||||||
|
new_entry = {
|
||||||
|
'appid': f'{str(appid)}' if appid is not None else '',
|
||||||
|
'appname': appname,
|
||||||
|
'exe': shortcutdirectory,
|
||||||
|
'StartDir': startingdir,
|
||||||
|
'icon': '',
|
||||||
|
'ShortcutPath': '',
|
||||||
|
'LaunchOptions': launchoptions,
|
||||||
|
'IsHidden': 0,
|
||||||
|
'AllowDesktopConfig': 1,
|
||||||
|
'AllowOverlay': 1,
|
||||||
|
'OpenVR': 0,
|
||||||
|
'Devkit': 0,
|
||||||
|
'DevkitGameID': '',
|
||||||
|
'LastPlayTime': 0,
|
||||||
|
'tags': {
|
||||||
|
'0': 'favorite'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# Add the new entry to the shortcuts dictionary
|
# Add the new entry to the shortcuts dictionary
|
||||||
entry_exists = False
|
entry_exists = False
|
||||||
if type(shortcuts['shortcuts']) == list:
|
if type(shortcuts['shortcuts']) == list:
|
||||||
for entry in shortcuts['shortcuts']:
|
for entry in shortcuts['shortcuts']:
|
||||||
entry.setdefault('appname', '')
|
entry.setdefault('appname', '')
|
||||||
entry.setdefault('exe', '')
|
entry.setdefault('exe', '')
|
||||||
if entry['appname'] == new_entry['appname'] and entry['exe'] == new_entry['exe']:
|
if entry['appname'] == new_entry['appname'] and entry['exe'] == new_entry['exe']:
|
||||||
entry_exists = True
|
entry_exists = True
|
||||||
break
|
break
|
||||||
if not entry_exists:
|
if not entry_exists:
|
||||||
shortcuts['shortcuts'].append(new_entry)
|
shortcuts['shortcuts'].append(new_entry)
|
||||||
elif type(shortcuts['shortcuts']) == dict:
|
elif type(shortcuts['shortcuts']) == dict:
|
||||||
for key in shortcuts['shortcuts'].keys():
|
for key in shortcuts['shortcuts'].keys():
|
||||||
shortcuts['shortcuts'][key].setdefault('appname', '')
|
shortcuts['shortcuts'][key].setdefault('appname', '')
|
||||||
shortcuts['shortcuts'][key].setdefault('exe', '')
|
shortcuts['shortcuts'][key].setdefault('exe', '')
|
||||||
if shortcuts['shortcuts'][key]['appname'] == new_entry['appname'] and shortcuts['shortcuts'][key]['exe'] == new_entry['exe']:
|
if shortcuts['shortcuts'][key]['appname'] == new_entry['appname'] and shortcuts['shortcuts'][key]['exe'] == new_entry['exe']:
|
||||||
entry_exists = True
|
entry_exists = True
|
||||||
break
|
break
|
||||||
if not entry_exists:
|
if not entry_exists:
|
||||||
# Check if the shortcuts['shortcuts'] dictionary is empty
|
# Check if the shortcuts['shortcuts'] dictionary is empty
|
||||||
if not shortcuts['shortcuts']:
|
if not shortcuts['shortcuts']:
|
||||||
max_key = -1
|
max_key = -1
|
||||||
else:
|
else:
|
||||||
# Find the highest key value
|
# Find the highest key value
|
||||||
max_key = max(int(key) for key in shortcuts['shortcuts'].keys())
|
max_key = max(int(key) for key in shortcuts['shortcuts'].keys())
|
||||||
# Add the new entry with a key value one higher than the current maximum
|
# Add the new entry with a key value one higher than the current maximum
|
||||||
shortcuts['shortcuts'][str(max_key + 1)] = new_entry
|
shortcuts['shortcuts'][str(max_key + 1)] = new_entry
|
||||||
|
|
||||||
create_new_entry('$epicshortcutdirectory', 'Epic Games', '$epiclaunchoptions', '$epicstartingdir')
|
create_new_entry('$epicshortcutdirectory', 'Epic Games', '$epiclaunchoptions', '$epicstartingdir')
|
||||||
create_new_entry('$gogshortcutdirectory', 'Gog Galaxy', '$goglaunchoptions', '$gogstartingdir')
|
create_new_entry('$gogshortcutdirectory', 'Gog Galaxy', '$goglaunchoptions', '$gogstartingdir')
|
||||||
|
Loading…
Reference in New Issue
Block a user