updated status bar

This commit is contained in:
2025-08-15 16:36:05 +02:00
parent 6a3de0df23
commit 1b88c5cc71
7 changed files with 443 additions and 268 deletions

View File

@@ -2,162 +2,15 @@
[{
"layer": "top",
"position": "top",
"output": "!eDP-1",
"height": 35,
"modules-left": ["hyprland/workspaces"],
"modules-center": [],
"modules-right": [
"wireplumber",
"custom/audio-output",
"network",
"cpu",
"memory",
"custom/tlp",
"tray",
"clock"
],
"hyprland/workspaces": {
"format": "{icon}",
"on-click": "activate"
},
"hyprland/window": {
"format": "{}",
"max-length": 35
},
"clock": {
"format": "{:%H:%M}",
"format-alt": "{:%a, %b %d}",
"on-click-right": "xdg-open https://calendar.proton.me/u/0/month &> /dev/null & disown"
},
"custom/gpu": {
"format": "GPU: {}%",
"exec": "~/.config/waybar/scripts/gpu_usage.sh",
"interval": 1,
"tooltip": true
},
"cpu": {
"format": "CPU: {usage}%",
"tooltip": true
},
"memory": {
"format": "MEM: {used}/{total}GB"
},
"network": {
"format-wifi": "{essid} ({signalStrength}%): {ipaddr}",
"format-ethernet": "{ifname}: {ipaddr}",
"format-disconnected": "Disconnected",
"tooltip-format": "{ifname} via {gwaddr}"
},
"wireplumber": {
"format": "{volume}% {icon}",
"format-muted": "Muted ",
"format-icons": {
"headphone": "",
"hands-free": "",
"default": ["", ""]
},
"on-click": "pavucontrol",
"scroll-step": 1
},
"pulseaudio": {
"format": "{icon} {volume}%",
"format-muted": " Muted",
"format-icons": {
"headphone": "",
"hands-free": "",
"headset": "",
"phone": "",
"portable": "",
"car": "",
"default": ["", ""]
},
"on-click": "pavucontrol"
},
"tray": {
"icon-size": 18,
"spacing": 10
},
"custom/power": {
"format": "",
"tooltip": false,
"on-click": "~/.config/hypr/scripts/powermenu.sh"
},
"custom/tlp": {
"format": "{}",
"exec": "~/.config/waybar/scripts/tlp-profile.sh",
"return-type": "json",
"interval": 5
},
"battery": {
"states": {
"warning": 30,
"critical": 15
},
"format": "{capacity}%",
"format-charging": "{capacity}%",
"format-plugged": "{capacity}%",
"format-alt": "{time} {icon}",
"format-full": "{capacity}%",
"format-icons": ["", "", "", "", ""]
},
"custom/pixelbuds": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/pixelbuds.sh",
"interval": 10,
"on-click": "bluetoothctl disconnect B4:23:A2:09:D3:53"
},
"custom/anc": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/anc_control.sh",
"interval": 10,
"on-click": "~/.config/waybar/scripts/anc_control.sh off",
"on-click-right": "~/.config/waybar/scripts/anc_control.sh cycle"
},
"custom/audio-output": {
"format": "{}",
"return-type": "json",
"exec": "/home/narl/.config/waybar/scripts/get_audio_output.sh",
"on-click": "/home/narl/.config/waybar/scripts/cycle_audio_output.sh",
"interval": 1
},
"custom/gamemode": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/gamemode_status.sh",
"on-click": "~/.config/hypr/scripts/gamemode.sh",
"interval": 1
},
"custom/gpu-screen-recorder": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/gpu-screen-recorder-status.sh",
"on-click-right": "~/.config/hypr/scripts/replay-ctrl.sh save",
"on-click": "~/.config/waybar/scripts/toggle-replay.sh",
"interval": 1
},
"custom/gpu-usage": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/gpu_usage.sh",
"interval": 5
}
},
{
"layer": "top",
"height": 35,
"output": "eDP-1",
"height": 40,
"modules-left": ["hyprland/workspaces"],
"modules-center": [],
"modules-right": [
"custom/bluetooth-audio",
"custom/pixelbuds_pro",
"wireplumber",
"custom/audio-output",
"custom/pixelbuds",
"custom/anc",
"network",
"cpu",
"memory",
@@ -166,6 +19,7 @@
"clock"
],
"hyprland/workspaces": {
"format": "{icon}",
"on-click": "activate"
@@ -175,9 +29,10 @@
"max-length": 35
},
"clock": {
"format": "{:%H:%M}",
"format-alt": "{:%a, %b %d}",
"on-click-right": "xdg-open https://calendar.proton.me/u/0/month &> /dev/null & disown"
"format": "{:%a %d %b %H:%M}",
"format-alt": false,
"on-click-right": "xdg-open https://calendar.proton.me/u/0/month &> /dev/null & disown",
"tooltip": false,
},
"custom/gpu": {
"format": "GPU: {}%",
@@ -210,6 +65,14 @@
"scroll-step": 1
},
"custom/bluetooth-audio": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/bluetooth_audio.sh",
"interval": 3,
"on-click": "~/.config/waybar/scripts/bluetooth_audio.sh disconnect"
},
"pulseaudio": {
"format": "{icon} {volume}%",
"format-muted": " Muted",
@@ -251,20 +114,13 @@
"format-full": "{capacity}%",
"format-icons": ["", "", "", "", ""]
},
"custom/pixelbuds": {
"custom/pixelbuds_pro": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/pixelbuds.sh",
"interval": 10,
"on-click": "bluetoothctl disconnect B4:23:A2:09:D3:53"
},
"custom/anc": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/anc_control.sh",
"interval": 10,
"on-click": "~/.config/waybar/scripts/anc_control.sh off",
"on-click-right": "~/.config/waybar/scripts/anc_control.sh cycle"
"exec": "~/.config/waybar/scripts/pixelbuds_pro_control.sh",
"interval": 5,
"on-click-right": "~/.config/waybar/scripts/pixelbuds_pro_control.sh connect",
"on-click": "~/.config/waybar/scripts/pixelbuds_pro_control.sh cycle_anc"
},
"custom/audio-output": {
"format": "{}",
@@ -294,7 +150,155 @@
"exec": "~/.config/waybar/scripts/gpu_usage.sh",
"interval": 5
}
},{
"layer": "top",
"position": "top",
"output": "!eDP-1",
"height": 40,
"modules-left": ["hyprland/workspaces"],
"modules-center": [],
"modules-right": [
"custom/bluetooth-audio",
// "custom/pixelbuds_pro",
"wireplumber",
"custom/audio-output",
"network",
"cpu",
"memory",
"custom/tlp",
"tray",
"clock"
],
"hyprland/workspaces": {
"format": "{icon}",
"on-click": "activate"
},
"hyprland/window": {
"format": "{}",
"max-length": 35
},
"clock": {
"format": "{:%a %d %b %H:%M}",
"format-alt": false,
"on-click-right": "xdg-open https://calendar.proton.me/u/0/month &> /dev/null & disown",
"tooltip": false,
},
"custom/gpu": {
"format": "GPU: {}%",
"exec": "~/.config/waybar/scripts/gpu_usage.sh",
"interval": 1,
"tooltip": true
},
"cpu": {
"format": "CPU: {usage}%",
"tooltip": true
},
"memory": {
"format": "MEM: {used}/{total}GB"
},
"network": {
"format-wifi": "{essid} ({signalStrength}%): {ipaddr}",
"format-ethernet": "{ifname}: {ipaddr}",
"format-disconnected": "Disconnected",
"tooltip-format": "{ifname} via {gwaddr}"
},
"wireplumber": {
"format": "{volume}% {icon}",
"format-muted": "Muted ",
"format-icons": {
"headphone": "",
"hands-free": "",
"default": ["", ""]
},
"on-click": "pavucontrol",
"scroll-step": 1
},
"custom/bluetooth-audio": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/bluetooth_audio.sh",
"interval": 3,
"on-click": "~/.config/waybar/scripts/bluetooth_audio.sh disconnect"
},
"pulseaudio": {
"format": "{icon} {volume}%",
"format-muted": " Muted",
"format-icons": {
"headphone": "",
"hands-free": "",
"headset": "",
"phone": "",
"portable": "",
"car": "",
"default": ["", ""]
},
"on-click": "pavucontrol"
},
"tray": {
"icon-size": 18,
"spacing": 10
},
"custom/power": {
"format": "",
"tooltip": false,
"on-click": "~/.config/hypr/scripts/powermenu.sh"
},
"custom/tlp": {
"format": "{}",
"exec": "~/.config/waybar/scripts/tlp-profile.sh",
"return-type": "json",
"interval": 5
},
"battery": {
"states": {
"warning": 30,
"critical": 15
},
"format": "{capacity}%",
"format-charging": "{capacity}%",
"format-plugged": "{capacity}%",
"format-alt": "{time} {icon}",
"format-full": "{capacity}%",
"format-icons": ["", "", "", "", ""]
},
"custom/pixelbuds_pro": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/pixelbuds_pro_control.sh",
"interval": 5,
"on-click-right": "~/.config/waybar/scripts/pixelbuds_pro_control.sh connect",
"on-click": "~/.config/waybar/scripts/pixelbuds_pro_control.sh cycle_anc"
},
"custom/audio-output": {
"format": "{}",
"return-type": "json",
"exec": "/home/narl/.config/waybar/scripts/get_audio_output.sh",
"on-click": "/home/narl/.config/waybar/scripts/cycle_audio_output.sh",
"interval": 1
},
"custom/gamemode": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/gamemode_status.sh",
"on-click": "~/.config/hypr/scripts/gamemode.sh",
"interval": 1
},
"custom/gpu-screen-recorder": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/gpu-screen-recorder-status.sh",
"on-click-right": "~/.config/hypr/scripts/replay-ctrl.sh save",
"on-click": "~/.config/waybar/scripts/toggle-replay.sh",
"interval": 1
},
"custom/gpu-usage": {
"format": "{}",
"return-type": "json",
"exec": "~/.config/waybar/scripts/gpu_usage.sh",
"interval": 5
}
}]

