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

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-updates {
padding: 5px 15px;
background-color: rgba(0, 43, 51, 0.85); /* Matches your other modules */
#custom-updater {
font-size: 13px;
background-color: rgba(0,43,51,0.85);
border-radius: 20px;
padding: 5px 8px;
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 {
margin: 2px 0 0 5px;
}