fixes and improvements

This commit is contained in:
2025-07-25 10:24:08 +02:00
parent e2f428bc64
commit 0f51bf1abb
46 changed files with 780 additions and 63 deletions
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
# Check the current state of the speaker
state=$(amixer -D pulse sget Master | awk '/\[on\]/{print "unmute"; exit} /\[off\]/{print "mute"; exit}')
# Toggle the state of the speaker
#
if [ "$state" = "[on] "]; then
amixer
# amixer -D pulse sset Master "$state" > /dev/null
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
check() {
command -v "$1" 1>/dev/null
}
notify() {
check notify-send && {
notify-send -a "Color Picker" "$@"
return
}
echo "$@"
}
loc="$HOME/.cache/colorpicker"
[ -d "$loc" ] || mkdir -p "$loc"
[ -f "$loc/colors" ] || touch "$loc/colors"
limit=10
[[ $# -eq 1 && $1 = "-l" ]] && {
cat "$loc/colors"
exit
}
[[ $# -eq 1 && $1 = "-j" ]] && {
text="$(head -n 1 "$loc/colors")"
mapfile -t allcolors < <(tail -n +2 "$loc/colors")
# allcolors=($(tail -n +2 "$loc/colors"))
tooltip="<b> COLORS</b>\n\n"
tooltip+="-> <b>$text</b> <span color='$text'></span> \n"
for i in "${allcolors[@]}"; do
tooltip+=" <b>$i</b> <span color='$i'></span> \n"
done
cat <<EOF
{ "text":"<span color='$text'></span>", "tooltip":"$tooltip"}
EOF
exit
}
check hyprpicker || {
notify "hyprpicker is not installed"
exit
}
killall -q hyprpicker
color=$(hyprpicker)
check wl-copy && {
echo "$color" | sed -z 's/\n//g' | wl-copy
}
prevColors=$(head -n $((limit - 1)) "$loc/colors")
echo "$color" >"$loc/colors"
echo "$prevColors" >>"$loc/colors"
sed -i '/^$/d' "$loc/colors"
pkill -RTMIN+1 waybar
+53
View File
@@ -0,0 +1,53 @@
# Temp file to store previous readings
tmpfile="/tmp/cpu_prev_all"
# Get all per-core lines
mapfile -t cpu_lines < <(grep '^cpu[0-9]' /proc/stat)
# On first run, save and exit
if [[ ! -f $tmpfile ]]; then
printf "%s\n" "${cpu_lines[@]}" > "$tmpfile"
echo "..." # No previous data
exit 0
fi
# Load previous readings
mapfile -t prev_lines < "$tmpfile"
# Sanity check
if (( ${#cpu_lines[@]} != ${#prev_lines[@]} )); then
echo "..." # Core count mismatch (e.g., suspend/resume)
printf "%s\n" "${cpu_lines[@]}" > "$tmpfile"
exit 0
fi
total_usage=0
for i in "${!cpu_lines[@]}"; do
# Current
read -r cpu user nice system idle iowait irq softirq steal _ _ <<< "${cpu_lines[$i]}"
total_now=$((user + nice + system + idle + iowait + irq + softirq + steal))
idle_now=$((idle + iowait))
# Previous
read -r _ pu pn ps pi piw pir psf pst _ _ <<< "${prev_lines[$i]}"
total_prev=$((pu + pn + ps + pi + piw + pir + psf + pst))
idle_prev=$((pi + piw))
# Deltas
diff_total=$((total_now - total_prev))
diff_idle=$((idle_now - idle_prev))
if ((diff_total > 0)); then
usage=$((100 * (diff_total - diff_idle) / diff_total))
total_usage=$((total_usage + usage))
fi
done
# Output total usage (per-core sum)
#echo '{"usage": ${total_usage}%}'}
printf "{ \"text\": %6.0f, \"tooltip\": \"%s\" }" "$total_usage" "test"
# Save current readings
printf "%s\n" "${cpu_lines[@]}" > "$tmpfile"
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
format() {
if [ "$1" -eq 0 ]; then
echo '-'
else
echo "$1"
fi
}
if ! updates_arch="$(checkupdates | wc -l)"; then
updates_arch=0
fi
if ! updates_aur="$(yay -Qum 2>/dev/null | wc -l)"; then
updates_aur=0
fi
updates="$((updates_arch + updates_aur))"
if [ "$updates" -gt 0 ]; then
echo " ($(format $updates_arch)/$(format $updates_aur))"
else
echo
fia
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
pkgmgr="pacman"
hash paru 2>/dev/null && pkgmgr="paru"
hash yay 2>/dev/null && pkgmgr="yay"
IFS=$'\n'$'\r'
updatesli=($($pkgmgr -Qu))
text=${#updatesli[@]}
icon=""
[ $text -eq 0 ] && icon="" || icon="📦"
for i in ${updatesli[@]}
do
tooltip+="$i\n"
done
cat << EOF
{ "text":"$icon", "tooltip":"UPDATES: $text"}
EOF
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
if [ -f /sys/class/power_supply/BAT*/current_now ]; then
powerDraw="󰠰 $(($(cat /sys/class/power_supply/BAT*/current_now)/1000000))w"
fi
cat << EOF
{ "text":"$powerDraw", "tooltip":"power Draw $powerDraw"}
EOF
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
BSSIDS="$(nmcli device wifi list |
awk 'NR>1 {if ($1 != "*") {print $1}}' |
tr -d ":" |
tr "\n" ",")"
LOC=""
REQUEST_GEO="$(wget -qO - http://openwifi.su/api/v1/bssids/"$BSSIDS")"
if [[ "$(jq ".count_results" <<< "$REQUEST_GEO")" -gt 0 ]] ; then
LAT="$(jq ".lat" <<< "$REQUEST_GEO")"
LON="$(jq ".lon" <<< "$REQUEST_GEO")"
LOC="$LAT,$LON"
fi
text="$(curl -s "https://wttr.in/$LOC?format=1" | sed 's/ //g')"
tooltip="$(curl -s "https://wttr.in/$LOC?0QT" |
sed 's/\\/\\\\/g' |
sed ':a;N;$!ba;s/\n/\\n/g' |
sed 's/"/\\"/g')"
if ! grep -q "Unknown location" <<< "$text"; then
echo "{\"text\": \"$text\", \"tooltip\": \"<tt>$tooltip</tt>\", \"class\": \"weather\"}"
fi