118
waybar/scripts/bluetooth_audio.sh Executable file
View File

@@ -0,0 +1,118 @@
#!/bin/bash
bt-audio-info() {
# Check if a MAC address was provided as the first argument.
if [ -z "$1" ]; then
echo "Usage: $0 <MAC_ADDRESS>"
echo "Example: $0 00:11:22:33:AA:BB"
exit 1
fi
MAC_ADDRESS="$1"
# --- Main Logic ---
# Construct the PipeWire sink name from the MAC address.
# The format is typically: bluez_output.XX_XX_XX_XX_XX_XX.a2dp_sink
# We replace colons with underscores for the format.
SINK_IDENTIFIER="bluez_output.$(echo "$MAC_ADDRESS" | tr ':' '_')"
# Use pactl to get the full details for all sinks, then find the one
# that contains our device's identifier. We use awk to print the
# entire block of text for that specific sink.
# We check for a partial match on the sink identifier because the profile
# (e.g., .a2dp_sink) can change.
sink_info=$(pactl list sinks | awk -v id="$SINK_IDENTIFIER" '/Sink #/ {p=0} $0 ~ "Name: " id {p=1} p')
# If sink_info is empty, the device might not be an audio sink or isn't connected.
if [ -z "$sink_info" ]; then
echo "Error: Could not find an active audio sink for MAC ${MAC_ADDRESS}"
echo "Please ensure the device is connected and is an audio output device."
exit 1
fi
# Get the full block of info for the device from bluetoothctl.
device_info=$(bluetoothctl info "$MAC_ADDRESS")
# --- Parse Information ---
# Parse bluetoothctl output for general device details.
alias=$(echo "$device_info" | rg "Alias:" | cut -d ' ' -f 2-)
trusted=$(echo "$device_info" | rg "Trusted:" | awk '{print $2}')
battery_raw=$(echo "$device_info" | rg "Battery Percentage:" | awk -F'[()]' '{print $2}')
# Parse pactl output for audio-specific details.
volume=$(echo "$sink_info" | rg "Volume:" | head -n1 | awk '{print $5}')
codec=$(echo "$sink_info" | rg -e 'bluetooth.codec|api.bluez5.codec' | awk -F'"' '{print $2}')
# --- Build and Display Compact Output ---
# Build the output string with all the information.
output_string="${alias} | MAC: ${MAC_ADDRESS}\n"
output_string+="Trusted: ${trusted}"
# Append battery info if available, otherwise show N/A.
if [ -n "$battery_raw" ]; then
output_string+=" | Bat: ${battery_raw}%"
else
output_string+=" | Bat: N/A"
fi
output_string+=" | Vol: ${volume} | Codec: ${codec:-N/A}"
# Print the final, single-line string.
echo "$output_string"
}
# Find the MAC address of the first connected device that is an audio sink
find_audio_device() {
default_sink_name=$(pactl get-default-sink)
# Check if the default sink is a Bluetooth device. Their names typically
# start with "bluez_output.". If not, print a message and exit.
if [[ "$default_sink_name" == bluez_output* ]]; then
# Extract the MAC address from the sink name.
# The format is bluez_output.XX_XX_XX_XX_XX_XX.profile
# We extract the middle part and replace underscores with colons.
mac_with_underscores=$(echo "$default_sink_name" | cut -d '.' -f 2)
mac=$(echo "$mac_with_underscores" | tr '_' ':')
echo "$mac"
return
fi
# else look for the first bluetooth device that provides a sink
bluetoothctl devices Connected | rg '^Device ' | awk '{print $2}' | while read -r mac;
do
# Check if the device provides the "Audio Sink" service
if bluetoothctl info "$mac" | rg -q "0000110b-0000-1000-8000-00805f9b34fb"; then
echo "$mac"
# If you only want the first audio device found, you can 'break' or 'exit' here.
break
fi
done
}
# If the script is called with "disconnect"
if [ "$1" == "disconnect" ]; then
device_mac=$(find_audio_device)
if [ -n "$device_mac" ]; then
bluetoothctl disconnect "$device_mac"
fi
echo "{}"
exit 0
fi
# Main logic to display the device name
device_mac=$(find_audio_device)
if [ -n "$device_mac" ]; then
# Get the device alias (name)
device_name=$(bluetoothctl info "$device_mac" | rg "Alias:" | cut -d ' ' -f 2-)
# Output in Waybar's JSON format
tooltip=$(bt-audio-info $device_mac)
echo "{\"text\": \"$device_name <span size='large'>󰂰</span>\", \"tooltip\": \"$tooltip\"}"
else
# Output empty string when no device is connected
echo "{}"
fi

