From e814d79f0dca2981f442dbe8e58f1ca0d793731e Mon Sep 17 00:00:00 2001 From: retrilzzy Date: Thu, 25 Dec 2025 21:49:11 +0500 Subject: [PATCH] Update Waybar config and styles, refactor scripts - Restructure Waybar configuration - Update CSS styles for better appearance - Refactor helper scripts --- Configs/.config/bin/cpu-usage.sh | 10 ---- Configs/.config/bin/idle-inhibitor.sh | 4 +- Configs/.config/bin/mic-control.sh | 51 ++++++++++++++++ Configs/.config/bin/volume-control.sh | 85 +++++---------------------- Configs/.config/waybar/config.jsonc | 57 +++++++++++------- Configs/.config/waybar/styles.css | 22 +++---- 6 files changed, 117 insertions(+), 112 deletions(-) create mode 100755 Configs/.config/bin/mic-control.sh diff --git a/Configs/.config/bin/cpu-usage.sh b/Configs/.config/bin/cpu-usage.sh index 6f1dea2..50a773a 100755 --- a/Configs/.config/bin/cpu-usage.sh +++ b/Configs/.config/bin/cpu-usage.sh @@ -6,17 +6,7 @@ model=$(awk -F ': ' '/model name/{print $2}' /proc/cpuinfo | head -n 1 | sed 's/ # Get CPU usage percentage load=$(vmstat 1 2 | tail -1 | awk '{print 100 - $15}') -# Determine CPU state based on usage -if [ "$load" -le 25 ]; then - state="Low" -elif [ "$load" -le 50 ]; then - state="Medium" -else - state="High" -fi - tooltip="${model}" -tooltip+="\nCPU Usage: ${state}" # Module and tooltip echo "{\"text\": \"󰻠 ${load}%\", \"tooltip\": \"${tooltip}\"}" diff --git a/Configs/.config/bin/idle-inhibitor.sh b/Configs/.config/bin/idle-inhibitor.sh index 0c143b4..3d55954 100755 --- a/Configs/.config/bin/idle-inhibitor.sh +++ b/Configs/.config/bin/idle-inhibitor.sh @@ -14,9 +14,9 @@ toggle() { status_json() { if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then - echo '{"text":" ","tooltip":"Idle Inhibitor: On"}' + echo '{"tooltip":"Idle Inhibitor: On"}' else - echo '{"text":" ","tooltip":"Idle Inhibitor: Off"}' + echo '{"tooltip":"Idle Inhibitor: Off"}' fi } diff --git a/Configs/.config/bin/mic-control.sh b/Configs/.config/bin/mic-control.sh new file mode 100755 index 0000000..69c7fb9 --- /dev/null +++ b/Configs/.config/bin/mic-control.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Display usage help +print_error() { + cat <<"EOF" +Usage: ./mic-control.sh +Actions: + i -- increase sensitivity [+1%] + d -- decrease sensitivity [-1%] + m -- toggle mute +EOF + exit 1 +} + +# Send notification for mute status +notify_mute() { + mute=$(pactl get-source-mute @DEFAULT_SOURCE@ | awk '{print $2}') + if [ "${mute}" = "yes" ]; then + notify-send "Microphone" "Muted" -i microphone-sensitivity-high-symbolic -t 1000 -r 91191 + else + notify-send "Microphone" "Unmuted" -i microphone-sensitivity-high-symbolic -t 1000 -r 91191 + fi +} + +# Handle sensitivity changes +action_volume() { + current_vol=$(pactl get-source-volume @DEFAULT_SOURCE@ | grep -m1 'Volume:' | awk '{print $5}' | sed 's/%//') + + case "${1}" in + i) + if [ "$current_vol" -lt 100 ]; then + new_vol=$((current_vol + 1)) + [ "$new_vol" -gt 100 ] && new_vol=100 + pactl set-source-volume @DEFAULT_SOURCE@ "${new_vol}%" + fi + ;; + d) + new_vol=$((current_vol - 1)) + [ "$new_vol" -lt 0 ] && new_vol=0 + pactl set-source-volume @DEFAULT_SOURCE@ "${new_vol}%" + ;; + esac +} + +# Main execution +case "${1}" in +i) action_volume i ;; +d) action_volume d ;; +m) pactl set-source-mute @DEFAULT_SOURCE@ toggle && notify_mute ;; +*) print_error ;; +esac diff --git a/Configs/.config/bin/volume-control.sh b/Configs/.config/bin/volume-control.sh index d7d45b0..974c55b 100755 --- a/Configs/.config/bin/volume-control.sh +++ b/Configs/.config/bin/volume-control.sh @@ -1,104 +1,51 @@ #!/bin/bash -# Define functions +# Display usage help print_error() { cat <<"EOF" -Usage: ./volume-control.sh -[device] -...valid devices are... - i -- input device - o -- output device - p -- player application -...valid actions are... - i -- increase volume [+5] - d -- decrease volume [-5] - m -- mute [x] +Usage: ./volume-control.sh +Actions: + i -- increase volume [+5%] + d -- decrease volume [-5%] + m -- toggle mute EOF exit 1 } +# Send notification for mute status notify_mute() { mute=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}') if [ "${mute}" = "yes" ]; then - notify-send -r 91190 "Volume" "Muted" + notify-send "Volume" "Muted" -i audio-volume-muted-symbolic -t 1000 -r 91190 else - notify-send -r 91190 "Volume" "Unmuted" + notify-send "Volume" "Unmuted" -i audio-volume-muted-symbolic -t 1000 -r 91190 fi } +# Handle volume changes action_volume() { + current_vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -m1 'Volume:' | awk '{print $5}' | sed 's/%//') + case "${1}" in i) - # Check current volume and increase only if below 100 - current_vol=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | sed 's/%//') if [ "$current_vol" -lt 100 ]; then new_vol=$((current_vol + 5)) - if [ "$new_vol" -gt 100 ]; then - new_vol=100 - fi + [ "$new_vol" -gt 100 ] && new_vol=100 pactl set-sink-volume @DEFAULT_SINK@ "${new_vol}%" fi ;; d) - # Decrease volume, ensuring it doesn't drop below 0% - current_vol=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | sed 's/%//') new_vol=$((current_vol - 5)) - if [ "$new_vol" -lt 0 ]; then - new_vol=0 - fi + [ "$new_vol" -lt 0 ] && new_vol=0 pactl set-sink-volume @DEFAULT_SINK@ "${new_vol}%" ;; esac } -select_output() { - if [ "$@" ]; then - desc="$*" - device=$(pactl list sinks | grep -C2 -F "Description: $desc" | grep Name | cut -d: -f2 | xargs) - if pactl set-default-sink "$device"; then - notify-send -r 91190 "Activated: $desc" - else - notify-send -r 91190 "Error activating $desc" - fi - else - pactl list sinks | grep -ie "Description:" | awk -F ': ' '{print $2}' | sort - fi -} - -# Evaluate device option -while getopts iops: DeviceOpt; do - case "${DeviceOpt}" in - i) - nsink=$(pactl list sources short | awk '{print $2}') - [ -z "${nsink}" ] && echo "ERROR: Input device not found..." && exit 0 - srce="--default-source" - ;; - o) - nsink=$(pactl list sinks short | awk '{print $2}') - [ -z "${nsink}" ] && echo "ERROR: Output device not found..." && exit 0 - srce="" - ;; - p) - nsink=$(playerctl --list-all | grep -w "${OPTARG}") - [ -z "${nsink}" ] && echo "ERROR: Player ${OPTARG} not active..." && exit 0 - # shellcheck disable=SC2034 - srce="${nsink}" - ;; - s) - # Select an output device - select_output "$@" - exit - ;; - *) print_error ;; - esac -done - -# Set default variables -shift $((OPTIND - 1)) - -# Execute action +# Main execution case "${1}" in i) action_volume i ;; d) action_volume d ;; -m) pactl set-sink-mute @DEFAULT_SINK@ toggle && notify_mute && exit 0 ;; +m) pactl set-sink-mute @DEFAULT_SINK@ toggle && notify_mute ;; *) print_error ;; esac diff --git a/Configs/.config/waybar/config.jsonc b/Configs/.config/waybar/config.jsonc index e64591e..bd37af6 100644 --- a/Configs/.config/waybar/config.jsonc +++ b/Configs/.config/waybar/config.jsonc @@ -7,7 +7,6 @@ "gtk-layer-shell": true, "reload_style_on_change": true, - // Positions "modules-left": [ "custom/idle_inhibitor", @@ -29,6 +28,7 @@ "privacy", "hyprland/language", // language indicator "pulseaudio", + "pulseaudio#microphone", "custom/backlight", "power-profiles-daemon", "battery", @@ -38,6 +38,7 @@ // Left modules "custom/idle_inhibitor": { + "format": "󰣇", "exec": "~/.config/bin/idle-inhibitor.sh", "on-click": "~/.config/bin/idle-inhibitor.sh --toggle", "return-type": "json", @@ -48,36 +49,31 @@ }, "hyprland/workspaces": { - "all-outputs": false, - "active-only": false, - "on-click": "activate", "disable-scroll": false, + "tooltip": false, "on-scroll-up": "hyprctl dispatch workspace -1", "on-scroll-down": "hyprctl dispatch workspace +1", + "sort-by-number": true, "persistent-workspaces": { - "1": [ ], - "2": [ ], - "3": [ ], - "4": [ ], - "5": [ ] - }, - "sort-by-number": true + "*": [ 1, 2, 3 ] + } }, "hyprland/window": { "format": "{}", + "tooltip": false, "separate-outputs": true, "icon": true, "icon-size": 14, "rewrite": { // Desktop - "": " Hyprland", + "": " Hyprland", // Security "Authenticate": " Authenticate" }, "min-length": 3, - "max-length": 50 + "max-length": 55 }, @@ -85,6 +81,7 @@ "custom/cpu": { "exec": "~/.config/bin/cpu-usage.sh", "return-type": "json", + "on-click": "missioncenter", "tooltip": true, "interval": 5, "min-length": 6, @@ -94,6 +91,7 @@ "exec": "~/.config/bin/cpu-info.sh", "return-type": "json", "format": "{}", + "on-click": "psensor", "tooltip": true, "interval": 5, "min-length": 6, @@ -105,10 +103,11 @@ "c": 90 }, "format": "󰘚 {percentage}%", - "format-c": "󰀪 {percentage}%", + "format-c": "󰀪 {percentage}%", "tooltip": true, "tooltip-format": "Memory Used: {used:0.1f} GB / {total:0.1f} GB", "interval": 5, + "on-click": "kitty sh -c btop", "min-length": 6, "max-length": 6 }, @@ -116,6 +115,7 @@ "clock#time": { "format": "󱑂 {:%H:%M}", "tooltip": true, + "on-click": "gnome-clocks", "tooltip-format": "12-hour Format: {:%I:%M %p}", "min-length": 7, "max-length": 7 @@ -137,6 +137,7 @@ "on-scroll-up": "shift_up", "on-scroll-down": "shift_down" }, + "on-click": "gnome-calendar", "min-length": 7, "max-length": 7 }, @@ -152,6 +153,7 @@ "tooltip-format": " {ifname} \n {bandwidthUpBytes}  {bandwidthDownBytes}", "tooltip-format-wifi": "󰖩 {essid} ({signalStrength}%) \n {bandwidthUpBytes}  {bandwidthDownBytes}", "tooltip-format-disconnected": "Disconnected", + "on-click-right": "portmaster", "max-length": 24 }, @@ -206,15 +208,30 @@ ] }, "tooltip": true, - "tooltip-format": "Device: {desc}", - "on-click": "~/.config/bin/volume-control.sh -o m", + "tooltip-format": "{desc} - {volume}%", + "on-click": "~/.config/bin/volume-control.sh m", "on-click-right": "pavucontrol", - "on-scroll-up": "~/.config/bin/volume-control.sh -o i", - "on-scroll-down": "~/.config/bin/volume-control.sh -o d", + "on-scroll-up": "~/.config/bin/volume-control.sh i", + "on-scroll-down": "~/.config/bin/volume-control.sh d", "min-length": 6, "max-length": 6 }, + "pulseaudio#microphone": { + "format": "{format_source}", + "rotate": 0, + "format-source": "󰍬", + "format-source-muted": "󰍭", + "tooltip": true, + "tooltip-format": "{source_desc} - {source_volume}%", + "on-click": "~/.config/bin/mic-control.sh m", + "on-click-right": "easyeffects", + "on-scroll-up": "~/.config/bin/mic-control.sh i", + "on-scroll-down": "~/.config/bin/mic-control.sh d", + "min-length": 2, + "max-length": 2 + }, + "custom/backlight": { "exec": "~/.config/bin/brightness-control.sh", "return-type": "json", @@ -237,8 +254,8 @@ "balanced": "", "power-saver": "" }, - "min-length": 1, - "max-length": 1 + "min-length": 2, + "max-length": 2 }, "battery": { diff --git a/Configs/.config/waybar/styles.css b/Configs/.config/waybar/styles.css index d1c1b61..115a673 100644 --- a/Configs/.config/waybar/styles.css +++ b/Configs/.config/waybar/styles.css @@ -4,7 +4,7 @@ * { border: none; font-family: "JetBrainsMono Nerd Font"; - font-weight: bold; + font-weight: 700; font-size: 14px; color: @foreground; } @@ -14,8 +14,8 @@ window#waybar { } window#waybar > box { - margin: 5px 6px 0 6px; - padding: 2px 0; + margin: 7px 6px 0 6px; + padding: 1px 0; background-color: @background; border-radius: 15px; border: 2px solid @selected; @@ -50,17 +50,19 @@ tooltip { #battery, #custom-power { opacity: 1; - padding: 0px 3px; + padding: 0px 2px; margin: 0px 3px; } /* -- Left Modules -- */ /* Idle Inhibitor */ #custom-idle_inhibitor { - padding: 0 7px 0 2px; + padding-left: 2px; + padding-right: 5px; margin-left: 6px; margin-right: 0; border-radius: 4px; + font-size: 16px; } #custom-idle_inhibitor:hover { @@ -83,8 +85,7 @@ tooltip { /* Active Workspace Button */ #workspaces button.active { background: @active; - margin-right: 2px; - margin-left: 2px; + margin: 2px 2px; padding: 0 5px; animation: ws_active 20s ease-in-out 1; transition: all 0.4s cubic-bezier(0.55, -0.68, 0.48, 1.682); @@ -110,7 +111,6 @@ tooltip { /* Tray */ #tray { padding: 0 6px; - background: @background; } #tray menu { @@ -149,10 +149,10 @@ tooltip { /* Power Button */ #custom-power { - padding-left: 3px; - padding-right: 5px; - border-radius: 4px; + padding-left: 4px; + padding-right: 6px; margin-right: 6px; + border-radius: 4px; } #custom-power:hover {