rearrange hyprland config; change back to old waybar: adjust waybar colors; add btop

This commit is contained in:
2025-11-28 13:20:58 -08:00
parent e1f34cb767
commit 0042568e34
103 changed files with 8055 additions and 2825 deletions

View File

@@ -1,66 +0,0 @@
#!/usr/bin/env bash
#
# Adjust screen brightness and send a notification with the current level
#
# Requirements:
# - brightnessctl
# - notify-send (libnotify)
#
# Author: Jesse Mirabel <sejjymvm@gmail.com>
# Created: August 28, 2025
# License: MIT
VALUE=1
print-usage() {
local script=${0##*/}
cat <<- EOF
USAGE: $script [OPTIONS]
Adjust screen brightness and send a notification with the current level
OPTIONS:
up <value> Increase brightness by <value>
down <value> Decrease brightness by <value>
Default value: $VALUE
EXAMPLES:
Increase brightness:
$ $script up
Decrease brightness by 5:
$ $script down 5
EOF
exit 1
}
set-brightness() {
local op
case $action in
'up') op='+' ;;
'down') op='-' ;;
esac
brightnessctl -n set "${value}%${op}" &> /dev/null
local level
level=$(brightnessctl -m | awk -F ',' '{print $4}')
notify-send "Brightness: $level" -h int:value:"$level" -i 'contrast' -r 2825
}
main() {
action=$1
value=${2:-$VALUE}
! ((value > 0)) && print-usage
case $action in
'up' | 'down') set-brightness ;;
*) print-usage ;;
esac
}
main "$@"

80
waybar/scripts/battery-level.sh Executable file
View File

@@ -0,0 +1,80 @@
#!/usr/bin/env bash
# Original script by Eric Murphy
# https://github.com/ericmurphyxyz/dotfiles/blob/master/.local/bin/battery-alert
#
# Modified by Jesse Mirabel (@sejjy)
# https://github.com/sejjy/mechabar
# This script sends a notification when the battery is full, low, or critical.
# icon theme used: tela-circle-icon-theme-dracula
#
# (see the bottom of the script for more information)
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
# battery levels
WARNING_LEVEL=20
CRITICAL_LEVEL=10
# get the battery state and percentage using upower (waybar dependency)
BAT_PATH=$(upower -e | grep BAT | head -n 1)
BATTERY_STATE=$(upower -i "$BAT_PATH" | awk '/state:/ {print $2}')
BATTERY_LEVEL=$(upower -i "$BAT_PATH" | awk '/percentage:/ {print $2}' | tr -d '%')
# prevent multiple notifications
FILE_FULL=/tmp/battery-full
FILE_WARNING=/tmp/battery-warning
FILE_CRITICAL=/tmp/battery-critical
# remove the files if the battery is no longer in that state
if [ "$BATTERY_STATE" == "discharging" ]; then
rm -f $FILE_FULL
elif [ "$BATTERY_STATE" == "charging" ]; then
rm -f "$FILE_WARNING" "$FILE_CRITICAL"
fi
# if the battery is full and is plugged in
if [ "$BATTERY_LEVEL" -eq 100 ] && [ "$BATTERY_STATE" == "fully-charged" ] && [ ! -f $FILE_FULL ]; then
notify-send -a "state" "Battery Charged (${BATTERY_LEVEL}%)" "You might want to unplug your PC." -i "battery-full" -r 9991
touch $FILE_FULL
# if the battery is low and is discharging
elif [ "$BATTERY_LEVEL" -le $WARNING_LEVEL ] && [ "$BATTERY_STATE" == "discharging" ] && [ ! -f $FILE_WARNING ]; then
notify-send -a "state" "Battery Low (${BATTERY_LEVEL}%)" "You might want to plug in your PC." -u critical -i "battery-caution" -r 9991 -h string:fgcolor:\#fab387 -h string:frcolor:\#fab387
touch $FILE_WARNING
# if the battery is critical and is discharging
elif [ "$BATTERY_LEVEL" -le $CRITICAL_LEVEL ] && [ "$BATTERY_STATE" == "discharging" ] && [ ! -f $FILE_CRITICAL ]; then
notify-send -a "state" "Battery Critical (${BATTERY_LEVEL}%)" "Plug in your PC now." -u critical -i "battery-empty" -r 9991
touch $FILE_CRITICAL
fi
# systemd service
# Add the following to ~/.config/systemd/user/battery-level.service:
# [Unit]
# Description=Battery Level Checker
# After=graphical.target
#
# [Service]
# ExecStart=%h/.config/waybar/scripts/battery-level.sh
# Type=oneshot
# systemd timer
# Add the following to ~/.config/systemd/user/battery-level.timer:
# [Unit]
# Description=Run Battery Level Checker
#
# [Timer]
# OnBootSec=1min
# OnUnitActiveSec=1min
# Unit=battery-level.service
#
# [Install]
# WantedBy=timers.target
# enable the timer by running the following commands:
# systemctl --user daemon-reload
# systemctl --user enable --now battery-level.timer

50
waybar/scripts/battery-state.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Original script by Eric Murphy
# https://github.com/ericmurphyxyz/dotfiles/blob/master/.local/bin/battery-alert
#
# Modified by Jesse Mirabel (@sejjy)
# https://github.com/sejjy/mechabar
# This script sends a notification when the battery is charging or discharging.
# icon theme used: tela-circle-icon-theme-dracula
#
# (see the bottom of the script for more information)
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
# get the battery state from the udev rule
BATTERY_STATE=$1
# get the battery percentage using upower (waybar dependency)
BAT_PATH=$(upower -e | grep BAT | head -n 1)
BATTERY_LEVEL=$(upower -i "$BAT_PATH" | awk '/percentage:/ {print $2}' | tr -d '%')
# set the battery charging state and icon
case "$BATTERY_STATE" in
"charging")
BATTERY_CHARGING="Charging"
BATTERY_ICON="090-charging"
;;
"discharging")
BATTERY_CHARGING="Disharging"
BATTERY_ICON="090"
;;
esac
# send the notification
notify-send -a "state" "Battery ${BATTERY_CHARGING} (${BATTERY_LEVEL}%)" -u normal -i "battery-${BATTERY_ICON}" -r 9991
# udev rule
# Add the following to /etc/udev/rules.d/60-power.rules:
# ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", ENV{DISPLAY}=":0", RUN+="/usr/bin/su <username> -c '$HOME/.config/waybar/scripts/battery-state.sh discharging'"
# ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", ENV{DISPLAY}=":0", RUN+="/usr/bin/su <username> -c '$HOME/.config/waybar/scripts/battery-state.sh charging'"
# the number 60 in the udev rule can be changed to any number between 0 and 99.
# the lower the number, the higher the priority.
#
# $USER does not work, so you have to replace "<username>" with your username.
# reload udev rules by running the following command:
# sudo udevadm control --reload-rules