View File

@@ -0,0 +1,113 @@
#!/bin/bash
# --- CONFIGURATION ---
# Your Pixel Buds Pro's MAC Address
MAC_ADDRESS="B4:23:A2:09:D3:53"
# --- END CONFIGURATION ---
not_connected() {
printf '{"text": "L: --- | R: --- | Off", "tooltip": "Pixel Buds Pro 2", "class": "disconnected"}\n'
exit 0
}
status() {
# 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 status and formats it for Waybar.
get_status() {
# Get all info from pbpctrl in one go. Redirect errors to null.
battery_output=$(pbpctrl show battery 2>/dev/null)
# Fallback: If pbpctrl fails or returns 'unknown', hide the module.
if [[ $? -ne 0 || -z "$battery_output" ]]; then
not_connected
fi
# --- PARSE BATTERY INFO ---
left_bud=$(echo "$battery_output" | grep "left bud:" | awk '{print $3}')
right_bud=$(echo "$battery_output" | grep "right bud:" | awk '{print $3}')
if ([[ "$left_bud" == "unknown" ]] && [[ "$right_bud" == "unknown" ]]) || \
[[ -z "$left_bud" && -z "$right_bud" ]]; then
echo "{}"
exit 0
fi
if [[ "$left_bud" == "unknown" ]]; then
left_display="L: ---"
else
left_display="L: $left_bud"
fi
if [[ "$right_bud" == "unknown" ]]; then
right_display="R: ---"
else
right_display="R: $right_bud"
fi
# --- PARSE ANC INFO ---
current_mode=$(pbpctrl get anc 2>/dev/null)
case "$current_mode" in
"active")
anc_icon="ANC"
class="anc-active"
;;
"aware")
anc_icon="Aware"
class="anc-aware"
;;
"off")
anc_icon="Off"
class="anc-off"
;;
*)
anc_icon="?"
class="anc-unknown"
;;
esac
# --- FORMAT OUTPUT ---
printf '{"text": "%s | %s | %s", "tooltip": "Pixel Buds Pro 2", "class": "%s"}\n' \
"$left_display" "$right_display" "$anc_icon" "$class"
}
get_status
else
# --- DEVICE IS NOT CONNECTED ---
not_connected
fi
}
# Handle click actions passed from Waybar.
case "$1" in
cycle_anc)
current_mode=$(pbpctrl get anc 2>/dev/null)
next_mode=""
case "$current_mode" in
active)
next_mode="aware"
;;
aware)
next_mode="off"
;;
off)
next_mode="active"
;;
esac
pbpctrl set anc "$next_mode"
sleep 0.1
;;
connect)
bluetoothctl connect "$MAC_ADDRESS" & disown
;;
disconnect)
bluetoothctl disconnect "$MAC_ADDRESS" & disown
;;
*)
status
;;
esac

