feat: nekoray app downloader function

This commit is contained in:
hesam-init 2024-03-22 14:42:41 +03:30
parent f86f0108bc
commit 0e54e4f2d0
5 changed files with 61 additions and 11 deletions

View file

@ -12,7 +12,7 @@ window {
window>box {
min-height: 30px;
margin: 4px;
margin: 6px;
margin-bottom: 2px;
padding: 5px 4px;
background-color: @backgrounddark;

View file

@ -1,8 +1,3 @@
#workspaces,
#tray {
padding: 0px 10px;
}
#tray menu * {
all: unset;
}
@ -27,7 +22,7 @@
}
#workspaces * {
font-size: 11px;
font-size: 10px;
}
#workspaces button {

View file

@ -0,0 +1,12 @@
#!/bin/bash
source ../utils/main.sh
DOWNLOAD_URL="https://github.com/MatsuriDayo/nekoray/releases/download/3.26/nekoray-3.26-2023-12-09-linux64.zip"
FILE_NAME="nekoray.zip"
install_nekoray() {
download_file $DOWNLOAD_URL $FILE_NAME
}
install_nekoray

View file

@ -1,3 +0,0 @@
#!/bin/bash
source ../utils/main.sh

View file

@ -4,7 +4,7 @@ log() {
local timestamp=$(date +"%T")
local message="======> $1 : $timestamp"
echo -e "\n$message"
echo -e "\n$message\n"
}
check_sudo() {
@ -20,3 +20,49 @@ check() {
exit 1
fi
}
check_command() {
if ! command -v $1 &>/dev/null; then
log "$1 is not installed. Please install $1 to continue."
exit 1
fi
}
ask_prompt() {
local question="$1"
while true; do
read -p "$question (Y/N): " choice
case "$choice" in
[Yy]) return 0 ;;
[Nn]) return 1 ;;
*) echo "Please enter Y or N." ;;
esac
done
}
download_file() {
check_command wget
local url="$1"
local tmp_dir="/tmp"
local filename="${2:-$(basename "$url")}"
local file_path="$tmp_dir/$filename"
if [ -e "$file_path" ]; then
if ask_prompt "File $file_path already exists. Do you want to continue ?"; then
echo "Continuing with existing file: $file_path"
wget -c -O "$tmp_dir/$filename" "$url"
else
echo "Deleted existing file: $file_path"
wget -O "$tmp_dir/$filename" "$url"
fi
else
wget -O "$tmp_dir/$filename" "$url"
fi
if [ $? -eq 0 ]; then
echo "File downloaded successfully: $tmp_dir/$filename"
else
echo "Failed to download file from $url"
fi
}