106
waybar/scripts/bluetooth-menu.sh Executable file
View File

@@ -0,0 +1,106 @@
#!/usr/bin/env bash
# Author: Jesse Mirabel (@sejjy)
# GitHub: https://github.com/sejjy/mechabar
# Rofi config
config="$HOME/.config/rofi/bluetooth-menu.rasi"
# Rofi window override
override_disabled="mainbox { children: [ textbox-custom, listview ]; } listview { lines: 1; padding: 6px 6px 8px; }"
get_device_icon() {
local device_mac=$1
device_info=$(bluetoothctl info "$device_mac")
device_icon=$(echo "$device_info" | grep "Icon:" | awk '{print $2}')
case "$device_icon" in
"audio-headphones" | "audio-headset") echo "󰋋 " ;; # Headphones
"video-display" | "computer") echo "󰍹 " ;; # Monitor
"audio-input-microphone") echo "󰍬 " ;; # Microphone
"input-keyboard") echo "󰌌 " ;; # Keyboard
"audio-speakers") echo "󰓃 " ;; # Speakers
"input-mouse") echo "󰍽 " ;; # Mouse
"phone") echo "󰏲 " ;; # Phone
*)
echo "󰂱 " # Default
;;
esac
}
while true; do
# Get list of paired devices
bluetooth_devices=$(bluetoothctl devices | while read -r line; do
device_mac=$(echo "$line" | awk '{print $2}')
device_name=$(echo "$line" | awk '{$1=$2=""; print substr($0, 3)}')
icon=$(get_device_icon "$device_mac")
echo "$icon $device_name"
done)
options=$(
echo "󰏌 Scan for devices"
echo "󰂲 Disable Bluetooth"
echo "$bluetooth_devices"
)
option="󰂯 Enable Bluetooth"
# Get Bluetooth status
bluetooth_status=$(bluetoothctl show | grep "Powered:" | awk '{print $2}')
if [[ "$bluetooth_status" == "yes" ]]; then
selected_option=$(echo -e "$options" | rofi -dmenu -i -selected-row 1 -config "${config}" -p " " || pkill -x rofi)
else
selected_option=$(echo -e "$option" | rofi -dmenu -i -selected-row 1 -config "${config}" -theme-str "${override_disabled}" -p " " || pkill -x rofi)
fi
# Exit if no option is selected
if [ -z "$selected_option" ]; then
exit
fi
# Actions based on selected option
case "$selected_option" in
*"Enable Bluetooth")
notify-send "Bluetooth Enabled" -i "package-installed-outdated"
rfkill unblock bluetooth
bluetoothctl power on
sleep 1
;;
*"Disable Bluetooth")
notify-send "Bluetooth Disabled" -i "package-broken"
rfkill block bluetooth
bluetoothctl power off
exit
;;
*"Scan for devices")
notify-send "Press '?' to show help." -i "package-installed-outdated"
kitty --title '󰂱 Bluetooth TUI' bash -c "bluetui" # Launch bluetui
;;
*)
# Extract device name
device_name="${selected_option#* }"
device_name="${device_name## }"
if [[ -n "$device_name" ]]; then
# Get MAC address
device_mac=$(bluetoothctl devices | grep "$device_name" | awk '{print $2}')
# Trust and pair device
bluetoothctl trust "$device_mac" >/dev/null 2>&1
bluetoothctl pair "$device_mac" >/dev/null 2>&1
# Connect to device
bluetoothctl connect "$device_mac" &
sleep 3
connection_status=$(bluetoothctl info "$device_mac" | grep "Connected:" | awk '{print $2}')
if [[ "$connection_status" == "yes" ]]; then
notify-send "Connected to \"$device_name\"." -i "package-installed-outdated"
exit
else
notify-send "Failed to connect to \"$device_name\"." -i "package-broken"
fi
fi
;;
esac
done

View File

