Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

im trying to write a script on arch linux in bash, i want to add a shortcut to my steam…

  1. User

    im trying to write a script on arch linux in bash, i want to add a shortcut to my steam library, however is there a library i need to install in order to read and write to .vdf files?

  2. Assistant

    Yes, you will need to install the steamcmd package in order to read and write to .vdf files. This package provides a command line tool steamcmd which allows you to manage your Steam library including adding shortcuts, updating games, and more.

    You can install steamcmd using the following command in the terminal:

    sudo pacman -S steamcmd
    

    Once installed, you can access steamcmd using the command steamcmd followed by various flags and parameters depending on the specific action you would like to perform. For example, to add a shortcut to your library, you can use the -addshortcut flag followed by the ID of the game you would like to add as a shortcut.

    Here's an example command to add a shortcut for the game with ID 12345:

    steamcmd +login your_steam_username your_steam_password +force_install_dir your_steam_library_directory +app_update 12345 validate +quit
    

    Note that you will need to replace your_steam_username, your_steam_password, and your_steam_library_directory with your actual Steam account information and library directory path respectively.

  3. User

    no.. is there a different way maybe a way that heroic does it?

  4. Assistant

    Ah, I see what you're asking now. Heroic is a third-party open-source client for managing and running games installed through the Epic Games Store, not Steam.

    To my knowledge, there isn't a similar tool or library for working with Steam library shortcuts specifically in the way Heroic handles Epic Games Store games. However, you can achieve similar functionality using the steam command-line tool built into the Steam client.

    Here's an example of how you can use the steam tool to create a desktop shortcut for a specific game in your Steam library:

    steam steam://rungameid/GAME_ID_HERE
    

    You will need to replace GAME_ID_HERE with the actual Steam App ID for the game in question. You can find this by searching for the game on the Steam store website and looking at the App ID in the URL (e.g. https://store.steampowered.com/app/GAME_ID_HERE/GAME_NAME_HERE/).

    Once you've run the above command, you should see the game launch and a desktop shortcut created for it in your operating system's GUI. You can then move this shortcut wherever you want or modify its properties to change the icon, name, and other details.

  5. User

    no... is there a different way that autoamtes this process and has no human interaction and doesnt create .desktop files? im just trying to edit the shortcuts.vdf file in the best way possible and in a seamless way.

  6. Assistant

    I understand now, thank you for clarifying.

    You can use the steamcmd tool to manipulate your Steam library without user interaction. Specifically, you can use the app_set_config command to modify the shortcuts.vdf file.

    Here's an example command to add a shortcut for the game with ID 12345 to the shortcuts.vdf file:

    steamcmd +login your_steam_username your_steam_password +force_install_dir your_steam_library_directory +app_set_config 12345 "shortcuts" "1" +quit
    

    Similarly, you can remove a shortcut with the following command:

    steamcmd +login your_steam_username your_steam_password +force_install_dir your_steam_library_directory +app_set_config 12345 "shortcuts" "0" +quit
    

    You will need to replace your_steam_username, your_steam_password, and your_steam_library_directory with your actual information as before.

    Note that these commands will modify the shortcuts.vdf file directly without any GUI interaction or creating desktop files. However, I should caution that modifying the Steam configuration files directly can have unintended consequences and it's possible to corrupt your library if you're not careful. Be sure to make backups of your Steam installation and configuration files before attempting this.

  7. User

    is there a way to do it without needing the username pasword?

  8. Assistant

    No, unfortunately it's not possible to use steamcmd to modify your Steam library without providing your Steam account login information. The +login parameter is required for steamcmd to authenticate with the Steam server and be allowed to modify your library.

    If you're concerned about security, you may consider setting up a dedicated Steam account specifically for running automated scripts like this. You can restrict this account's access to your personal library and use a unique password to further protect your main account. However, you will still need to provide the login information for this secondary account when using steamcmd.

  9. User

    ok well is there a different way besides steamcmd?

  10. Assistant

    There is an open-source tool called steam-shortcuts that allows you to easily create, manage, and launch Steam library shortcuts directly from the command line. It does not require Steam account login information nor does it modify the shortcuts.vdf file directly.

    To use steam-shortcuts, you'll need to have node.js installed on your system. Once installed, you can install steam-shortcuts globally using the following command:

    npm install -g steam-shortcuts
    

    With steam-shortcuts installed, you can create a shortcut for a specific app ID with the following command:

    steam-shortcuts add APP_ID "Shortcut Name"
    

    This will create a new shortcut with the specified name in the default shortcut directory (~/.local/share/applications/steam/shortcuts on Linux). You can also specify a custom directory using the -d flag.

    To remove a shortcut, you can use the following command:

    steam-shortcuts remove APP_ID
    

    Again, you will need to replace APP_ID with the actual Steam App ID for the game in question.

    steam-shortcuts also supports a number of other features like listing all installed shortcuts, displaying detailed information for a specific shortcut, and more. You can view the full documentation on the GitHub repository.

  11. User

    could you write a bash script for arch linux that automates this process for the current users library sign in to steam?

  12. Assistant

    Certainly! Here's an example bash script that automates the process of adding a shortcut for a specific Steam game using steam-shortcuts.

    #!/bin/bash
    
    # Check if node.js is installed, if not install it
    if ! type "node" > /dev/null; then
        echo "node.js not found, installing..."
        sudo pacman -S nodejs npm
    fi
    
    # Install steam-shortcuts if not already installed
    if ! type "steam-shortcuts" > /dev/null; then
        echo "steam-shortcuts not found, installing..."
        sudo npm install -g steam-shortcuts
    fi
    
    # Get the current user's steam library directory
    STEAM_LIB_DIR="$(find $HOME/.steam/ -name steamapps -type d)"
    
    # Prompt for the game ID and shortcut name
    read -p "Enter the Steam App ID for the game you want to add: " APP_ID
    read -p "Enter the name for the shortcut: " SHORTCUT_NAME
    
    # Create the shortcut with steam-shortcuts
    steam-shortcuts add "$APP_ID" "$SHORTCUT_NAME" -d "$STEAM_LIB_DIR/steam"
    
    echo "Shortcut created!"
    

    Save the above code to a file (e.g. add-steam-shortcut.sh), make it executable with chmod +x add-steam-shortcut.sh, and then run it with ./add-steam-shortcut.sh to launch the script.

    The script will first check if node.js is installed, and if not, it will install it using pacman. It will then install steam-shortcuts if it's not already installed using npm.

    Next, it will use the find command to locate the Steam library directory for the current user and store it in the $STEAM_LIB_DIR variable.

    The script will then prompt you to enter the Steam App ID for the game you want to add and the name for the shortcut. It will then create the shortcut using steam-shortcuts with the specified name and location.

    Hope this helps! Let me know if you have any other questions.