upadted waybar + hypr theme
This commit is contained in:
45
waybar/scripts/btrfs.sh
Executable file
45
waybar/scripts/btrfs.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get BTRFS filesystems
|
||||
btrfs_filesystems=$(df -hT | grep btrfs)
|
||||
|
||||
# Initialize variables
|
||||
total_used=0
|
||||
total_size=0
|
||||
|
||||
# Process each BTRFS filesystem
|
||||
while read -r line; do
|
||||
size_str=$(echo "$line" | awk '{print $3}')
|
||||
used_str=$(echo "$line" | awk '{print $4}')
|
||||
|
||||
size=$(echo "$size_str" | sed 's/[GT]//')
|
||||
used=$(echo "$used_str" | sed 's/[GT]//')
|
||||
|
||||
if [[ $size_str == *T ]]; then
|
||||
size=$(awk -v s="$size" 'BEGIN {print s*1024}')
|
||||
fi
|
||||
if [[ $used_str == *T ]]; then
|
||||
used=$(awk -v u="$used" 'BEGIN {print u*1024}')
|
||||
fi
|
||||
|
||||
total_size=$(awk -v total="$total_size" -v size="$size" 'BEGIN {print total+size}')
|
||||
total_used=$(awk -v total="$total_used" -v used="$used" 'BEGIN {print total+used}')
|
||||
|
||||
done <<< "$btrfs_filesystems"
|
||||
|
||||
# Calculate usage percentage
|
||||
usage_percentage=$(awk -v used="$total_used" -v total="$total_size" 'BEGIN {printf "%.0f", (used/total)*100}')
|
||||
|
||||
# Set class based on usage
|
||||
if [ "$usage_percentage" -gt 95 ]; then
|
||||
class="max"
|
||||
elif [ "$usage_percentage" -gt 80 ]; then
|
||||
class="high"
|
||||
else
|
||||
class="normal"
|
||||
fi
|
||||
|
||||
text="$(printf "%.0f" $total_used)G / $(printf "%.0f" $total_size)G"
|
||||
|
||||
# Manually construct the JSON output
|
||||
echo "{\"text\": \"$text\", \"tooltip\": \"\", \"class\": \"$class\"}"
|
@@ -1,9 +1,12 @@
|
||||
#!/bin/bash
|
||||
USAGE=$(mpstat 1 1 | awk '/Average:/ {print 100 - $12}')
|
||||
TEMP=$(cat /sys/class/hwmon/hwmon6/temp1_input)
|
||||
TEXT="$(printf "%.1f" $(echo "$USAGE"))% TEMP: $(printf "%.1f" $(echo "scale=2; $TEMP"/1000 | bc -l))C"
|
||||
TEMP=$(cat /sys/class/hwmon/hwmon3/temp1_input)
|
||||
TEXT="$(printf "%.1f" $(echo "$USAGE"))% $(printf "%.1f" $(echo "scale=2; $TEMP"/1000 | bc -l))C"
|
||||
CPU=$(lscpu | grep 'Model name' | awk -F': ' '{print $2}' | sed 's/^[ \t]*//')
|
||||
TOOLTIP=$(ps -eo %cpu,comm --sort=-%cpu | head -n 6 | sed '1d' | awk -v ncores=$(nproc) '{printf "%.1f%%\t%s\\n", $1/ncores, $2}')
|
||||
# TOOLTIP=$(ps -eo %cpu,comm --sort=-%cpu | head -n 6 | sed '1d' | awk '{output = output sprintf("%.1f%%\t%s\\n", $1, $2)} END {printf "%s", output}')
|
||||
# TOOLTIP=$(ps -eo %cpu,comm --sort=-%cpu | head -n 6 | sed '1d' | awk -v ncores=$(nproc) '{printf "%.1f%%\t%s\n", $1/ncores, $2}')
|
||||
# TOOLTIP=$(ps -eo %cpu,comm --sort=-%cpu | head -n 6 | sed '1d' | awk -v ncores=$(nproc) '{printf "%.1f%%\t%s\\n", $1/ncores, $2}')
|
||||
# TOOLTIP=$(top -b -n 1 | sed '1,7d' | head -n 5 | awk '{output = output sprintf("%.1f%%\t%s\\n", $9, $12)} END {printf "%s", output}')
|
||||
|
||||
CLASS=""
|
||||
|
||||
@@ -15,4 +18,5 @@ else
|
||||
CLASS="normal"
|
||||
fi
|
||||
|
||||
echo "{\"text\":\"CPU: $TEXT\", \"tooltip\": \"$TOOLTIP\", \"class\":\"$CLASS\"}"
|
||||
# echo "{\"text\":\"CPU: $TEXT\", \"tooltip\": \"$TOOLTIP\", \"class\":\"$CLASS\"}"
|
||||
echo "{\"text\":\"CPU: $TEXT\", \"class\":\"$CLASS\"}"
|
||||
|
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
SINKS=($(pactl list short sinks | awk '{print $2}'))
|
||||
CURRENT_SINK=$(pactl info | grep 'Default Sink' | cut -d ' ' -f3)
|
||||
NUM_SINKS=${#SINKS[@]}
|
||||
|
||||
for i in "${!SINKS[@]}"; do
|
||||
if [[ "${SINKS[$i]}" == "$CURRENT_SINK" ]]; then
|
||||
NEXT_INDEX=$(( (i + 1) % NUM_SINKS ))
|
||||
pactl set-default-sink "${SINKS[$NEXT_INDEX]}"
|
||||
break
|
||||
fi
|
||||
done
|
31
waybar/scripts/disk_info.sh
Executable file
31
waybar/scripts/disk_info.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 <mountpoint>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MOUNTPOINT=$1
|
||||
|
||||
# Get disk usage info
|
||||
USED=$(df -h --output=used "$MOUNTPOINT" | sed '1d' | awk '{print $1}')
|
||||
TOTAL=$(df -h --output=size "$MOUNTPOINT" | sed '1d' | awk '{print $1}')
|
||||
PERCENTAGE=$(df --output=pcent "$MOUNTPOINT" | sed '1d' | tr -d '%' | awk '{print $1}')
|
||||
|
||||
# Set class based on usage
|
||||
CLASS="normal"
|
||||
if [ "$PERCENTAGE" -gt 95 ]; then
|
||||
CLASS="max"
|
||||
elif [ "$PERCENTAGE" -gt 80 ]; then
|
||||
CLASS="high"
|
||||
fi
|
||||
|
||||
# Create tooltip with more details
|
||||
TOOLTIP=$(df -h "$MOUNTPOINT" | sed '1d' | awk '{printf "Used: %s\nTotal: %s\nFree: %s", $3, $2, $4}')
|
||||
|
||||
# Output JSON for Waybar using jq
|
||||
jq -n -c \
|
||||
--arg text "$1 $USED/$TOTAL" \
|
||||
--arg tooltip "$TOOLTIP" \
|
||||
--arg class "$CLASS" \
|
||||
'{"text": $text, "tooltip": $tooltip, "class": $class}'
|
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
DEFAULT_SINK=$(pactl info | grep 'Default Sink' | cut -d ' ' -f3)
|
||||
DESCRIPTION=$(pactl list sinks | grep -A2 "Name: $DEFAULT_SINK" | grep "Description:" | cut -d ' ' -f2-)
|
||||
|
||||
if [ -z "$DESCRIPTION" ]; then
|
||||
DESCRIPTION=$DEFAULT_SINK
|
||||
fi
|
||||
|
||||
TEXT=$(echo "$DESCRIPTION" | cut -c -20)
|
||||
|
||||
printf '{"text": "%s", "tooltip": "%s"}
|
||||
' "$TEXT" "$DESCRIPTION"
|
@@ -6,7 +6,7 @@ EDGE_TEMP=$(cat /sys/class/drm/card1/device/hwmon/hwmon2/temp1_input)
|
||||
JUNC_TEMP=$(cat /sys/class/drm/card1/device/hwmon/hwmon2/temp2_input)
|
||||
MEM_TEMP=$(cat /sys/class/drm/card1/device/hwmon/hwmon2/temp3_input)
|
||||
GPU=$(/opt/rocm/bin/rocm-smi --showproductname | grep "Card Series" | awk -F':' '{print $3}' | xargs)
|
||||
TEXT="$USAGE% $(printf "%.1f" $(echo "scale=2; $MEM_USED/1024/1024/1024" | bc -l))/$(printf "%.1f" $(echo "scale=2; $MEM_TOTAL/1024/1024/1024" | bc -l))GB TEMP: $(printf "%.1f" $(echo "scale=2; $EDGE_TEMP/1000" | bc -l))/$(printf "%.1f" $(echo "scale=2; $JUNC_TEMP/1000" | bc -l))/$(printf "%.1f" $(echo "scale=2; $MEM_TEMP/1000" | bc -l))C"
|
||||
TEXT="$USAGE% $(printf "%.1f" $(echo "scale=2; $MEM_USED/1024/1024/1024" | bc -l))/$(printf "%.1f" $(echo "scale=2; $MEM_TOTAL/1024/1024/1024" | bc -l))GB $(printf "%.1f" $(echo "scale=2; $EDGE_TEMP/1000" | bc -l))/$(printf "%.1f" $(echo "scale=2; $MEM_TEMP/1000" | bc -l))C"
|
||||
RATIO=$(echo "$MEM_USED/ $MEM_TOTAL" | bc -l)
|
||||
|
||||
CLASS=""
|
||||
|
@@ -1,19 +0,0 @@
|
||||
#!/bin/bash
|
||||
USAGE=$(cat /sys/class/drm/card1/device/gpu_busy_percent)
|
||||
MEM_USED=$(cat /sys/class/drm/card1/device/mem_info_vram_used)
|
||||
MEM_TOTAL=$(cat /sys/class/drm/card1/device/mem_info_vram_total)
|
||||
GPU=$(/opt/rocm/bin/rocm-smi --showproductname | grep "Card Series" | awk -F':' '{print $3}' | xargs)
|
||||
TEXT="$USAGE% $(printf "%.2f\n" $(echo "scale=2; $MEM_USED/1024/1024/1024" | bc -l))/$(echo "scale=2; $MEM_TOTAL/1024/1024/1024" | bc -l)GB"
|
||||
RATIO=$(echo "$MEM_USED/ $MEM_TOTAL" | bc -l)
|
||||
|
||||
CLASS=""
|
||||
|
||||
if (( $(echo "$USAGE > 95" | bc -l) )); then
|
||||
CLASS="max_usage"
|
||||
elif (( $(echo "$USAGE > 75" | bc -l) )); then
|
||||
CLASS="high_usage"
|
||||
else
|
||||
CLASS="normal_usage"
|
||||
fi
|
||||
|
||||
echo "{\"text\":\"GPU: $TEXT\", \"tooltip\": \"$GPU\", \"class\":\"$CLASS\"}"
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
TOOLTIP=$(ps -eo rss,comm --sort=-rss | head -n 6 | sed '1d' | awk '{output = output sprintf("%.2f GB\t%s\\n", $1/1024/1024, $2)} END {printf "%s", output}')
|
||||
# TOOLTIP=$(ps -eo rss,comm --sort=-rss | head -n 6 | sed '1d' | awk '{output = output sprintf("%.2f GB\t%s\\n", $1/1024/1024, $2)} END {printf "%s", output}')
|
||||
TOTAL=$(awk '/MemTotal/ {printf "%.2f\n", $2/1024/1024}' /proc/meminfo)
|
||||
USED=$(awk '/MemTotal/ {total=$2} /MemAvailable/ {available=$2} END {printf "%.2f\n", (total-available)/1024/1024}' /proc/meminfo)
|
||||
RATIO=$(echo "$USED/ $TOTAL" | bc -l)
|
||||
@@ -15,4 +15,5 @@ else
|
||||
CLASS="normal"
|
||||
fi
|
||||
|
||||
printf '{"text": "MEM: %s/%sGB", "tooltip": "%s", "class": "%s"}' "$USED" "$TOTAL" "$TOOLTIP" "$CLASS"
|
||||
# printf '{"text": "%s/%sGB", "tooltip": "%s", "class": "%s"}' "$USED" "$TOTAL" "$TOOLTIP" "$CLASS"
|
||||
printf '{"text": "%s/%sGB", "class": "%s"}' "$USED" "$TOTAL" "$CLASS"
|
||||
|
@@ -1,73 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# --- CONFIGURATION ---
|
||||
# Your Pixel Buds Pro's MAC Address
|
||||
MAC_ADDRESS="B4:23:A2:09:D3:53"
|
||||
# --- END CONFIGURATION ---
|
||||
|
||||
# First, check if the device is connected using bluetoothctl.
|
||||
if bluetoothctl info "$MAC_ADDRESS" | grep -q "Connected: yes"; then
|
||||
# --- DEVICE IS CONNECTED ---
|
||||
|
||||
# This function gets the current ANC status and formats it for Waybar.
|
||||
get_status() {
|
||||
# Get the mode from pbpctrl. Redirect errors to null in case of a temporary glitch.
|
||||
current_mode=$(pbpctrl get anc 2>/dev/null)
|
||||
|
||||
# Fallback: If pbpctrl fails or returns 'unknown', hide the module.
|
||||
# This handles cases where buds are connected but not fully ready.
|
||||
if [[ $? -ne 0 || "$current_mode" == "unknown (0)"* || -z "$current_mode" ]]; then
|
||||
echo "{}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Set icon and tooltip based on the current mode.
|
||||
case "$current_mode" in
|
||||
"active")
|
||||
icon="ANC: Active"
|
||||
class="anc-active"
|
||||
;;
|
||||
"aware")
|
||||
icon="ANC: Aware"
|
||||
class="anc-aware"
|
||||
;;
|
||||
"off")
|
||||
icon="ANC: Off"
|
||||
class="anc-off"
|
||||
;;
|
||||
*)
|
||||
# Failsafe to hide the module if the mode is unrecognized.
|
||||
echo "{}"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
echo "{\"text\":\"$icon\", \"class\":\"$class\"}"
|
||||
}
|
||||
|
||||
# Handle click actions passed from Waybar.
|
||||
case "$1" in
|
||||
# Right-click: Cycle between active and aware modes.
|
||||
cycle)
|
||||
current_mode=$(pbpctrl get anc 2>/dev/null)
|
||||
if [[ "$current_mode" == "active" ]]; then
|
||||
pbpctrl set anc aware
|
||||
else
|
||||
pbpctrl set anc active
|
||||
fi
|
||||
sleep 0.1 # Brief pause for the state to update.
|
||||
;;
|
||||
# Left-click: Turn ANC off.
|
||||
off)
|
||||
pbpctrl set anc off
|
||||
sleep 0.1 # Brief pause for the state to update.
|
||||
;;
|
||||
esac
|
||||
|
||||
# Always display the current status after any action or on a scheduled interval.
|
||||
get_status
|
||||
|
||||
else
|
||||
# --- DEVICE IS NOT CONNECTED ---
|
||||
# Output an empty JSON object to completely hide the Waybar module.
|
||||
echo "{}"
|
||||
fi
|
@@ -1,49 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# --- CONFIGURATION ---
|
||||
# Your Pixel Buds Pro's MAC Address
|
||||
MAC_ADDRESS="B4:23:A2:09:D3:53"
|
||||
# --- END CONFIGURATION ---
|
||||
|
||||
# Check if the device is connected using bluetoothctl.
|
||||
if bluetoothctl info "$MAC_ADDRESS" | grep -q "Connected: yes"; then
|
||||
|
||||
# If connected, get battery info from pbpctrl.
|
||||
if battery_output=$(pbpctrl show battery); then
|
||||
# Use awk to grab the third field, which is the percentage or "unknown".
|
||||
left_bud=$(echo "$battery_output" | grep "left bud:" | awk '{print $3}')
|
||||
right_bud=$(echo "$battery_output" | grep "right bud:" | awk '{print $3}')
|
||||
|
||||
# If both buds are unknown (e.g., case is closed and buds are out of range),
|
||||
# or if the command output is empty, hide the module.
|
||||
if ([[ "$left_bud" == "unknown" ]] && [[ "$right_bud" == "unknown" ]]) || \
|
||||
[[ -z "$left_bud" && -z "$right_bud" ]]; then
|
||||
echo "{}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Prepare the display string for the left bud.
|
||||
if [[ "$left_bud" == "unknown" ]]; then
|
||||
left_display="L: ---"
|
||||
else
|
||||
left_display="L: $left_bud"
|
||||
fi
|
||||
|
||||
# Prepare the display string for the right bud.
|
||||
if [[ "$right_bud" == "unknown" ]]; then
|
||||
right_display="R: ---"
|
||||
else
|
||||
right_display="R: $right_bud"
|
||||
fi
|
||||
|
||||
# Format the final output for Waybar as JSON.
|
||||
printf '{"text": "%s | %s", "tooltip": "Pixel Buds Pro 2", "class": "connected"}\n' "$left_display" "$right_display"
|
||||
|
||||
else
|
||||
# pbpctrl failed to run, so hide the module.
|
||||
echo "{}"
|
||||
fi
|
||||
else
|
||||
# Not connected, output an empty JSON object to hide the module.
|
||||
echo "{}"
|
||||
fi
|
@@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
wlogout -p layer-shell
|
Reference in New Issue
Block a user