waybar changes 1

This commit is contained in:
cnst
2024-12-27 16:46:50 +01:00
parent 542bac2fe7
commit 10716da678
22 changed files with 1007 additions and 159 deletions

View File

@@ -1,8 +1,8 @@
#!/bin/sh
MAKOCTL="/etc/profiles/per-user/$USER/bin/makoctl"
GREP="/run/current-system/sw/bin/grep"
# Toggle Mako mode between "do-not-disturb" and "default"
if makoctl mode | grep -q "default"; then
makoctl set-mode do-not-disturb
if "$MAKOCTL" mode | "$GREP" -q "default"; then
"$MAKOCTL" set-mode do-not-disturb
else
makoctl set-mode default
"$MAKOCTL" set-mode default
fi

View File

@@ -1,10 +1,10 @@
#!/bin/sh
MAKOCTL="/etc/profiles/per-user/$USER/bin/makoctl"
GREP="/run/current-system/sw/bin/grep"
COUNT=$(makoctl list | grep -c "id")
ENABLED=󰂚
DISABLED=󱏧
if [ "$COUNT" != 0 ]; then DISABLED="󱅫"; fi
if [ "$(
makoctl mode | grep -q "default"
echo $?
)" -eq 0 ]; then echo $ENABLED; else echo $DISABLED; fi
if "$MAKOCTL" mode | "$GREP" -q "default"; then
# Default mode
echo "󰂚"
else
# Do-not-disturb mode
echo "󱏧"
fi

10
scripts/bin/waybar-progress.sh Executable file
View File

@@ -0,0 +1,10 @@
# This is a very slightly modified version of a script from @maximbaz
PROGRESS="/run/current-system/sw/bin/progress"
PERL="/run/current-system/sw/bin/perl"
SED="/etc/profiles/per-user/$USER/bin/sed"
output="$("$PROGRESS" -q)"
text="$(printf "%s" "$output" | "$SED" 's/\[[^]]*\] //g' | /run/current-system/sw/bin/awk 'BEGIN { ORS=" " } NR%3==1 { op=$1 } NR%3==2 { pct=($1+0); if (op != "gpg" && op != "coreutils" && pct > 0 && pct < 100) { print op, $1 } }')"
tooltip="$(printf "%s" "$output" | "$PERL" -pe 's/\n/\\n/g' | "$PERL" -pe 's/(?:\\n)+$//')"
printf '{"text": "%s", "tooltip": "%s"}\n' "$text" "$tooltip"

52
scripts/bin/waybar-systemd.sh Executable file
View File

@@ -0,0 +1,52 @@
# This is a modified version of a script from @maximbaz
SYSTEMCTL="/run/current-system/sw/bin/systemctl"
WC="/run/current-system/sw/bin/wc"
failed_user_output=$("$SYSTEMCTL" --plain --no-legend --user list-units --state=failed --type=service 2>/dev/null)
failed_system_output=$("$SYSTEMCTL" --plain --no-legend list-units --state=failed --type=service)
if [[ -z "$failed_system_output" ]]; then
failed_systemd_count=0
else
failed_systemd_count=$("$WC" -l <<<"$failed_system_output")
fi
if [[ -z "$failed_user_output" ]]; then
failed_user_count=0
else
failed_user_count=$("$WC" -l <<<"$failed_user_output")
fi
total_failed=$((failed_systemd_count + failed_user_count))
if [[ "$total_failed" -eq 0 ]]; then
printf '{"text": ""}\n'
else
tooltip=""
if [[ -n "$failed_system_output" ]]; then
failed_system=$(echo "$failed_system_output" | /run/current-system/sw/bin/awk '{print $1}')
tooltip+="Failed system services: "
if [[ "$failed_systemd_count" -gt 1 ]]; then
failed_system_indented="${failed_system//$'\n'/\\n }"
tooltip+="$failed_system_indented"
else
tooltip+="$failed_system"
fi
fi
if [[ -n "$failed_user_output" ]]; then
failed_user=$(echo "$failed_user_output" | /run/current-system/sw/bin/awk '{print $1}')
if [[ -n "$tooltip" ]]; then tooltip+="\n"; fi
tooltip+="Failed user services: "
if [[ "$failed_user_count" -gt 1 ]]; then
failed_user_indented="${failed_user//$'\n'/\\n }"
tooltip+="$failed_user_indented"
else
tooltip+="$failed_user"
fi
fi
escaped_tooltip="${tooltip//$'\\n'/\\\\n}"
printf '{"text": " %d", "tooltip": "%s"}\n' "$total_failed" "$escaped_tooltip"
fi