@@ -1,120 +0,0 @@
#!/usr/bin/env bash
#
# Scan, select, pair, and connect to Bluetooth devices
#
# Requirements:
# - bluetoothctl (bluez-utils)
# - fzf
# - notify-send (libnotify)
#
# Author: Jesse Mirabel <sejjymvm@gmail.com>
# Created: August 19, 2025
# License: MIT
RED='\033[1;31m'
RST='\033[0m'
TIMEOUT=10
get-device-list() {
bluetoothctl --timeout $TIMEOUT scan on > /dev/null &
local i num
for ((i = 1; i <= TIMEOUT; i++)); do
printf '\rScanning for devices... (%d/%d)' $i $TIMEOUT
printf '\n%bPress [q] to stop%b\n\n' "$RED" "$RST"
num=$(bluetoothctl devices | grep -c Device)
printf '\rDevices: %s' "$num"
printf '\033[3A' # move cursor up 3 lines
read -rs -n 1 -t 1
[[ $REPLY == [Qq] ]] && break
done
printf '\n%bScanning stopped.%b\n\n' "$RED" "$RST"
list=$(bluetoothctl devices | grep Device | cut -d ' ' -f 2-)
if [[ -z $list ]]; then
notify-send 'Bluetooth' 'No devices found' -i 'package-broken'
return 1
fi
}
select-device() {
local header
header=$(printf '%-17s %s' 'Address' 'Name')
# shellcheck disable=SC1090
. ~/.config/waybar/scripts/fzf-colors.sh 2> /dev/null
local opts=(
--border=sharp
--border-label=' Bluetooth Devices '
--ghost='Search'
--header="$header"
--height=~100%
--highlight-line
--info=inline-right
--pointer=
--reverse
"${COLORS[@]}"
)
address=$(fzf "${opts[@]}" <<< "$list" | awk '{print $1}')
[[ -z $address ]] && return 1
local connected
connected=$(bluetoothctl info "$address" | grep Connected |
awk '{print $2}')
if [[ $connected == 'yes' ]]; then
notify-send 'Bluetooth' 'Already connected to this device' \
-i 'package-install'
return 1
fi
}
pair-and-connect() {
local paired
paired=$(bluetoothctl info "$address" | grep Paired | awk '{print $2}')
if [[ $paired == 'no' ]]; then
printf 'Pairing...'
if ! timeout $TIMEOUT bluetoothctl pair "$address" > /dev/null; then
notify-send 'Bluetooth' 'Failed to pair' -i 'package-purge'
return 1
fi
fi
printf '\nConnecting...'
if timeout $TIMEOUT bluetoothctl connect "$address" > /dev/null; then
notify-send 'Bluetooth' 'Successfully connected' -i 'package-install'
else
notify-send 'Bluetooth' 'Failed to connect' -i 'package-purge'
fi
}
main() {
local status
status=$(bluetoothctl show | grep PowerState | awk '{print $2}')
if [[ $status == 'off' ]]; then
bluetoothctl power on > /dev/null
notify-send 'Bluetooth On' -i 'network-bluetooth-activated' -r 1925
fi
tput civis # make cursor invisible
get-device-list || exit 1
tput cnorm # make cursor visible
select-device || exit 1
pair-and-connect || exit 1
}
main

View File

@@ -0,0 +1,92 @@
#!/usr/bin/env bash
# Print error message for invalid arguments
print_error() {
cat <<"EOF"
Usage: ./brightnesscontrol.sh <action>
Valid actions are:
i -- <i>ncrease brightness [+2%]
d -- <d>ecrease brightness [-2%]
EOF
}
# Send a notification with brightness info
send_notification() {
brightness=$(brightnessctl info | grep -oP "(?<=\()\d+(?=%)")
notify-send -a "state" -r 91190 -i "gpm-brightness-lcd" -h int:value:"$brightness" "Brightness: ${brightness}%" -u low
}
# Get the current brightness percentage and device name
get_brightness() {
brightness=$(brightnessctl -m | grep -o '[0-9]\+%' | head -c-2)
device=$(brightnessctl -m | head -n 1 | awk -F',' '{print $1}' | sed 's/_/ /g; s/\<./\U&/g') # Get device name
current_brightness=$(brightnessctl -m | head -n 1 | awk -F',' '{print $3}') # Get current brightness
max_brightness=$(brightnessctl -m | head -n 1 | awk -F',' '{print $5}') # Get max brightness
}
get_brightness
# Handle options
while getopts o: opt; do
case "${opt}" in
o)
case $OPTARG in
i) # Increase brightness
if [[ $brightness -lt 10 ]]; then
brightnessctl set +1%
else
brightnessctl set +2%
fi
send_notification
;;
d) # Decrease brightness
if [[ $brightness -le 1 ]]; then
brightnessctl set 1%
elif [[ $brightness -le 10 ]]; then
brightnessctl set 1%-
else
brightnessctl set 2%-
fi
send_notification
;;
*)
print_error
;;
esac
;;
*)
print_error
;;
esac
done
# Determine the icon based on brightness level
get_icon() {
if ((brightness <= 5)); then
icon=""
elif ((brightness <= 15)); then
icon=""
elif ((brightness <= 30)); then
icon=""
elif ((brightness <= 45)); then
icon=""
elif ((brightness <= 55)); then
icon=""
elif ((brightness <= 65)); then
icon=""
elif ((brightness <= 80)); then
icon=""
elif ((brightness <= 95)); then
icon=""
else
icon=""
fi
}
# Backlight module and tooltip
get_icon
module="${icon} ${brightness}%"
tooltip="Device Name: ${device}"
tooltip+="\nBrightness: ${current_brightness} / ${max_brightness}"
echo "{\"text\": \"${module}\", \"tooltip\": \"${tooltip}\"}"

