nixos-config/modules/home/scripts/scripts/unfuck.sh

105 lines
2.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# unfuck system when shit goes wrong
unfuckable=(
2025-06-09 14:02:03 +02:00
"wallpaper"
"bar"
"networkmanager"
"spotify"
"audio"
"screenlock"
)
usage() {
2025-06-09 14:02:03 +02:00
echo "INFO: usage; unfuck [OPTION]"
echo "INFO: example; unfuck everything"
echo ""
echo "INFO: items: ${unfuckable[*]}"
echo ""
echo "WARN: unfuck everything should only be used when *everything* is broken and nothing works anymore!"
}
unfuck_wallpaper() {
2025-06-09 14:02:03 +02:00
pkill swww-daemon
setsid swww-daemon &
swww img ~/.local/share/bg.png
}
2025-07-17 14:00:48 +02:00
unfuck_fingerprint() {
notify-send "Touch sensor or use YubiKey." "Sleeping for 10 seconds."
sleep 10
sudo systemctl restart fprintd.service
2025-07-17 14:00:48 +02:00
}
unfuck_bar() {
2025-06-09 14:02:03 +02:00
pkill waybar
setsid waybar &
}
2025-12-16 18:50:05 +01:00
unfuck_dock() {
pkill .nwg-dock-hyprl
setsid dock-on-all-monitors &
2025-12-16 18:50:05 +01:00
}
unfuck_networkmanager() {
2025-06-09 14:02:03 +02:00
# sudo modprobe -r iwlwifi
# sudo modprobe iwlwifi
notify-send "Touch sensor or use YubiKey." "Sleeping for 10 seconds."
sleep 10
2025-06-09 14:02:03 +02:00
sudo systemctl restart NetworkManager
}
unfuck_spotify() {
2025-06-09 14:02:03 +02:00
if pgrep ncspot; then
pkill ncspot
kitty -e ncspot
elif pgrep spotify; then
pkill spotify
spotify
fi
}
unfuck_audio() {
2025-06-09 14:02:03 +02:00
if [[ "$(playerctl status)" == "Playing" ]]; then
playerctl pause
fi
for device in $(bluetoothctl devices Connected | awk '{print $2}'); do
devices+=("$device")
done
systemctl --user restart wireplumber pipewire pipewire-pulse bluetooth
rfkill block bluetooth
rfkill unblock bluetooth
2025-06-09 14:02:03 +02:00
bluetoothctl power off
bluetoothctl power on
for device in ${devices[*]}; do
# because bluetooth is the worst thing ever created and defaults to handset mode, devices will need to reconnect
echo "INFO: disconnecting and reconnecting to $device"
bluetoothctl disconnect "$device"
bluetoothctl connect "$device"
done
}
unfuck_screenlock() {
2025-06-09 14:02:03 +02:00
hyprctl --instance 0 'keyword misc:allow_session_lock_restore 1'
hyprctl --instance 0 'dispatch exec hyprlock'
}
case $1 in
"")
2025-06-09 14:02:03 +02:00
echo "what is fucked?"
;;
-h | --help | help)
2025-06-09 14:02:03 +02:00
usage
;;
everything)
2025-06-09 14:02:03 +02:00
unfuck_screenlock
unfuck_bar
unfuck_spotify
unfuck_wallpaper
2025-07-17 14:00:48 +02:00
unfuck_fingerprint
2025-06-09 14:02:03 +02:00
;;
*)
2025-06-09 14:02:03 +02:00
eval "unfuck_$1"
;;
esac