View File

@@ -1,54 +0,0 @@
#!/bin/bash
# Script to manage and display system76-power profiles for Waybar
# Define the available power profiles
PROFILES=("Performance" "Balanced" "Battery")
# Get the current power profile
CURRENT_PROFILE=$(system76-power profile | awk '/Power Profile/ {print $3}')
# Function to switch to the next profile
switch_next_profile() {
# Find the index of the current profile
for i in "${!PROFILES[@]}"; do
if [[ "${PROFILES[$i]}" == "$CURRENT_PROFILE" ]]; then
current_index=$i
break
fi
done
# Calculate the index of the next profile
next_index=$(((current_index + 1) % ${#PROFILES[@]}))
NEXT_PROFILE=${PROFILES[$next_index]}
# Switch to the next profile
system76-power profile "$NEXT_PROFILE"
}
# If the script is called with "next", switch the profile
if [[ "$1" == "next" ]]; then
switch_next_profile
# After switching, get the new current profile
CURRENT_PROFILE=$(system76-power profile | awk '/Power Profile/ {print $3}')
fi
# Set an icon based on the current profile
case $CURRENT_PROFILE in
"Performance")
ICON="🚀"
;;
"Balanced")
ICON="⚖️"
;;
"Battery")
ICON="🔋"
;;
*)
ICON="❓"
;;
esac
# Output in JSON format for Waybar
printf '{"text": "%s", "tooltip": "Power Profile: %s", "class": "%s"}\n' "$ICON" "$CURRENT_PROFILE" "$(echo $CURRENT_PROFILE | tr '[:upper:]' '[:lower:]')"

