update config

This commit is contained in:
2025-11-23 11:42:35 +01:00
parent fab7d2f157
commit 91df449304
73 changed files with 8450 additions and 338 deletions

View File

@@ -0,0 +1,66 @@
#!/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 "$@"

View File

@@ -0,0 +1,120 @@
#!/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,82 @@
#!/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

@@ -0,0 +1,99 @@
#!/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

@@ -0,0 +1,49 @@
#!/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'
)
main() {
# shellcheck disable=SC1090
. ~/.config/waybar/scripts/fzf-colors.sh 2> /dev/null
local opts=(
--border=sharp
--border-label=' Power Menu '
--height=~100%
--highlight-line
--no-input
--pointer=
--reverse
"${COLORS[@]}"
)
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

View File

@@ -0,0 +1,82 @@
#!/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
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
}
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...'
}
display-module() {
local tooltip="Official: $repo"
if [[ -n $helper ]]; then
tooltip+="\nAUR($helper): $aur"
fi
local total=$((repo + aur))
if ((total == 0)); then
echo "{ \"text\": \"󰸟\", \"tooltip\": \"No updates available\" }"
else
echo "{ \"text\": \"\", \"tooltip\": \"$tooltip\" }"
fi
}
main() {
local arg=$1
local helpers=(aura paru pikaur trizen yay)
local bin
bin=$(command -v "${helpers[@]}" | head -n 1)
helper=${bin##*/}
repo=0
aur=0
case $arg in
'module')
check-updates
display-module
;;
*)
printf '%bChecking for updates...%b' "$BLU" "$RST"
check-updates
update-packages
;;
esac
}
main "$@"

159
.config/waybar/scripts/volume.sh Executable file
View File

@@ -0,0 +1,159 @@
#!/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 "$@"