added update logic and styles, added update script

This commit is contained in:
2026-05-02 02:30:51 +01:00
parent 82f0a6253f
commit 84c5ee9864
3 changed files with 53 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
{ {
"modules-left": ["battery", "clock#date", "clock","custom/updates", "custom/launcher"], "modules-left": ["battery", "clock#date", "clock","custom/updater", "custom/launcher"],
"modules-center": ["hyprland/workspaces"], "modules-center": ["hyprland/workspaces"],
"modules-right": ["network", "bluetooth", "pulseaudio", "custom/power"], "modules-right": ["network", "bluetooth", "pulseaudio", "custom/power"],
@@ -136,14 +136,13 @@
}, },
"sort-by-number": true "sort-by-number": true
}, },
"custom/updatespacman": { "custom/updater": {
"format": "{}{icon}", "format": "󰏖 {}",
"return-type": "json", "exec": "checkupdates | wc -l",
"format-icons": { "exec-if": "[[ $(checkupdates | wc -l) ]]",
"has-updates": " 󰏖", "interval": 5,
"updated": "" "on-click": "$HOME/.config/waybar/scripts/update-distro.sh",
}, "tooltip": true,
"exec-if": "which waybar-module-pacman-updates", "tooltip-format": "Left Click: Update System\nArch (w/ notification)\nFedora, OpenSuse, Debian/Ubuntu click to update"
"exec": "waybar-module-pacman-updates --no-zero-output"
} }
} }

View File

@@ -0,0 +1,40 @@
#!/bin/bash
# HyprFlux — https://github.com/ahmad9059/HyprFlux
# Simple bash script to check and will try to update your system
# Local Paths
iDIR="$HOME/.config/swaync/images"
# Check for required tools (kitty)
if ! command -v kitty &> /dev/null; then
notify-send -i "$iDIR/error.png" "Need Kitty:" "Kitty terminal not found. Please install Kitty terminal."
exit 1
fi
# Detect distribution and update accordingly
if command -v paru &> /dev/null || command -v yay &> /dev/null; then
# Arch-based
if command -v paru &> /dev/null; then
kitty -T update paru -Syu
notify-send -i "$iDIR/ja.png" -u low 'Arch-based system' 'has been updated.'
else
kitty -T update yay -Syu
notify-send -i "$iDIR/ja.png" -u low 'Arch-based system' 'has been updated.'
fi
elif command -v dnf &> /dev/null; then
# Fedora-based
kitty -T update sudo dnf update --refresh -y
notify-send -i "$iDIR/ja.png" -u low 'Fedora system' 'has been updated.'
elif command -v apt &> /dev/null; then
# Debian-based (Debian, Ubuntu, etc.)
kitty -T update sudo apt update && sudo apt upgrade -y
notify-send -i "$iDIR/ja.png" -u low 'Debian/Ubuntu system' 'has been updated.'
elif command -v zypper &> /dev/null; then
# openSUSE-based
kitty -T update sudo zypper dup -y
notify-send -i "$iDIR/ja.png" -u low 'openSUSE system' 'has been updated.'
else
# Unsupported distro
notify-send -i "$iDIR/error.png" -u critical "Unsupported system" "This script does not support your distribution."
exit 1
fi

View File

@@ -17,24 +17,14 @@ window#waybar {
} }
/* Updated Update Module Styling */ #custom-updater {
#custom-updates { font-size: 13px;
padding: 5px 15px; background-color: rgba(0,43,51,0.85);
background-color: rgba(0, 43, 51, 0.85); /* Matches your other modules */
border-radius: 20px; border-radius: 20px;
padding: 5px 8px;
margin: 5px 3px; margin: 5px 3px;
} }
#custom-updates.yellow {
background-color: #ffcc66; /* A nice yellow/orange */
color: #000000;
}
#custom-updates.red {
background-color: #cc3436; /* Your existing red color */
color: #ffffff;
}
.modules-left { .modules-left {
margin: 2px 0 0 5px; margin: 2px 0 0 5px;
} }