{ config, pkgs, ... }:
{
home.file.".config/waybar/scripts/asus-profile.sh".text = ''
#!/bin/bash
# ── asus-profile.sh ───────────────────────────────────────
# Description: Display current ASUS power profile with color
# Usage: Called by Waybar `custom/asus-profile`
# Dependencies: asusctl, awk
# ──────────────────────────────────────────────────────────
profile=$(asusctl profile -p | awk '/Active profile/ {print $NF}')
case "$profile" in
Performance)
text="RAZGON"
fg="#bf616a"
;;
Balanced)
text="STABILIZATION"
fg="#fab387"
;;
Quiet)
text="REACTOR SLEEP"
fg="#56b6c2"
;;
*)
text="ASUS ??"
fg="#ffffff"
;;
esac
echo "$text"
'';
home.file.".config/waybar/scripts/battery.sh".text = ''
#!/bin/bash
# ── battery.sh ─────────────────────────────────────────────
# Description: Shows battery % with ASCII bar + dynamic tooltip
# Usage: Waybar `custom/battery` every 10s
# Dependencies: upower, awk, seq, printf
# ──────────────────────────────────────────────────────────
capacity=$(cat /sys/class/power_supply/BAT0/capacity)
status=$(cat /sys/class/power_supply/BAT0/status)
# Get detailed info from upower
time_to_empty=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | awk -F: '/time to empty/ {print $2}' | xargs)
time_to_full=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | awk -F: '/time to full/ {print $2}' | xargs)
# Icons
charging_icons=( )
default_icons=( )
index=$((capacity / 10))
[ $index -ge 10 ] && index=9
if [[ "$status" == "Charging" ]]; then
icon=${charging_icons[$index]}
elif [[ "$status" == "Full" ]]; then
icon=""
else
icon=${default_icons[$index]}
fi
# ASCII bar
filled=$((capacity / 10))
empty=$((10 - filled))
bar=$(printf '█%.0s' $(seq 1 $filled))
pad=$(printf '░%.0s' $(seq 1 $empty))
ascii_bar="[$bar$pad]"
# Color thresholds
if [ "$capacity" -lt 20 ]; then
fg="#bf616a" # red
elif [ "$capacity" -lt 55 ]; then
fg="#fab387" # orange
else
fg="#56b6c2" # cyan
fi
# JSON output
echo "{\"text\":\"$icon $ascii_bar $capacity%\",\"tooltip\":\"$tooltip\"}"
'';
home.file.".config/waybar/scripts/bluetooth-toggle.sh".text = ''
#!/bin/bash
# ── bluetooth-toggle.sh ──────────────────────────────────────────────────────
# Toggle Bluetooth on/off using rfkill.
# Usage: Waybar `bluetooth` module :on-click
# Output: (changes state only)
# ─────────────────────────────────────────────────────────────────────────────
if rfkill list bluetooth | grep -q "Soft blocked: yes"; then
rfkill unblock bluetooth
else
rfkill block bluetooth
fi
'';
home.file.".config/waybar/scripts/brightness.sh".text = ''
#!/bin/bash
# ── brightness.sh ─────────────────────────────────────────
# Description: Shows current brightness with ASCII bar + tooltip
# Usage: Waybar `custom/brightness` every 2s
# Dependencies: brightnessctl, seq, printf, awk
# ─────────────────────────────────────────────────────────
# Get brightness percentage
brightness=$(brightnessctl get)
max_brightness=$(brightnessctl max)
percent=$((brightness * 100 / max_brightness))
# Build ASCII bar
filled=$((percent / 10))
empty=$((10 - filled))
bar=$(printf '█%.0s' $(seq 1 $filled))
pad=$(printf '░%.0s' $(seq 1 $empty))
ascii_bar="[$bar$pad]"
# Icon
icon=""
# Color thresholds
if [ "$percent" -lt 20 ]; then
fg="#bf616a" # red
elif [ "$percent" -lt 55 ]; then
fg="#fab387" # orange
else
fg="#56b6c2" # cyan
fi
# Device name (first column from brightnessctl --machine-readable)
device=$(brightnessctl --machine-readable | awk -F, 'NR==1 {print $1}')
# Tooltip text
tooltip="Brightness: $percent%\nDevice: $device"
# JSON output
echo "{\"text\":\"$icon $ascii_bar $percent%\",\"tooltip\":\"$tooltip\"}"
'';
home.file.".config/waybar/scripts/brightness-toggle.sh".text = ''
#!/bin/bash
# ── brightness-toggle.sh ─────────────────────────────
# Description: Cycle screen brightness between 30%, 60%, and 100%
# Usage: Waybar `custom/brightness` on-click
# Dependencies: brightnessctl
# ─────────────────────────────────────────────────────
current=$(brightnessctl get)
max=$(brightnessctl max)
percent=$((current * 100 / max))
if [ "$percent" -lt 45 ]; then
brightnessctl set 60%
elif [ "$percent" -lt 85 ]; then
brightnessctl set 100%
else
brightnessctl set 30%
fi
'';
home.file.".config/waybar/scripts/mic.sh".text = ''
#!/bin/bash
# ── mic.sh ─────────────────────────────────────────────────
# Description: Shows microphone mute/unmute status with icon
# Usage: Called by Waybar `custom/microphone` module every 1s
# Dependencies: pactl (PulseAudio / PipeWire)
# ───────────────────────────────────────────────────────────
if pactl get-source-mute @DEFAULT_SOURCE@ | grep -q 'yes'; then
# Muted → mic-off icon
echo "[ ]"
else
# Active → mic-on icon
echo "[ ]"
fi
'';
home.file.".config/waybar/scripts/nordvpn-toggle.sh".text = ''
#!/bin/bash
# ── vpn-toggle.sh ─────────────────────────────────────────
# Description: Toggle VPN on/off via systemd service
# Usage: Called by Waybar `custom/vpn` on click
# Dependencies: systemctl, ip
# ──────────────────────────────────────────────────────────
if ip a | grep -q "10\.6\.0\."; then
# VPN active → stop service (disconnect)
systemctl stop nordvpn-retry.service
systemctl stop nordvpnd.service
else
# VPN inactive → start service (connect)
systemctl start nordvpn-retry.service
fi
'';
home.file.".config/waybar/scripts/nordvpn-status.sh".text = ''
#!/bin/bash
# ── nordvpn-status.sh ──────────────────────────────────────
# Description: Checks if VPN interface is active via IP range
# Usage: Called by Waybar `custom/vpn` every 5s
# Dependencies: ip, curl (optional, for country lookup)
# Output: Pango markup → [ФАНТОМ]: Country or KAPUTT
# Example: [ФАНТОМ]: Japan
# [ФАНТОМ]: KAPUTT
# ───────────────────────────────────────────────────────────
#!/bin/bash
if sudo ipsec statusall 2>/dev/null | grep -q "ESTABLISHED"; then
country=$(curl -s ifconfig.co/country 2>/dev/null)
[[ -z "$country" ]] && country="UNKNOWN"
echo "[УЗЕЛ]: $country"
else
echo "[НЕТ СВЯЗИ]"
fi
'';
home.file.".config/waybar/scripts/powermenu.sh".text = ''
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────────────
# Rofi Power Menu
# Provides a simple system power menu integrated with Waybar.
# Example:
# ./powermenu.sh
# # Opens a Rofi menu with power options
# ─────────────────────────────────────────────────────────────────────────────
rofi_command="rofi -dmenu -p Power"
options="Shutdown\nReboot\nLogout\nSuspend\nLock"
chosen="$(echo -e "$options" | $rofi_command)"
case $chosen in
Shutdown) systemctl poweroff ;;
Reboot) systemctl reboot ;;
Logout) hyprctl dispatch exit ;;
Suspend) systemctl suspend ;;
Lock) ~/.config/hyprlock/lock.sh ;;
esac
'';
home.file.".config/waybar/scripts/volume.sh".text = ''
#!/bin/bash
# ── volume.sh ─────────────────────────────────────────────
# Description: Shows current audio volume with ASCII bar + tooltip
# Usage: Waybar `custom/volume` every 1s
# Dependencies: wpctl, awk, bc, seq, printf
# ───────────────────────────────────────────────────────────
# Get raw volume and convert to int
vol_raw=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{ print $2 }')
vol_int=$(echo "$vol_raw * 100" | bc | awk '{ print int($1) }')
# Check mute status
is_muted=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q MUTED && echo true || echo false)
# Get default sink description (human-readable)
sink=$(wpctl status | awk '/Sinks:/,/Sources:/' | grep '\*' | cut -d'.' -f2- | sed 's/^\s*//; s/\[.*//')
# Icon logic
if [ "$is_muted" = true ]; then
icon=""
vol_int=0
elif [ "$vol_int" -lt 50 ]; then
icon=""
else
icon=""
fi
# ASCII bar
filled=$((vol_int / 10))
empty=$((10 - filled))
bar=$(printf '█%.0s' $(seq 1 $filled))
pad=$(printf '░%.0s' $(seq 1 $empty))
ascii_bar="[$bar$pad]"
# Color logic
if [ "$is_muted" = true ] || [ "$vol_int" -lt 10 ]; then
fg="#bf616a" # red
elif [ "$vol_int" -lt 50 ]; then
fg="#fab387" # orange
else
fg="#56b6c2" # cyan
fi
# Tooltip text
if [ "$is_muted" = true ]; then
tooltip="Audio: Muted\nOutput: $sink"
else
tooltip="Audio: $vol_int%\nOutput: $sink"
fi
# Final JSON output
echo "{\"text\":\"$icon $ascii_bar $vol_int%\",\"tooltip\":\"$tooltip\"}"
'';
}