dotfiles/bash/.bash/03-boot.bash

52 lines
1.6 KiB
Bash
Raw Normal View History

2022-11-16 19:01:14 -07:00
#!/bin/bash
2022-03-22 00:04:49 -06:00
#
# 03-boot.bash
# startup scripts for systems
2022-10-26 12:05:56 -06:00
bat_check() {
2022-12-11 01:03:47 -07:00
TEST=$(acpi | grep "Discharging" | grep -v "rate information")
2022-10-26 12:05:56 -06:00
if [[ $? -eq 0 ]]; then
echo "***********************************************************"
echo " WARNING"
echo "***********************************************************"
echo "Power supply is not plugged in."
echo "Make sure it is plugged in to avoid a random shutdown."
read -rs -N 1 -p "Press [Enter] to continue, any other key to return..." input;
if grep -q "$input" <<< ""; then
echo ""
else
return 1
fi
fi
}
2022-03-22 00:04:49 -06:00
# run startup script if tty
# for dingo
if [[ $TERM == 'linux' && $(hostname) == 'dingo' ]]; then
cat ~/bin/house.txt
printf "\n${CYAN}Welcome back Bryson :)\n\n"
2022-10-26 12:05:56 -06:00
printf "${LGREEN}What should dingo do?\n${magenta}"
echo -e '\td: start docked\n\tn: start not docked\n\tq: shutdown\n\tr: reboot\n\tl: logout\n\tb: bash\n\n'
2022-03-22 00:04:49 -06:00
while read -rs -N 1 key; do
printf "${NC}"
2022-03-22 00:04:49 -06:00
case $key in
2022-10-26 12:05:56 -06:00
d) bat_check && startx ;;
2022-03-22 00:04:49 -06:00
n) nstartx.sh ;;
q) echo "Are you sure you want to shutdown? (y/n)";
2022-10-26 12:05:56 -06:00
read -rs -N 1 key2; case $key2 in y) doas shutdown -Ph now ;; esac; ;;
2022-03-22 00:04:49 -06:00
r) echo "Are you sure you want to reboot? (y/n)";
2022-10-26 12:05:56 -06:00
read -rs -N 1 key3; case $key3 in y) doas reboot ;; esac; ;;
l) logout ;;
2022-03-22 00:04:49 -06:00
b) break ;;
[h?]) echo "$USAGE";;
esac
clear
2022-10-26 12:05:56 -06:00
cat ~/bin/house.txt
printf "\n${LGREEN}What should dingo do now?\n${magenta}"
echo -e '\td: start docked\n\tn: start not docked\n\tq: shutdown\n\tr: reboot\n\tl: logout\n\tb: bash\n\n'
2022-03-22 00:04:49 -06:00
done
fi