Added ge-tool script

This commit is contained in:
crt0mega 2021-07-28 11:24:43 +02:00
parent c4f74c8714
commit 617a218e13
Signed by: crt0mega
GPG Key ID: DCAA09100B14F420
3 changed files with 181 additions and 0 deletions

166
proton/ge-tool Executable file
View File

@ -0,0 +1,166 @@
#!/bin/bash
# ge-tool
#
# Copyright 2021 crt0mega <crt0mega@c-r-t.tk>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
# Configuration
declare CONFIG_DIR="$HOME/.config/ge-tool"
declare CONFIG_FILE="$CONFIG_DIR/config"
declare LATEST_FILE="$CONFIG_DIR/latest"
declare API_CACHE=$(mktemp)
if [ ! -d "$CONFIG_DIR" ]; then
# Create config dir if it doesn't exist
mkdir -p $CONFIG_DIR
fi
if [ ! -f "$CONFIG_FILE" ]; then
# Default values
declare COMPAT_DIR="$HOME/.steam/root/compatibilitytools.d"
declare REL_URL="https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases"
declare GITHUB_TOKEN=""
else
# Read config instead
source $CONFIG_FILE > /dev/null
fi
if [ ! $GITHUB_TOKEN=="" ]; then
# Have token, give token
declare CURL_ARGS="-H 'Authorization: token $GITHUB_TOKEN'"
else
# Have no token, give no token
declare CURL_ARGS=""
fi
# Checking requirements
declare JQ=$(which jq)
declare CURL=$(which curl)
declare ZEN=$(which zenity)
declare NTFY=$(which notify-send)
declare ERR="0"
if [ "$JQ" == "" ]; then
echo "Error: jq not installed."
ERR="1"
fi
if [ "$CURL" == "" ]; then
echo "Error: curl not installed."
ERR="2"
fi
if [ "$ZEN" == "" ]; then
echo "Error: zenity not installed."
ERR="3"
fi
if [ "$NTFY" == "" ]; then
echo "Error: libnotify-bin not installed."
ERR="4"
fi
if [ ! "$ERR" == "0" ]; then exit; fi
# Caching latest release
$CURL $CURL_ARGS -sL $REL_URL/latest > $API_CACHE
# Getting tag-name of latest git release
declare LATEST_REMOTE_REL=$($JQ -r '.tag_name' < $API_CACHE)
# Getting tag-name of latest local copy
if [ -f "$LATEST_FILE" ]; then
declare LATEST_LOCAL_REL=$(<$LATEST_FILE)
else
declare LATEST_LOCAL_REL="null"
fi
# Compare with latest local release
if [ "$LATEST_LOCAL_REL" == "$LATEST_REMOTE_REL" ]; then
$ZEN --info --no-wrap \
--text="Your local copy of proton-ge-custom is up to date!\nLatest git release: $LATEST_REMOTE_REL"
exit
else
if ! $ZEN --question --no-wrap \
--text="A newer release of proton-ge-custom is available!\nLatest local release: $LATEST_LOCAL_REL\n\
Latest git release: $LATEST_REMOTE_REL\n\
Do you want to download it?"; then
exit
fi
fi
# Get download URLs if local release is outdated
# Download now, verify later :D
# declare DOWNLOAD_SHA512_URL=$($JQ -r '.assets[0].browser_download_url' < $API_CACHE)
declare DOWNLOAD_TARBALL_URL=$($JQ -r '.assets[1].browser_download_url' < $API_CACHE)
declare DOWNLOAD_TARBALL_FILE=$($JQ -r '.assets[1].name' < $API_CACHE)
declare DOWNLOAD_DIR=$(mktemp -d)
$NTFY "Downloading $DOWNLOAD_TARBALL_FILE"
$CURL $DOWNLOAD_TARBALL_URL -o $DOWNLOAD_DIR/$DOWNLOAD_TARBALL_FILE -sL
$NTFY "Download completed, extracting ..."
# Extracting downloaded Proton release
if [ ! -d $COMPAT_DIR ]; then mkdir -p $COMPAT_DIR; fi
tar xf $DOWNLOAD_DIR/$DOWNLOAD_TARBALL_FILE -C $COMPAT_DIR
# Setting info for latest release
echo "$LATEST_REMOTE_REL" > $LATEST_FILE
# Cleaning up
rm -r $DOWNLOAD_DIR
rm $API_CACHE
$NTFY "Installation complete."

13
proton/readme.md Normal file
View File

@ -0,0 +1,13 @@
# Usage of tools in proton/
## ge-tool
Running `ge-tool` will download the most recent release of proton-ge-custom from github and extract it automatically in compatibilitytools.d. It also keeps track of the latest downloaded release.
For configuring, you may change the default values in the script itself or add a custom `~/.config/ge-tool/config` file with the following content:
```
declare COMPAT_DIR="$HOME/.steam/root/compatibilitytools.d"
declare REL_URL="https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases"
declare GITHUB_TOKEN="<your github token>"
```
You can create your own GitHub token [here](https://github.com/settings/tokens/new).

View File

@ -12,4 +12,6 @@ Trigger warning: Most of them need "zenity" to be installed.
- Simple Zenity GUI for changing Wattman settings on Kernel 4.17+
- playonlinux/pol-steamhelp
- Provides a simple GUI to install Steam games via AppID in PlayOnLinux "Virtual Drives".
- proton/ge-tool
- An automatic, configurable downloader/updater for GloriousEgroll's custom Proton builds a. k. a. proton-ge-custom