aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/KooLsDotsUpdate.sh
blob: 887993a5a6a25a1eb18560831a96230c2b46d9bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# ==================================================
#  KoolDots (2026)
#  Project URL: https://github.com/LinuxBeginnings
#  License: GNU GPLv3
#  SPDX-License-Identifier: GPL-3.0-or-later
# ==================================================
# simple bash script to check if update is available by comparing local version and github version

# Local Paths
local_dir="$HOME/.config/hypr"
iDIR="$HOME/.config/swaync/images/"
local_version=$(find "$local_dir" -maxdepth 1 -name 'v*' -printf '%f\n' 2>/dev/null | sort -V | tail -n 1 | sed 's/^v//')
KooL_Dots_DIR="$HOME/Hyprland-Dots"

# exit if cannot find local version
if [ -z "$local_version" ]; then
  notify-send -i "$iDIR/error.png" 'ERROR !?!?!!' "Unable to find KooL's dots version. Exiting."
  exit 1
fi

# GitHub URL - KooL's dots
branch="main"
github_url="https://github.com/LinuxBeginnings/Hyprland-Dots/tree/$branch/config/hypr/"
# Check for required tools (curl)
if ! command -v curl &> /dev/null; then
  notify-send -i "$iDIR/error.png" "Need curl:" "curl not found. Please install curl."
  exit 1
fi

# Fetch the version from GitHub URL - KooL's dots
github_version=$(curl -fsSL -A "Mozilla/5.0" "$github_url" | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+' | sort -V | tail -n 1 | sed 's/v//')

# Cant find  GitHub URL - KooL's dots version
if [ -z "$github_version" ]; then
  notify-send -i "$iDIR/error.png" 'KooL Hyprland:' "Unable to determine GitHub version."
  exit 1
fi

# Comparing local and github versions
if [ "$(echo -e "$github_version\n$local_version" | sort -V | head -n 1)" = "$github_version" ]; then
   notify-send -i "$iDIR/note.png" "KooL Hyprland:" "No update available"
  exit 0
else
  # update available
  notify_cmd_base="notify-send -t 10000 -A action1=Update -A action2=NO -h string:x-canonical-private-synchronous:shot-notify"
  notify_cmd_shot="${notify_cmd_base} -i $iDIR/ja.png"

  response=$($notify_cmd_shot "KooL Hyprland:" "Update available! Update now?")

  case "$response" in
    "action1")  
      if [ -d "$KooL_Dots_DIR" ]; then
      	if ! command -v kitty &> /dev/null; then
  			notify-send -i "$iDIR/error.png" "E-R-R-O-R" "Kitty terminal not found. Please install Kitty terminal."
  			exit 1
		fi
        kitty -e bash -c "
          cd \"$KooL_Dots_DIR\" &&
          git stash &&
          git pull &&
          ./copy.sh &&
		  notify-send -u critical -i "$iDIR/ja.png" 'Update Completed:' 'Kindly log out and relogin to take effect'
        "
	
      else
         if ! command -v kitty &> /dev/null; then
  		  	notify-send -i "$iDIR/error.png" "E-R-R-O-R" "Kitty terminal not found. Please install Kitty terminal."
  			exit 1
		fi
        kitty -e bash -c "
          git clone --depth=1 https://github.com/LinuxBeginnings/Hyprland-Dots.git $KooL_Dots_DIR &&
          cd \"$KooL_Dots_DIR\" &&
          chmod +x copy.sh &&
          ./copy.sh &&
		  notify-send -u critical -i "$iDIR/ja.png" 'Update Completed:' 'Kindly log out and relogin to take effect'
        "
      fi
      ;;
    "action2")
      exit 0
      ;;
  esac
fi
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage