Skip to content

Commit

Permalink
Fix for Issue mylinuxforwork#665
Browse files Browse the repository at this point in the history
Fix for Issue mylinuxforwork#665
  • Loading branch information
degobbis committed Feb 7, 2025
1 parent b070acb commit f670b18
Showing 1 changed file with 41 additions and 17 deletions.
58 changes: 41 additions & 17 deletions share/dotfiles/.config/ml4w/scripts/updates.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
#!/bin/bash
# _ _ _ _
# | | | |_ __ __| | __ _| |_ ___ ___
# | | | | '_ \ / _` |/ _` | __/ _ \/ __|
# | |_| | |_) | (_| | (_| | || __/\__ \
# \___/| .__/ \__,_|\__,_|\__\___||___/
# |_|
#

# -----------------------------------------------------
# _ _ _ _
# | | | |_ __ __| | __ _| |_ ___ ___
# | | | | '_ \ / _` |/ _` | __/ _ \/ __|
# | |_| | |_) | (_| | (_| | || __/\__ \
# \___/| .__/ \__,_|\__,_|\__\___||___/
# |_|
#

script_name=$(basename "$0")

# Count the instances
instance_count=$(ps aux | grep -F "$script_name" | grep -v grep | grep -v $$ | wc -l)

if [ $instance_count -gt 1 ]; then
sleep $instance_count
fi


# -----------------------------------------------------
# Define threshholds for color indicators
# -----------------------------------------------------
# -----------------------------------------------------

threshhold_green=0
threshhold_yellow=25
Expand All @@ -21,25 +31,39 @@ case $install_platform in
arch)
aur_helper="$(cat ~/.config/ml4w/settings/aur.sh)"

# -----------------------------------------------------
# -----------------------------------------------------
# Calculate available updates
# -----------------------------------------------------
# -----------------------------------------------------

# flatpak remote-ls --updates

# -----------------------------------------------------------------------------
# Check for pacman or checkupdates-with-aur database lock and wait if necessary
# -----------------------------------------------------------------------------
check_lock_files() {
local pacman_lock="/var/lib/pacman/db.lck"
local checkup_lock="${TMPDIR:-/tmp}/checkup-db-${UID}/db.lck"

while [ -f "$pacman_lock" ] || [ -f "$checkup_lock" ]; do
sleep 1
done
}

check_lock_files

updates=$(checkupdates-with-aur | wc -l)
;;
;;
fedora)
updates=$(dnf check-update -q | grep -c ^[a-z0-9])
;;
;;
*)
updates=0
;;
;;
esac

# -----------------------------------------------------
# -----------------------------------------------------
# Output in JSON format for Waybar Module custom-updates
# -----------------------------------------------------
# -----------------------------------------------------

css_class="green"

Expand Down

0 comments on commit f670b18

Please sign in to comment.