67
waybar/scripts/cpu-temp.sh Executable file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/env bash
model=$(awk -F ': ' '/model name/{print $2}' /proc/cpuinfo | head -n 1 | sed 's/@.*//; s/ *\((R)\|(TM)\)//g; s/^[ \t]*//; s/[ \t]*$//')
# get CPU clock speeds
get_cpu_frequency() {
freqlist=$(awk '/cpu MHz/ {print $4}' /proc/cpuinfo)
maxfreq=$(sed 's/...$//' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
if [ -z "$freqlist" ] || [ -z "$maxfreq" ]; then
echo "--"
return
fi
average_freq=$(echo "$freqlist" | tr ' ' '\n' | awk "{sum+=\$1} END {printf \"%.0f/%s MHz\", sum/NR, $maxfreq}")
echo "$average_freq"
}
# get CPU temp
get_cpu_temperature() {
temp=$(sensors | awk '/Package id 0/ {print $4}' | awk -F '[+.]' '{print $2}')
if [[ -z "$temp" ]]; then
temp=$(sensors | awk '/Tctl/ {print $2}' | tr -d '+°C')
fi
if [[ -z "$temp" ]]; then
temp="--"
temp_f="--"
else
temp=${temp%.*}
temp_f=$(awk "BEGIN {printf \"%.1f\", ($temp * 9 / 5) + 32}")
fi
# Celsius and Fahrenheit
echo "${temp:---} ${temp_f:---}"
}
get_temperature_icon() {
temp_value=$1
if [ "$temp_value" = "--" ]; then
icon="󱔱" # none
elif [ "$temp_value" -ge 80 ]; then
icon="󰸁" # high
elif [ "$temp_value" -ge 70 ]; then
icon="󱃂" # medium
elif [ "$temp_value" -ge 60 ]; then
icon="󰔏" # normal
else
icon="󱃃" # low
fi
echo "$icon"
}
cpu_frequency=$(get_cpu_frequency)
read -r temp_info < <(get_cpu_temperature)
temp=$(echo "$temp_info" | awk '{print $1}')
temp_f=$(echo "$temp_info" | awk '{print $2}')
thermo_icon=$(get_temperature_icon "$temp")
# high temp warning
if [ "$temp" == "--" ] || [ "$temp" -ge 80 ]; then
text_output="<span color='#f38ba8'>${thermo_icon} ${temp}°C</span>"
else
text_output="${thermo_icon} ${temp}°C"
fi
tooltip=":: ${model}\n"
tooltip+="Clock Speed: ${cpu_frequency}\nTemperature: ${temp_f}°F"
# module and tooltip
echo "{\"text\": \"$text_output\", \"tooltip\": \"$tooltip\"}"

24
waybar/scripts/current-theme.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
CURRENT_THEME_FILE="$HOME/.config/waybar/themes/current-theme"
# Get the current theme
current_theme=$(cat "$CURRENT_THEME_FILE" 2>/dev/null || echo "")
current_theme_name="Default"
# Get the theme name
if [[ -n "$current_theme" ]]; then
current_theme_name=$(basename "$current_theme" .css)
# Convert "theme-name" to "Theme Name"
formatted_theme_name="${current_theme_name//-/ }"
formatted_theme_name=$(echo "$formatted_theme_name" | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1')
else
formatted_theme_name="Default"
fi
tooltip="Theme: $formatted_theme_name"
tooltip+="\nStyle: Classic" # hard-coded for now
# Tooltip
echo "{\"tooltip\": \"$tooltip\"}"

View File

@@ -1,82 +0,0 @@
#!/usr/bin/env bash
#
# NOTE:
# The names, maps, and COLORS arrays are all parallel:
# - names[i]: the color name as defined in theme.css
# - maps[i]: variable to store the hex value
# - COLORS: color config passed to fzf
#
# Add themes by defining the names array in def-colors().
FILE="$XDG_CONFIG_HOME/waybar/theme.css"
def-colors() {
local theme
theme=$(sed 1q "$FILE")
declare -ga names
# Add themes here:
if [[ $theme == *"catppuccin"* ]]; then
names=(
'surface0' 'base' 'rosewater'
'red' 'text' 'red'
'mauve' 'rosewater' 'lavender'
'text' 'mauve' 'red'
'surface1' 'overlay0' 'text'
)
fi
}
get-hex() {
local defs
defs=$(sed -n '3,28p' "$FILE")
local n hex
declare -gA colors
for n in "${names[@]}"; do
read -r _ _ hex < <(grep " $n " <<< "$defs")
hex=${hex%;}
colors[$n]=$hex
done
}
map-colors() {
local -a maps=(
'_cur_bg' '_bg' '_spinner'
'_hl' '_fg' '_header'
'_info' '_pointer' '_marker'
'_cur_fg' '_prompt' '_cur_hl'
'_sel_bg' '_border' '_label'
)
local n
local i=0
for n in "${names[@]}"; do
declare -g "${maps[i]}"="${colors[$n]}"
((i++))
done
}
main() {
def-colors
get-hex
map-colors
# shellcheck disable=SC2154
# These variables are defined dynamically
declare -ga COLORS=(
"--color= bg+:$_cur_bg, bg:$_bg, spinner:$_spinner"
"--color= hl:$_hl, fg:$_fg, header:$_header"
"--color= info:$_info, pointer:$_pointer, marker:$_marker"
"--color= fg+:$_cur_fg, prompt:$_prompt, hl+:$_cur_hl"
"--color=selected-bg:$_sel_bg, border:$_border, label:$_label"
)
export COLORS
}
main

View File

@@ -1,99 +0,0 @@
#!/usr/bin/env bash
#
# Scan, select, and connect to Wi-Fi networks
#
# Requirements:
# - nmcli (networkmanager)
# - fzf
# - notify-send (libnotify)
#
# Author: Jesse Mirabel <sejjymvm@gmail.com>
# Created: August 11, 2025
# License: MIT
RED='\033[1;31m'
RST='\033[0m'
TIMEOUT=5
get-network-list() {
nmcli device wifi rescan 2> /dev/null
local i
for ((i = 1; i <= TIMEOUT; i++)); do
printf '\rScanning for networks... (%d/%d)' $i $TIMEOUT
printf '\033[1A' # move cursor up 1 line
list=$(timeout 1 nmcli device wifi list)
networks=$(tail -n +2 <<< "$list" | awk '$2 != "--"')
[[ -n $networks ]] && break
done
printf '\n%bScanning stopped.%b\n\n' "$RED" "$RST"
if [[ -z $networks ]]; then
notify-send 'Wi-Fi' 'No networks found' -i 'package-broken'
return 1
fi
}
select-network() {
local header
header=$(head -n 1 <<< "$list")
# shellcheck disable=SC1090
. ~/.config/waybar/scripts/fzf-colors.sh 2> /dev/null
local opts=(
--border=sharp
--border-label=' Wi-Fi Networks '
--ghost='Search'
--header="$header"
--height=~100%
--highlight-line
--info=inline-right
--pointer=
--reverse
"${COLORS[@]}"
)
bssid=$(fzf "${opts[@]}" <<< "$networks" | awk '{print $1}')
if [[ -z $bssid ]]; then
return 1
elif [[ $bssid == '*' ]]; then
notify-send 'Wi-Fi' 'Already connected to this network' \
-i 'package-install'
return 1
fi
}
connect-to-network() {
printf 'Connecting...\n'
if nmcli --ask device wifi connect "$bssid"; then
notify-send 'Wi-Fi' 'Successfully connected' -i 'package-install'
else
notify-send 'Wi-Fi' 'Failed to connect' -i 'package-purge'
fi
}
main() {
local status
status=$(nmcli radio wifi)
if [[ $status == 'disabled' ]]; then
nmcli radio wifi on
notify-send 'Wi-Fi Enabled' -i 'network-wireless-on' -r 1125
fi
tput civis # make cursor invisible
get-network-list || exit 1
tput cnorm # make cursor visible
select-network || exit 1
connect-to-network
}
main

View File

@@ -1,49 +1,30 @@
#!/usr/bin/env bash
#
# Display a power menu to perform system actions
#
# Requirements:
# - fzf
#
# Author: Jesse Mirabel <sejjymvm@gmail.com>
# Created: August 19, 2025
# License: MIT
LIST=(
'Lock'
'Shutdown'
'Reboot'
'Logout'
'Hibernate'
'Suspend'
)
config="$HOME/.config/rofi/power-menu.rasi"
main() {
# shellcheck disable=SC1090
. ~/.config/waybar/scripts/fzf-colors.sh 2> /dev/null
actions=$(echo -e " Lock\n Shutdown\n Reboot\n Suspend\n Hibernate\n󰞘 Logout")
local opts=(
--border=sharp
--border-label=' Power Menu '
--height=~100%
--highlight-line
--no-input
--pointer=
--reverse
"${COLORS[@]}"
)
# Display logout menu
selected_option=$(echo -e "$actions" | rofi -dmenu -i -config "${config}" || pkill -x rofi)
local selected
selected=$(printf '%s\n' "${LIST[@]}" | fzf "${opts[@]}")
case $selected in
'Lock') loginctl lock-session ;;
'Shutdown') systemctl poweroff ;;
'Reboot') systemctl reboot ;;
'Logout') loginctl terminate-session "$XDG_SESSION_ID" ;;
'Hibernate') systemctl hibernate ;;
'Suspend') systemctl suspend ;;
esac
}
main
# Perform actions based on the selected option
case "$selected_option" in
*Lock)
loginctl lock-session
;;
*Shutdown)
systemctl poweroff
;;
*Reboot)
systemctl reboot
;;
*Suspend)
systemctl suspend
;;
*Hibernate)
systemctl hibernate
;;
*Logout)
loginctl kill-session "$XDG_SESSION_ID"
;;
esac