View File

@@ -51,4 +51,4 @@ else # Fallback for "fully-charged", "pending-charge", etc.
fi
# Output JSON for Waybar
printf '{"text": "%s %s%%", "tooltip": "%s", "class": "%s"}\n' "$icon" "$percentage" "$tooltip" "$class"
printf '{"text": "%s%% %s", "tooltip": "%s", "class": "%s"}\n' "$percentage" "$icon" "$tooltip" "$class"

View File

@@ -10,7 +10,7 @@
}
window#waybar {
background-color: alpha(@base, 0.6);
background-color: alpha(@base, 0.4);
padding: 10px;
transition-property: background-color;
transition-duration: 0.5s;
@@ -33,20 +33,21 @@ window#waybar.hidden {
/* Use box-shadow instead of border so the text isn't offset */
padding: 6px 18px;
margin: 6px 3px;
border-radius: 3px;
background-color: alpha(@base, 0.9);
color: @text;
border-radius: 4px;
background-color: @base;
color: @subtext0;
}
#workspaces button.active {
border-bottom: 3px solid @green;
color: @text;
border-bottom: 3px solid @teal;
}
#workspaces button:hover {
box-shadow: inherit;
text-shadow: inherit;
background-color: @teal;
color: @base;
background-color: @surface0;
color: @text;
}
#workspaces button.urgent {
@@ -65,39 +66,40 @@ window#waybar.hidden {
#network,
#clock,
#tray,
#custom-pixelbuds,
#custom-anc,
#custom-pixelbuds_pro,
#custom-bluetooth-audio,
#custom-audio-output,
#custom-gpu-screen-recorder {
border-radius: 4px;
margin: 6px 3px;
padding: 6px 16px 6px 12px;
padding: 6px 12px;
background-color: @base;
color: @text;
}
#custom-anc.anc-active {
color: @teal;
border-bottom: 3px solid @teal;
#custom-pixelbuds_pro.anc-active {
color: @sapphire;
border-bottom: 3px solid @sapphire;
}
#custom-anc.anc-aware {
color: @yellow;
border-bottom: 3px solid @yellow;
#custom-bluetooth-audio {
color: @sapphire;
border-bottom: 3px solid @sapphire;
}
#custom-anc.anc-off {
#custom-pixelbuds_pro.anc-aware {
color: @sapphire;
border-bottom: 3px solid @sapphire;
}
#custom-pixelbuds_pro.anc-off {
color: @text;
border-bottom: 3px solid @text;
}
#custom-anc.disconnected {
}
#custom-gpu-screen-recorder,
#custom-gamemode {
color: @teal;
border-bottom: 3px solid @teal;
}
#custom-power {
@@ -107,7 +109,6 @@ window#waybar.hidden {
#custom-gpu-screen-recorder.recording,
#custom-gamemode.active {
color: @red;
border-bottom: 3px solid @red;
}
#custom-tlp {
@@ -150,19 +151,22 @@ window#waybar.hidden {
#custom-gpu-usage.max_usage {
color: @maroon;
/* border-bottom: 3px solid @maroon; */
}
#custom-gpu-usage.high_usage {
color: @yellow;
/* border-bottom: 3px solid @yellow; */
}
#custom-gpu-usage.normal_usage {
color: @teal;
/* border-bottom: 3px solid @teal; */
}
#memory,
#cpu {
color: @teal;
#memory, #cpu, #network {
color: @mauve;
border-bottom: 3px solid @mauve;
}
@@ -171,25 +175,20 @@ window#waybar.hidden {
}
#wireplumber {
color: @mauve;
padding-right: 15px;
border-bottom: 3px solid @mauve;
}
#custom-audio-output {
color: @mauve;
border-bottom: 3px solid @mauve;
#custom-audio-output, #wireplumber {
color: @teal;
border-bottom: 3px solid @teal;
}
#network {
color: @mauve;
padding-right: 15px;
}
#clock {
font-family: JetBrainsMono Nerd Font;
color: @green;
border-bottom: 3px solid @green;
color: @teal;
}
tooltip {
@@ -202,8 +201,3 @@ tooltip label {
padding: 5px;
background-color: @base;
}
#custom-pixelbuds.connected {
color: @teal; /* A pleasant green */
border-bottom: 3px solid @teal;
}