Skip to content

Commit

Permalink
Merge pull request #453 from Samueru-sama/main
Browse files Browse the repository at this point in the history
Add gum
  • Loading branch information
ivan-hc authored Apr 21, 2024
2 parents 62c8c67 + 22bd9be commit 74f1c73
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
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

0 comments on commit 74f1c73

Please sign in to comment.