From 0e54e4f2d05e3a13c14598f99ef1cc8c08f7b30c Mon Sep 17 00:00:00 2001 From: hesam-init Date: Fri, 22 Mar 2024 14:42:41 +0330 Subject: [PATCH] feat: nekoray app downloader function --- configs/hyprland/waybar/gandalf/style.css | 2 +- .../hyprland/waybar/style/modules/taskbar.css | 7 +-- scripts/app-installer/nekoray.sh | 12 +++++ scripts/installer/nekoray.sh | 3 -- scripts/utils/main.sh | 48 ++++++++++++++++++- 5 files changed, 61 insertions(+), 11 deletions(-) create mode 100755 scripts/app-installer/nekoray.sh delete mode 100644 scripts/installer/nekoray.sh diff --git a/configs/hyprland/waybar/gandalf/style.css b/configs/hyprland/waybar/gandalf/style.css index 0c68728..f69817d 100644 --- a/configs/hyprland/waybar/gandalf/style.css +++ b/configs/hyprland/waybar/gandalf/style.css @@ -12,7 +12,7 @@ window { window>box { min-height: 30px; - margin: 4px; + margin: 6px; margin-bottom: 2px; padding: 5px 4px; background-color: @backgrounddark; diff --git a/configs/hyprland/waybar/style/modules/taskbar.css b/configs/hyprland/waybar/style/modules/taskbar.css index 4b9e5ed..79db130 100644 --- a/configs/hyprland/waybar/style/modules/taskbar.css +++ b/configs/hyprland/waybar/style/modules/taskbar.css @@ -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 { diff --git a/scripts/app-installer/nekoray.sh b/scripts/app-installer/nekoray.sh new file mode 100755 index 0000000..3358a6b --- /dev/null +++ b/scripts/app-installer/nekoray.sh @@ -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 diff --git a/scripts/installer/nekoray.sh b/scripts/installer/nekoray.sh deleted file mode 100644 index d5d64cc..0000000 --- a/scripts/installer/nekoray.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -source ../utils/main.sh diff --git a/scripts/utils/main.sh b/scripts/utils/main.sh index 632bb79..078231e 100755 --- a/scripts/utils/main.sh +++ b/scripts/utils/main.sh @@ -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 +}