Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gum #453

Merged
merged 6 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions programs/x86_64-apps
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@
◆ guglielmo : A FM, DAB/DAB+ decoder using Qt and C++.
◆ guiscrcpy : GUI integration for android screen mirroring system.
◆ guitar : Graphical git client.
◆ gum : A tool for glamorous shell scripts.
◆ gvim : Edit text files.
◆ gxc-smart-contract-ide : Gxchain smart contract IDE alpha.
◆ gyroflow-appimage : Video stabilization using gyroscope data.
Expand Down
57 changes: 57 additions & 0 deletions programs/x86_64/gum
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh

APP=gum
REPO="charmbracelet/gum"

# CREATE DIRECTORIES
if [ -z "$APP" ]; then exit 1; fi
mkdir -p "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1

# ADD THE REMOVER
echo "#!/bin/sh
rm -f /usr/share/applications/AM-$APP.desktop /usr/local/bin/$APP
rm -R -f /opt/$APP" >> "/opt/$APP/remove"
chmod a+x "/opt/$APP/remove"

# DOWNLOAD AND PREPARE THE APP
# $version is also used for updates

version=$(wget -q https://api.github.com/repos/"$REPO"/releases -O - | grep browser_download_url | grep -i nux_x86_64.tar.gz | cut -d '"' -f 4 | head -1)
wget "$version" -O download.tar.gz
echo "$version" >> "/opt/$APP/version"
tar fx ./*tar* && rm -f ./download.tar.gz
cd ..
mv --backup=t ./tmp/* ./
rm -R -f ./tmp

# LINK
ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"
chmod a+x "/opt/$APP/$APP"

# SCRIPT TO UPDATE THE PROGRAM
cat >> /opt/$APP/AM-updater << 'EOF'
#!/bin/sh
APP=gum
REPO="charmbracelet/gum"
version0=$(cat /opt/$APP/version)
version=$(wget -q https://api.github.com/repos/"$REPO"/releases -O - | grep browser_download_url | grep -i nux_x86_64.tar.gz | cut -d '"' -f 4 | head -1)
if [ "$version" = "$version0" ]; then
echo "Update not needed!"
else
notify-send "A new version of $APP is available, please wait"
mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
wget $version -O download.tar.gz
tar fx ./*tar*; rm -f -R ./*tar*
cd ..
mv --backup=t ./tmp/* ./
rm ./version
echo "$version" >> ./version
rm -R -f ./tmp ./*~
notify-send "$APP is updated!"
fi
EOF
chmod a+x "/opt/$APP/AM-updater"

# CHANGE THE PERMISSIONS
currentuser=$(who | awk '{print $1}')
chown -R $currentuser /opt/$APP