summaryrefslogtreecommitdiff
path: root/ar/.local/bin/dmenuupgrade
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-24 20:35:27 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-24 20:35:27 +0900
commitc80a54e42b52ce297f0f2f71af23c562832025c7 (patch)
treedcce8bb977a770f473325d48f6f70b21d9818a40 /ar/.local/bin/dmenuupgrade
init
Diffstat (limited to 'ar/.local/bin/dmenuupgrade')
-rwxr-xr-xar/.local/bin/dmenuupgrade115
1 files changed, 115 insertions, 0 deletions
diff --git a/ar/.local/bin/dmenuupgrade b/ar/.local/bin/dmenuupgrade
new file mode 100755
index 0000000..b43ff4c
--- /dev/null
+++ b/ar/.local/bin/dmenuupgrade
@@ -0,0 +1,115 @@
+#!/bin/sh
+
+# Get list of pacman and yay upgradable packages
+pacman_updates=$(pacman -Qu)
+yay_updates=$(yay -Qu)
+
+# Count the number of upgradable packages, filtering yay's output to count only AUR packages
+pacman_count=$(printf "%s" "$pacman_updates" | grep -c '^\S')
+aur_count=$(printf "%s" "$yay_updates" | grep -c '^\[AUR\]')
+
+# Display the upgrade options with package counts
+selection=$(printf "All\nPacman(%d)\nAUR(%d)" "$pacman_count" "$aur_count" | dmenu -i -p "Upgrade Option:")
+
+case "$selection" in
+"All")
+ if [ "$(printf "No\nYes" | dmenu -i -p 'Proceed with upgrade for all packages?')" = "Yes" ]; then
+ notify-send "📦 Upgrading all packages..."
+ yay -Syu --noconfirm
+ pkill -RTMIN+16 "${STATUSBAR:-dwmblocks}"
+ notify-send "✅ Upgrade of all packages completed."
+ else
+ notify-send "❌ Upgrade cancelled."
+ exit 0
+ fi
+ ;;
+"Pacman($pacman_count)")
+ # Show all upgradable pacman packages with "Upgrade All" option
+ selection=$(printf "Upgrade All\n%s" "$pacman_updates" | dmenu -i -l 10 -p "Pacman: Upgrade or Open URL:")
+ case "$selection" in
+ "Upgrade All")
+ if [ "$(printf "No\nYes" | dmenu -i -p 'Proceed with pacman upgrade?')" = "Yes" ]; then
+ notify-send "📦 Upgrading pacman packages..."
+ printf "%s" "$pacman_updates" | awk '{print $1}' | xargs sudo pacman -S --noconfirm
+ pkill -RTMIN+16 "${STATUSBAR:-dwmblocks}"
+ notify-send "✅ Pacman packages upgrade completed."
+ else
+ notify-send "❌ Upgrade cancelled."
+ exit 0
+ fi
+ ;;
+ *)
+ # Individual package selected: Prompt to upgrade or open URL
+ action=$(printf "Upgrade\nOpen URL" | dmenu -i -p "Package: $selection")
+ case "$action" in
+ "Upgrade")
+ if [ "$(printf "No\nYes" | dmenu -i -p 'Proceed with upgrade for this package?')" = "Yes" ]; then
+ notify-send "📦 Upgrading package: $selection..."
+ sudo pacman -S --noconfirm "$(printf "%s" "$selection" | awk '{print $1}')"
+ pkill -RTMIN+16 "${STATUSBAR:-dwmblocks}"
+ notify-send "✅ Upgrade completed for package: $selection."
+ else
+ notify-send "❌ Upgrade cancelled."
+ exit 0
+ fi
+ ;;
+ "Open URL")
+ if [ "$(printf "No\nYes" | dmenu -i -p 'Open URL?')" = "Yes" ]; then
+ xdg-open "https://archlinux.org/packages/?q=$(printf "%s" "$selection" | awk '{print $1}')" >/dev/null 2>&1 &
+ else
+ exit
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+"AUR($aur_count)")
+ # Show all upgradable AUR packages with "Upgrade All" option
+ aur_updates=$(printf "%s" "$yay_updates" | grep '^\[AUR\]')
+ selection=$(printf "Upgrade All\n%s" "$aur_updates" | dmenu -i -l 10 -p "AUR: Upgrade or Open URL:")
+ case "$selection" in
+ "Upgrade All")
+ if [ "$(printf "No\nYes" | dmenu -i -p 'Proceed with AUR upgrade?')" = "Yes" ]; then
+ notify-send "📦 Upgrading AUR packages..."
+ yay -Syu --aur --noconfirm
+ pkill -RTMIN+16 "${STATUSBAR:-dwmblocks}"
+ notify-send "✅ AUR packages upgrade completed."
+ else
+ notify-send "❌ Upgrade cancelled."
+ exit 0
+ fi
+ ;;
+ *)
+ # Individual AUR package selected: Prompt to upgrade or open URL
+ action=$(printf "Upgrade\nOpen URL" | dmenu -i -p "Package: $selection")
+ case "$action" in
+ "Upgrade")
+ if [ "$(printf "No\nYes" | dmenu -i -p 'Proceed with upgrade for this package?')" = "Yes" ]; then
+ notify-send "📦 Upgrading AUR package: $selection..."
+ yay -S --noconfirm "$(printf "%s" "$selection" | awk '{print $2}')"
+ pkill -RTMIN+16 "${STATUSBAR:-dwmblocks}"
+ notify-send "✅ Upgrade completed for AUR package: $selection."
+ else
+ notify-send "❌ Upgrade cancelled."
+ exit 0
+ fi
+ ;;
+ "Open URL")
+ if [ "$(printf "No\nYes" | dmenu -i -p 'Open URL?')" = "Yes" ]; then
+ xdg-open "https://aur.archlinux.org/packages/?O=0&K=$(printf "%s" "$selection" | awk '{print $2}')" >/dev/null 2>&1 &
+ else
+ exit
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+*)
+ notify-send "❌ Invalid selection."
+ exit 0
+ ;;
+esac
+
+remaps