View File

@@ -1,82 +1,107 @@
#!/usr/bin/env bash
#
# Check for available updates and optionally upgrade packages on Arch Linux.
#
# Requirements:
# - checkupdates (pacman-contrib)
# - notify-send (libnotify)
# - optional: an AUR helper (aura, paru, pikaur, trizen, yay)
#
# Author: Jesse Mirabel <sejjymvm@gmail.com>
# Created: August 16, 2025
# License: MIT
# Check release
if [ ! -f /etc/arch-release ]; then
exit 0
fi
GRN='\033[1;32m'
BLU='\033[1;34m'
RST='\033[0m'
TIMEOUT=5
check-updates() {
repo=$(timeout $TIMEOUT checkupdates 2> /dev/null | wc -l)
if [[ -n $helper ]]; then
aur=$(timeout $TIMEOUT "$helper" -Quaq 2> /dev/null | wc -l)
fi
pkg_installed() {
local pkg=$1
if pacman -Qi "${pkg}" &>/dev/null; then
return 0
elif command -v "${pkg}" &>/dev/null; then
return 0
else
return 1
fi
}
update-packages() {
printf '\n%bUpdating pacman packages...%b\n' "$BLU" "$RST"
sudo pacman -Syu
printf '\n%bUpdating AUR packages...%b\n' "$BLU" "$RST"
"$helper" -Syu
# use signal to update the module
pkill -RTMIN+1 waybar
notify-send 'Update Complete' -i 'package-install'
printf '\n%bUpdate Complete!%b\n' "$GRN" "$RST"
read -rs -n 1 -p 'Press any key to exit...'
get_aur_helper() {
if command -v yay &>/dev/null; then
aur_helper="yay"
elif command -v paru &>/dev/null; then
aur_helper="paru"
else
aur_helper=""
fi
}
display-module() {
local tooltip="Official: $repo"
get_aur_helper
if [[ -n $helper ]]; then
tooltip+="\nAUR($helper): $aur"
fi
# Trigger upgrade
if [ "$1" == "up" ]; then
trap 'pkill -RTMIN+20 waybar' EXIT
command="
echo 'Starting system update...'
$0 upgrade
if [ -n '$aur_helper' ]; then
echo 'Running AUR update with $aur_helper...'
$aur_helper -Syu
else
echo 'Running official repository update...'
sudo pacman -Syu
fi
if command -v flatpak &>/dev/null; then
echo 'Running Flatpak update...'
flatpak update -y
fi
echo ''
echo 'Update complete! Press Enter to close...'
read -r
"
ghostty -e bash -c "${command}"
exit 0
fi
local total=$((repo + aur))
# Check for official repository updates with timeout
official_updates=$(
(timeout 10 bash -c 'while pgrep -x checkupdates >/dev/null; do sleep 1; done') 2>/dev/null
checkupdates 2>/dev/null | wc -l
)
official_updates=$((official_updates + 0))
if ((total == 0)); then
echo "{ \"text\": \"󰸟\", \"tooltip\": \"No updates available\" }"
else
echo "{ \"text\": \"\", \"tooltip\": \"$tooltip\" }"
fi
}
# Check for AUR updates with timeout
if [ -n "$aur_helper" ]; then
aur_updates=$(timeout 10 $aur_helper -Qua 2>/dev/null | wc -l)
aur_updates=$((aur_updates + 0))
else
aur_updates=0
fi
main() {
local arg=$1
local helpers=(aura paru pikaur trizen yay)
local bin
# Check for Flatpak updates with timeout
if pkg_installed flatpak; then
flatpak_updates=$(timeout 10 flatpak remote-ls --updates 2>/dev/null | wc -l)
flatpak_updates=$((flatpak_updates + 0))
else
flatpak_updates=0
fi
bin=$(command -v "${helpers[@]}" | head -n 1)
helper=${bin##*/}
repo=0
aur=0
# Calculate total available updates
total_updates=$((official_updates + aur_updates + flatpak_updates))
case $arg in
'module')
check-updates
display-module
;;
*)
printf '%bChecking for updates...%b' "$BLU" "$RST"
check-updates
update-packages
;;
esac
}
# Handle upgrade info display
if [ "${1}" == "upgrade" ]; then
if [ "$aur_helper" == "yay" ]; then
printf "Official: %s\nAUR ($aur_helper): %s\nFlatpak: %s\n\n" "$official_updates" "$aur_updates" "$flatpak_updates"
elif [ "$aur_helper" == "paru" ]; then
printf "Official: %s\nAUR ($aur_helper): %s\nFlatpak: %s\n\n" "$official_updates" "$aur_updates" "$flatpak_updates"
else
printf "Official: %s\nFlatpak: %s\n\n" "$official_updates" "$flatpak_updates"
fi
exit 0
fi
main "$@"
# Create tooltip text
if [ "$aur_helper" == "yay" ]; then
tooltip="Official: $official_updates\nAUR ($aur_helper): $aur_updates\nFlatpak: $flatpak_updates"
elif [ "$aur_helper" == "paru" ]; then
tooltip="Official: $official_updates\nAUR ($aur_helper): $aur_updates\nFlatpak: $flatpak_updates"
else
tooltip="Official: $official_updates\nFlatpak: $flatpak_updates"
fi
# Output compact JSON for Waybar
if [ $total_updates -eq 0 ]; then
echo '{"text":"󰸟","tooltip":"Packages are up to date"}'
else
printf '{"text":" %s","tooltip":"%s"}\n' "$total_updates" "$tooltip"
fi

View File

@@ -0,0 +1,54 @@
#!/usr/bin/env bash
WAYBAR_CSS_DIR="$HOME/.config/waybar/themes/css"
WAYBAR_CSS_FILE="$HOME/.config/waybar/theme.css"
WAYBAR_JSONC_DIR="$HOME/.config/waybar/themes/jsonc"
WAYBAR_JSONC_FILE="$HOME/.config/waybar/config.jsonc"
ROFI_THEMES_DIR="$HOME/.config/rofi/themes"
ROFI_THEME_FILE="$HOME/.config/rofi/theme.rasi"
CURRENT_THEME_FILE="$HOME/.config/waybar/themes/current-theme"
for dir in "$WAYBAR_CSS_DIR" "$WAYBAR_JSONC_DIR" "$ROFI_THEMES_DIR"; do
[[ ! -d "$dir" ]] && echo "Error: $dir not found" && exit 1
done
# Get all themes
waybar_css=("$WAYBAR_CSS_DIR"/*.css)
waybar_jsonc=("$WAYBAR_JSONC_DIR"/*.jsonc)
rofi_themes=("$ROFI_THEMES_DIR"/*.rasi)
if [[ ${#waybar_css[@]} -eq 0 || ${#waybar_jsonc[@]} -eq 0 || ${#rofi_themes[@]} -eq 0 ]]; then
echo "Error: No themes found in one of the directories"
exit 1
fi
# Get the current theme
current_theme=$(cat "$CURRENT_THEME_FILE" 2>/dev/null || echo "")
# Find the index of the current theme
next_theme_index=0
for i in "${!waybar_css[@]}"; do
[[ "${waybar_css[$i]}" == "$current_theme" ]] && next_theme_index=$(((i + 1) % ${#waybar_css[@]})) && break
done
# Get the new theme
new_waybar_css="${waybar_css[$next_theme_index]}"
new_waybar_jsonc="${waybar_jsonc[$next_theme_index]}"
new_rofi_theme="${rofi_themes[$next_theme_index]}"
# Save the new theme
echo "$new_waybar_css" >"$CURRENT_THEME_FILE"
declare -A theme_files=(
["$new_waybar_css"]="$WAYBAR_CSS_FILE"
["$new_waybar_jsonc"]="$WAYBAR_JSONC_FILE"
["$new_rofi_theme"]="$ROFI_THEME_FILE"
)
for src in "${!theme_files[@]}"; do
cp "$src" "${theme_files[$src]}"
done
# Restart Waybar to apply changes
killall waybar || true
nohup waybar --config "$HOME/.config/waybar/config.jsonc" --style "$HOME/.config/waybar/style.css" >/dev/null 2>&1 &

123
waybar/scripts/volume-control.sh Executable file
View File

@@ -0,0 +1,123 @@
#!/usr/bin/env bash
# Define functions
print_error() {
cat <<"EOF"
Usage: ./volumecontrol.sh -[device] <actions>
...valid devices are...
i -- input device
o -- output device
p -- player application
...valid actions are...
i -- increase volume [+2]
d -- decrease volume [-2]
m -- mute [x]
EOF
exit 1
}
icon() {
vol=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | sed 's/%//')
mute=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}')
if [ "$mute" = "yes" ] || [ "$vol" -eq 0 ]; then
icon="volume-level-muted"
elif [ "$vol" -lt 33 ]; then
icon="volume-level-low"
elif [ "$vol" -lt 66 ]; then
icon="volume-level-medium"
else
icon="volume-level-high"
fi
}
send_notification() {
icon
notify-send -a "state" -r 91190 -i "$icon" -h int:value:"$vol" "Volume: ${vol}%" -u low
}
notify_mute() {
mute=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}')
if [ "$mute" = "yes" ]; then
notify-send -a "state" -r 91190 -i "volume-level-muted" "Volume: Muted" -u low
else
icon
notify-send -a "state" -r 91190 -i "$icon" "Volume: Unmuted" -u low
fi
}
action_volume() {
case "${1}" in
i)
# Increase volume 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 + 2))
[ "$new_vol" -gt 100 ] && new_vol=100
pactl set-sink-volume @DEFAULT_SINK@ "${new_vol}%"
fi
;;
d)
# Decrease volume if above 0
current_vol=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | sed 's/%//')
new_vol=$((current_vol - 2))
[ "$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
case "${1}" in
i) action_volume i ;;
d) action_volume d ;;
m) pactl set-sink-mute @DEFAULT_SINK@ toggle && notify_mute && exit 0 ;;
*) print_error ;;
esac
send_notification

View File

@@ -1,159 +0,0 @@
#!/usr/bin/env bash
#
# Adjust default device volume and send a notification with the current level
#
# Requirements:
# - pactl (libpulse)
# - notify-send (libnotify)
#
# Author: Jesse Mirabel <sejjymvm@gmail.com>
# Created: September 07, 2025
# License: MIT
VALUE=1
MIN=0
MAX=100
ID=2425
print-usage() {
local script=${0##*/}
cat <<- EOF
USAGE: $script [OPTIONS]
Adjust default device volume and send a notification with the current level
OPTIONS:
input Set device as '@DEFAULT_SOURCE@'
output Set device as '@DEFAULT_SINK@'
mute Toggle device mute
raise <value> Raise volume by <value>
lower <value> Lower volume by <value>
Default value: $VALUE
EXAMPLES:
Toggle microphone mute:
$ $script input mute
Raise speaker volume:
$ $script output raise
Lower speaker volume by 5:
$ $script output lower 5
EOF
exit 1
}
check-muted() {
local muted
muted=$(pactl "get-$dev_mute" "$dev" | awk '{print $2}')
local state
case $muted in
'yes') state='Muted' ;;
'no') state='Unmuted' ;;
esac
echo "$state"
}
get-volume() {
local vol
vol=$(pactl "get-$dev_vol" "$dev" | awk '{print $5}' | tr -d '%')
echo "$vol"
}
get-icon() {
local state vol
state=$(check-muted)
vol=$(get-volume)
local icon
local new_vol=${1:-$vol}
if [[ $state == 'Muted' ]]; then
icon="$dev_icon-muted"
else
if ((new_vol < ((MAX * 33) / 100))); then
icon="$dev_icon-low"
elif ((new_vol < ((MAX * 66) / 100))); then
icon="$dev_icon-medium"
else
icon="$dev_icon-high"
fi
fi
echo "$icon"
}
toggle-mute() {
pactl "set-$dev_mute" "$dev" toggle
local state icon
state=$(check-muted)
icon=$(get-icon)
notify-send "$title: $state" -i "$icon" -r $ID
}
set-volume() {
local vol
vol=$(get-volume)
local new_vol
case $action in
'raise')
new_vol=$((vol + value))
((new_vol > MAX)) && new_vol=$MAX
;;
'lower')
new_vol=$((vol - value))
((new_vol < MIN)) && new_vol=$MIN
;;
esac
pactl "set-$dev_vol" "$dev" "${new_vol}%"
local icon
icon=$(get-icon "$new_vol")
notify-send "$title: ${new_vol}%" -h int:value:$new_vol -i "$icon" -r $ID
}
main() {
device=$1
action=$2
value=${3:-$VALUE}
! ((value > 0)) && print-usage
case $device in
'input')
dev='@DEFAULT_SOURCE@'
dev_mute='source-mute'
dev_vol='source-volume'
dev_icon='mic-volume'
title='Microphone'
;;
'output')
dev='@DEFAULT_SINK@'
dev_mute='sink-mute'
dev_vol='sink-volume'
dev_icon='audio-volume'
title='Volume'
;;
*) print-usage ;;
esac
case $action in
'mute') toggle-mute ;;
'raise' | 'lower') set-volume ;;
*) print-usage ;;
esac
}
main "$@"

