Add Launcher function implemented

This commit is contained in:
Fr4nz D13trich 2025-12-22 18:35:52 +01:00
parent b67067fccf
commit 5910d664d4
3 changed files with 45 additions and 61 deletions

View file

@ -3,12 +3,14 @@
# Helium BOWSER INSTALL & UPDATE SCRIPT ---> INTERACTIVE # Helium BOWSER INSTALL & UPDATE SCRIPT ---> INTERACTIVE
########## PREREQUISITES ########### ########## PREREQUISITES ###########
set -e
## SOME COLOR ## SOME COLOR
CYN="\e[0;36m" CYN="\e[0;36m"
YEL="\e[0;33m" YEL="\e[0;33m"
RED="\e[0;31m" RED="\e[0;31m"
GRN="\e[0;32m" GRN="\e[0;32m"
LCY="\e[1;36m"
CRS="\e[0m" CRS="\e[0m"
## GLOBAL VARIABLES ## GLOBAL VARIABLES
@ -23,7 +25,7 @@ DATE=$(date)
TMP=/tmp/$APP_NAME TMP=/tmp/$APP_NAME
INSTALL_PATH=$HOME/.apps/$APP_NAME INSTALL_PATH=$HOME/.apps/$APP_NAME
CONFIG_PATH=$INSTALL_PATH/assets CONFIG_PATH=$INSTALL_PATH/assets
BACKUP_PATH=$INSTALL_PATH/assets/backups BACKUP_PATH=$INSTALL_PATH/assets/backup
LOG_PATH=$INSTALL_PATH/assets/logs LOG_PATH=$INSTALL_PATH/assets/logs
LOG=$LOG_PATH/log LOG=$LOG_PATH/log
LAUNCHER_PATH=$HOME/.local/share/applications LAUNCHER_PATH=$HOME/.local/share/applications
@ -86,6 +88,7 @@ install_helium() {
while true ; do while true ; do
read -p " Download and install $APP_NAME_LONG from $SOURCE? (Y/n) : " CONFIRM_INSTALL read -p " Download and install $APP_NAME_LONG from $SOURCE? (Y/n) : " CONFIRM_INSTALL
echo
if [[ "$CONFIRM_INSTALL" == "" || "$CONFIRM_INSTALL" == "y" || "$CONFIRM_INSTALL" == "Y" ]] ; then if [[ "$CONFIRM_INSTALL" == "" || "$CONFIRM_INSTALL" == "y" || "$CONFIRM_INSTALL" == "Y" ]] ; then
GIT_URL=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | grep "browser_download_url" | grep "x86_64.AppImage" | grep -v "zsync" | tr -d \" | awk '{print $2}') GIT_URL=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | grep "browser_download_url" | grep "x86_64.AppImage" | grep -v "zsync" | tr -d \" | awk '{print $2}')
@ -95,7 +98,8 @@ install_helium() {
mkdir -p $INSTALL_PATH mkdir -p $INSTALL_PATH
mv $TMP/$GIT_FILENAME $INSTALL_PATH/$APP_NAME.AppImage mv $TMP/$GIT_FILENAME $INSTALL_PATH/$APP_NAME.AppImage
echo -e "\n ${GRN}$APP_NAME_LONG is installed!${CRS}\n" echo -e "\n ${GRN}$APP_NAME_LONG is installed!${CRS}\n"
exit add_launcher
exit_clean
elif [[ "$CONFIRM_INSTALL" == "n" || "$CONFIRM_INSTALL" == "N" ]] ; then elif [[ "$CONFIRM_INSTALL" == "n" || "$CONFIRM_INSTALL" == "N" ]] ; then
echo -e "\n ${RED}Installation cancelled!${CRS}\n" echo -e "\n ${RED}Installation cancelled!${CRS}\n"
@ -111,23 +115,30 @@ install_helium() {
### LAUNCHER --> TO DO ### LAUNCHER --> TO DO
add_launcher() { add_launcher() {
if [ -f "$INSTALL_PATH/$APP_NAME.AppImage" ] ; then if [ -f "$LAUNCHER_PATH/$APP_NAME.desktop" ] ; then
echo -e "\n ${RED}${APP_NAME}.desktop already exists!${CRS}"
exit
elif [ -f "$INSTALL_PATH/$APP_NAME.AppImage" ] ; then
while true ; do while true ; do
read -p " Add $APP_NAME_LONG launcher to $LAUNCHER_PATH? (Y/n) : " CONFIRM_LAUNCHER read -p " Add $APP_NAME_LONG launcher to $LAUNCHER_PATH? (Y/n) : " CONFIRM_LAUNCHER
echo
if [[ "$CONFIRM_LAUNCHER" == "" || "$CONFIRM_LAUNCHER" == "y" || "$CONFIRM_LAUNCHER" == "Y" ]] ; then if [[ "$CONFIRM_LAUNCHER" == "" || "$CONFIRM_LAUNCHER" == "y" || "$CONFIRM_LAUNCHER" == "Y" ]] ; then
ASSET_URL=https://lab.c95.org/fr4nz/helium-helper/src/branch/main/assets LAUNCHER_URL=https://lab.c95.org/fr4nz/helium-helper/raw/branch/main/assets/launcher/helium.desktop.template
ICON_URL=https://lab.c95.org/fr4nz/helium-helper/raw/branch/main/assets/icon/helium.png
LOCAL_VERSION=$($INSTALL_PATH/$APP_NAME.AppImage --version | awk '{print $2}') LOCAL_VERSION=$($INSTALL_PATH/$APP_NAME.AppImage --version | awk '{print $2}')
wget -P $TMP $ASSET_URL -q --show-progress wget -P $TMP $LAUNCHER_URL -q --show-progress
sed -i "s|%APP_LOCATION%|$INSTALL_PATH/$APP_NAME.AppImage|" $TMP/assets/launcher/helium.desktop.template wget -P $TMP $ICON_URL -q --show-progress
sed -i "s|%ICON_LOCATION%|$INSTALL_PATH/$CONFIG_PATH/icon/helium.png|" $TMP/assets/launcher/helium.desktop.template sed -i "s|%APP_LOCATION%|$INSTALL_PATH/$APP_NAME.AppImage|" $TMP/helium.desktop.template
sed -i "s|%APP_VERSION%|$LOCAL_VERSION|" $TMP/assets/launcher/helium.desktop.template sed -i "s|%ICON_LOCATION%|$CONFIG_PATH/icon/helium.png|" $TMP/helium.desktop.template
mkdir -p $LAUNCHER_PATH sed -i "s|%APP_VERSION%|$LOCAL_VERSION|" $TMP/helium.desktop.template
mv $TMP/assets/launcher/helium.desktop.template $LAUNCHER_PATH/$APP_NAME.desktop mkdir -p $LAUNCHER_PATH $BACKUP_PATH $CONFIG_PATH/icon
rm $TMP/assets/launcher cp $TMP/helium.desktop.template $LAUNCHER_PATH/$APP_NAME.desktop
mv $TMP/assets $CONFIG_PATH mv $TMP/helium.desktop.template $BACKUP_PATH/$APP_NAME.desktop.backup
mv $TMP/helium.png $CONFIG_PATH/icon
echo -e "\n ${GRN}$APP_NAME_LONG launcher is set up!${CRS}\n" echo -e "\n ${GRN}$APP_NAME_LONG launcher is set up!${CRS}\n"
exit exit_clean
elif [[ "$CONFIRM_LAUNCHER" == "n" || "$CONFIRM_LAUNCHER" == "N" ]] ; then elif [[ "$CONFIRM_LAUNCHER" == "n" || "$CONFIRM_LAUNCHER" == "N" ]] ; then
echo -e "\n ${RED}Launcher creation cancelled!${CRS}\n" echo -e "\n ${RED}Launcher creation cancelled!${CRS}\n"
@ -140,10 +151,6 @@ add_launcher() {
done done
elif [ -f "$LAUNCHER_PATH/$APP_NAME.desktop" ] ; then
echo -e "\n ${RED}${APP_NAME}.desktop already exists!${CRS}"
exit
else else
echo -e "\n ${RED}$APP_NAME_LONG AppImage not found! Can't add launcher...${CRS}" echo -e "\n ${RED}$APP_NAME_LONG AppImage not found! Can't add launcher...${CRS}"
install_helium install_helium
@ -182,6 +189,7 @@ update_helium() {
while true ; do while true ; do
read -p " Download and update $APP_NAME_LONG from $SOURCE? (Y/n) : " CONFIRM read -p " Download and update $APP_NAME_LONG from $SOURCE? (Y/n) : " CONFIRM
echo
if [[ "$CONFIRM" == "" || "$CONFIRM" == "y" || "$CONFIRM" == "Y" ]] ; then if [[ "$CONFIRM" == "" || "$CONFIRM" == "y" || "$CONFIRM" == "Y" ]] ; then
GIT_URL=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | grep "browser_download_url" | grep "x86_64.AppImage" | grep -v "zsync" | tr -d \" | awk '{print $2}') GIT_URL=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | grep "browser_download_url" | grep "x86_64.AppImage" | grep -v "zsync" | tr -d \" | awk '{print $2}')
@ -241,6 +249,7 @@ remove_helium() {
if [[ "$CONFIRM_REMOVE" == "" || "$CONFIRM_REMOVE" == "y" || "$CONFIRM_REMOVE" == "Y" ]] ; then if [[ "$CONFIRM_REMOVE" == "" || "$CONFIRM_REMOVE" == "y" || "$CONFIRM_REMOVE" == "Y" ]] ; then
rm -rf $INSTALL_PATH rm -rf $INSTALL_PATH
rm $LAUNCHER_PATH/$APP_NAME.desktop
echo -e "\n ${RED}$APP_NAME_LONG removed!${CRS}\n" echo -e "\n ${RED}$APP_NAME_LONG removed!${CRS}\n"
exit exit
@ -284,7 +293,7 @@ update_script() {
### COMPARE APPIMAGE VERSION ### COMPARE APPIMAGE VERSION
compare_version() { compare_version() {
LOCAL_VERSION=$($INSTALL_PATH/$APP_NAME.AppImage --version | awk '{print $2}' >/dev/null 2>&1) LOCAL_VERSION=$($INSTALL_PATH/$APP_NAME.AppImage --version | awk '{print $2}')
GIT_VERSION=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | grep "tag_name" | tr -d \", | awk '{print $2}') GIT_VERSION=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | grep "tag_name" | tr -d \", | awk '{print $2}')
### CHECK FOR EMPTY VERSION TAGS ### CHECK FOR EMPTY VERSION TAGS
@ -326,12 +335,12 @@ compare_version() {
### HELP ### HELP
help() { help() {
echo -e "\n${CYN}${SCRIPT_NAME}${CRS}\n" echo -e "\n${LCY}${SCRIPT_NAME}${CRS}\n"
echo -e "$APP_NAME_LONG installer & updater script\n" echo -e "$APP_NAME_LONG installer & updater script\n"
echo -e "Syntax: ${APP_NAME}_helper.sh [ -i | -L | -u | -U | -r | -c | -s | -S | -h ]\n" echo -e "Syntax: helium_helper.sh [ -i | -L | -u | -U | -r | -c | -s | -S | -h ]\n"
echo -e "Options:\n" echo -e "Options:\n"
echo -e "\t-i\tDownload & install $APP_NAME_LONG from $SOURCE" echo -e "\t-i\tDownload & install $APP_NAME_LONG from $SOURCE"
echo -e "\t-L\tCreate desktop launcher ${RED}--> Not yet working${CRS}" echo -e "\t-L\tCreate desktop launcher"
echo -e "\t-u\tDownload & update $APP_NAME_LONG from $SOURCE" echo -e "\t-u\tDownload & update $APP_NAME_LONG from $SOURCE"
echo -e "\t-U\tEnable automatic updates on login ${RED}--> Not yet working${CRS}" echo -e "\t-U\tEnable automatic updates on login ${RED}--> Not yet working${CRS}"
echo -e "\t-r\tRemove $APP_NAME_LONG" echo -e "\t-r\tRemove $APP_NAME_LONG"
@ -340,9 +349,9 @@ help() {
echo -e "\t-S\tUpdate script ${RED}--> Not yet working${CRS}" echo -e "\t-S\tUpdate script ${RED}--> Not yet working${CRS}"
echo -e "\t-h\tPrint this help page.\n" echo -e "\t-h\tPrint this help page.\n"
echo -e "Configured locations:\n" echo -e "Configured locations:\n"
echo -e "\t${YEL}${INSTALL_PATH}${CRS}\t\tInstall location" echo -e "\t${CYN}${INSTALL_PATH}${CRS}\t\tInstall location"
echo -e "\t${YEL}${LAUNCHER_PATH}${CRS}\tLauncher location" echo -e "\t${CYN}${LAUNCHER_PATH}${CRS}\tLauncher location"
echo -e "\t${YEL}${SCRIPT_PATH}${CRS}\t\t\tScript location\n" echo -e "\t${CYN}${SCRIPT_PATH}${CRS}\t\t\tScript location\n"
} }
### EXIT CLEAN ### EXIT CLEAN
@ -422,7 +431,7 @@ while getopts ":i,:L,:u,:U,:r,:c,:s,:S,:h" OPTION ; do
exit;; exit;;
*) *)
echo -e "\n ${YEL}Option ${RED}-t${YEL} not recognized... Refer to help below!${CRS}" echo -e "\n${YEL}Option ${RED}-t${YEL} not recognized... Refer to help below!${CRS}"
help help
exit;; exit;;

38
test.sh
View file

@ -1,36 +1,12 @@
#!/bin/bash #!/bin/bash
TMP=/tmp/Helium TMP=/tmp/Helium
DEPENDENCIES=("curl" "wget" "xeggw") add_launcher() {
### DEPENDENCIES --> NEEDS FIXING if [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
dependency_check () (
mkdir -p $TMP
cmd_query() {
local PACKAGE="$1"
if command -v "$PACKAGE" >/dev/null 2>&1 ; then
:
else
echo "$PACKAGE" >> $TMP/missingDeps
fi
}
for PACKAGE in "${DEPENDENCIES[@]}" ; do
cmd_query "$PACKAGE"
done
if ! [ -f "$TMP/missingDeps" ] ; then
:
else else
MISSING=$(cat $TMP/missingDeps) echo -e "\n ${RED}Helium AppImage not found! Can't add launcher...${CRS}"
echo -e "\n ${RED}Following dependencies are missing :\n\n${YEL}$MISSING\n\n ${CYN}Please install and re-run script !${CRS}" exit
fi fi
) }
dependency_check
rm -rf $TMP
exit

View file

@ -2,19 +2,18 @@
## Last Jobs ## Last Jobs
- Improved Version comparasing - Improved Version comparasing
- Added options [ -i | -u | -c | -s | -h ]
- Pre - Released Version 0.5
- Clean up function added - Clean up function added
- Remover function added --> Need to extend after launcher implementation - Remover function added
- Dummy functions added for: - Dummy functions added for:
- Desktop entry
- Auto Update - Auto Update
- Script update - Script update
- Dependency check fixed
- Launcher function works
- Remover extended
## Add ## Add
- Internet connectivity check in [Auto Update Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_auto_update.sh) - Internet connectivity check in [Auto Update Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_auto_update.sh)
- Desktop entry [Helper Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_helper.sh)
- Desktop entry updater [Helper Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_helper.sh) & [Auto Update Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_auto_update.sh) - Desktop entry updater [Helper Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_helper.sh) & [Auto Update Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_auto_update.sh)
- Auto update setup - Auto update setup
- shell recognition - shell recognition