Skip to content

Instantly share code, notes, and snippets.

@FindHao
Last active December 24, 2022 22:33

Revisions

  1. Yueming Hao revised this gist Dec 24, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion runqq.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/bin/bash
    # Put this script to the same folder with Icalingua++-XX.AppImage
    # Put this script to the same folder with Icalingua++-XX.AppImage or where you want to download the appimage.

    # get script path
    file_path=$(dirname $(readlink -f $0))
  2. Yueming Hao revised this gist Dec 24, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions runqq.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    #!/bin/bash
    # Put this script to the same folder with Icalingua++-XX.AppImage

    # get script path
    file_path=$(dirname $(readlink -f $0))
  3. Yueming Hao created this gist Dec 24, 2022.
    52 changes: 52 additions & 0 deletions runqq.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    #!/bin/bash

    # get script path
    file_path=$(dirname $(readlink -f $0))
    cd $file_path
    # check github releases for new version
    url=$(curl -s https://api.github.com/repos/Icalingua-plus-plus/Icalingua-plus-plus/releases/latest | grep "browser_download_url.*AppImage" | cut -d : -f 2,3 | tr -d \" | sed -n '3p')

    # check if url is empty
    if [ -z "$url" ]; then
    echo "can not get the latest version"
    exit 0
    fi

    # get the version number
    version=$(echo "$url" | sed -n 's/.*v\(.*\)\/.*/\1/p')

    function update() {
    target_file="Icalingua++-$version.AppImage"
    # strip url
    url=$(echo "$url" | sed -n 's/.*\(https.*\)/\1/p')
    # download the latest version
    wget "$url" -O $target_file
    }

    # get all icalingua++ appimage files
    files=$(find . -name "Icalingua++-*.AppImage")
    need_update=false
    # check if there is no appimage file
    if [ -z "$files" ]; then
    echo "No appimage file found"
    need_update=true
    else
    # check which one is the latest version
    local_latest=$(echo "$files" | sort -V | tail -n 1)
    local_version=$(echo "$local_latest" | sed -n 's/.*Icalingua++-\(.*\).AppImage/\1/p')
    target_file=$local_latest
    # check if the latest version is not the same as the latest version on github
    if [ "$version" != "$local_version" ]; then
    rm -f $local_latest
    echo "New version found: $version"
    need_update=true
    fi
    fi

    if [ "$need_update" = true ]; then
    update
    fi

    # run the latest version
    chmod +x "$target_file"
    ./"$target_file"