126
waybar/scripts/wifi-menu.sh Executable file
View File

@@ -0,0 +1,126 @@
#!/usr/bin/env bash
# Author: Jesse Mirabel (@sejjy)
# GitHub: https://github.com/sejjy/mechabar
# Rofi config
config="$HOME/.config/rofi/wifi-menu.rasi"
options=$(
echo " Manual Entry"
echo "󰤮 Disable Wi-Fi"
)
option_disabled="󰤥 Enable Wi-Fi"
# Rofi window override
override_ssid="entry { placeholder: \"Enter SSID\"; } listview { lines: 0; padding: 20px 6px; }"
override_password="entry { placeholder: \"Enter password\"; } listview { lines: 0; padding: 20px 6px; }"
override_disabled="mainbox { children: [ textbox-custom, listview ]; } listview { lines: 1; padding: 6px 6px 8px; }"
# Prompt for password
get_password() {
rofi -dmenu -password -config "${config}" -theme-str "${override_password}" -p " " || pkill -x rofi
}
while true; do
wifi_list() {
nmcli --fields "SECURITY,SSID" device wifi list |
tail -n +2 | # Skip the header line from nmcli output
sed 's/ */ /g' | # Replace multiple spaces with a single space
sed -E "s/WPA*.?\S/󰤪 /g" | # Replace 'WPA*' with a Wi-Fi lock icon
sed "s/^--/󰤨 /g" | # Replace '--' (open networks) with an open Wi-Fi icon
sed "s/󰤪 󰤪/󰤪/g" | # Remove duplicate Wi-Fi lock icons
sed "/--/d" | # Remove lines containing '--' (empty SSIDs)
awk '!seen[$0]++' # Filter out duplicate SSIDs
}
# Get Wi-Fi status
wifi_status=$(nmcli -fields WIFI g)
case "$wifi_status" in
*"enabled"*)
selected_option=$(echo "$options"$'\n'"$(wifi_list)" |
rofi -dmenu -i -selected-row 1 -config "${config}" -p " " || pkill -x rofi)
;;
*"disabled"*)
selected_option=$(echo "$option_disabled" |
rofi -dmenu -i -config "${config}" -theme-str "${override_disabled}" || pkill -x rofi)
;;
esac
# Extract selected SSID
read -r selected_ssid <<<"${selected_option:3}"
# Actions based on selected option
case "$selected_option" in
"")
exit
;;
*"Enable Wi-Fi")
notify-send "Scanning for networks..." -i "package-installed-outdated"
nmcli radio wifi on
nmcli device wifi rescan
sleep 3
;;
*"Disable Wi-Fi")
notify-send "Wi-Fi Disabled" -i "package-broken"
nmcli radio wifi off
exit
;;
*"Manual Entry")
# Prompt for SSID
manual_ssid=$(rofi -dmenu -config "${config}" -theme-str "${override_ssid}" -p " " || pkill -x rofi)
# Exit if no option is selected
if [ -z "$manual_ssid" ]; then
exit
fi
# Prompt for Wi-Fi password
wifi_password=$(get_password)
if [ -z "$wifi_password" ]; then
# Without password
if nmcli device wifi connect "$manual_ssid" | grep -q "successfully"; then
notify-send "Connected to \"$manual_ssid\"." -i "package-installed-outdated"
exit
else
notify-send "Failed to connect to \"$manual_ssid\"." -i "package-broken"
fi
else
# With password
if nmcli device wifi connect "$manual_ssid" password "$wifi_password" | grep -q "successfully"; then
notify-send "Connected to \"$manual_ssid\"." -i "package-installed-outdated"
exit
else
notify-send "Failed to connect to \"$manual_ssid\"." -i "package-broken"
fi
fi
;;
*)
# Get saved connections
saved_connections=$(nmcli -g NAME connection)
if echo "$saved_connections" | grep -qw "$selected_ssid"; then
if nmcli connection up id "$selected_ssid" | grep -q "successfully"; then
notify-send "Connected to \"$selected_ssid\"." -i "package-installed-outdated"
exit
else
notify-send "Failed to connect to \"$selected_ssid\"." -i "package-broken"
fi
else
# Handle secure network connection
if [[ "$selected_option" =~ ^"󰤪" ]]; then
wifi_password=$(get_password)
fi
if nmcli device wifi connect "$selected_ssid" password "$wifi_password" | grep -q "successfully"; then
notify-send "Connected to \"$selected_ssid\"." -i "package-installed-outdated"
exit
else
notify-send "Failed to connect to \"$selected_ssid\"." -i "package-broken"
fi
fi
;;
esac
done

84
waybar/scripts/wifi-status.sh Executable file
View File

@@ -0,0 +1,84 @@
#!/usr/bin/env bash
if ! command -v nmcli &>/dev/null; then
echo "{\"text\": \"󰤫\", \"tooltip\": \"nmcli utility is missing\"}"
exit 1
fi
# Check if Wi-Fi is enabled
wifi_status=$(nmcli radio wifi 2>/dev/null)
if [ "$wifi_status" = "disabled" ]; then
echo "{\"text\": \"󰤮\", \"tooltip\": \"Wi-Fi Disabled\"}"
exit 0
fi
# Initialize variables with defaults
essid="No Connection"
signal=0
tooltip="No Wi-Fi Connection"
ip_address="Not Connected"
security="None"
chan="N/A"
wifi_info=$(nmcli -t -f active,ssid,signal,security dev wifi 2>/dev/null | grep "^yes" | head -1)
if [ -n "$wifi_info" ]; then
# Parse the wifi info with error handling
essid=$(echo "$wifi_info" | awk -F: '{print $2}')
signal=$(echo "$wifi_info" | awk -F: '{print $3}')
security=$(echo "$wifi_info" | awk -F: '{print $4}')
# Set defaults if parsing failed
[ -z "$essid" ] && essid="Unknown"
[ -z "$signal" ] && signal=0
[ -z "$security" ] && security="None"
# Get active WiFi device, ignoring WireGuard interfaces
active_device=$(nmcli -t -f DEVICE,TYPE,STATE device status 2>/dev/null |
grep -E 'wifi:connected$' |
grep -v -E '^(wg0|wg1|wg2):' |
awk -F: '{print $1}' | head -1)
if [ -n "$active_device" ]; then
# Get IP address with error handling
ip_output=$(nmcli -e no -g ip4.address device show "$active_device" 2>/dev/null | head -1)
[ -n "$ip_output" ] && ip_address="$ip_output"
# Get channel and frequency info
wifi_details=$(nmcli -e no -t -f active,bssid,chan,freq device wifi 2>/dev/null | grep "^yes" | head -1)
if [ -n "$wifi_details" ]; then
chan_temp=$(echo "$wifi_details" | awk -F: '{print $8}')
freq_temp=$(echo "$wifi_details" | awk -F: '{print $9}')
[ -n "$chan_temp" ] && [ -n "$freq_temp" ] && chan="$chan_temp ($freq_temp)"
fi
# Build tooltip with proper formatting
tooltip="SSID: ${essid}"
tooltip+="\\nIP Address: ${ip_address}"
tooltip+="\\nSecurity: ${security}"
tooltip+="\\nChannel: ${chan}"
tooltip+="\\nStrength: ${signal}/100"
else
tooltip="Connected to: ${essid}\\nStrength: ${signal}/100\\nSecurity: ${security}"
fi
fi
# Ensure signal is a number for comparison
signal=$((signal + 0))
# Determine Wi-Fi icon based on signal strength
if [ "$signal" -ge 80 ]; then
icon="󰤨" # Strong signal
elif [ "$signal" -ge 60 ]; then
icon="󰤥" # Good signal
elif [ "$signal" -ge 40 ]; then
icon="󰤢" # Weak signal
elif [ "$signal" -ge 20 ]; then
icon="󰤟" # Very weak signal
else
icon="󰤯" # No signal
fi
# Output JSON with proper escaping
echo "{\"text\": \"${icon}\", \"tooltip\": \"${tooltip}\"}"