mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-04-19 21:42:53 -05:00
Added preliminary support for zsh
This commit is contained in:
parent
fbae8a9b72
commit
35c1b60a56
2 changed files with 51 additions and 30 deletions
31
install.sh
31
install.sh
|
@ -1,10 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/zsh
|
||||||
|
|
||||||
version='0.1'
|
version='0.1'
|
||||||
bashrc="/home/$USER/.bashrc"
|
bashrc="/home/$USER/.bashrc"
|
||||||
|
zshrc="/home/$USER/.zshrc"
|
||||||
originaldir=$PWD
|
originaldir=$PWD
|
||||||
|
environment=$(readlink /proc/$$/exe)
|
||||||
if ! grep -q 'bash /home/$USER/.welcome/welcome.sh' $bashrc;
|
if [[ "$environment" = "/usr/bin/bash" ]] || [[ "$environment" = "/usr/bin/zsh" ]];
|
||||||
|
then
|
||||||
|
if ! grep -q 'bash /home/$USER/.welcome/welcome.sh' $bashrc && ! grep -q 'zsh /home/$USER/.welcome/welcome.sh' $zshrc;
|
||||||
then
|
then
|
||||||
tput sc
|
tput sc
|
||||||
echo "Welcome! Installing..."
|
echo "Welcome! Installing..."
|
||||||
|
@ -12,21 +15,36 @@ then
|
||||||
mkdir -p /home/$USER/.welcome
|
mkdir -p /home/$USER/.welcome
|
||||||
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v${version}/welcome.sh --output /home/$USER/.welcome/welcome.sh
|
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v${version}/welcome.sh --output /home/$USER/.welcome/welcome.sh
|
||||||
chmod +x /home/$USER/.welcome/welcome.sh
|
chmod +x /home/$USER/.welcome/welcome.sh
|
||||||
|
if [[ "$environment" = "/usr/bin/bash" ]];
|
||||||
|
then
|
||||||
echo 'bash /home/$USER/.welcome/welcome.sh' >> $bashrc
|
echo 'bash /home/$USER/.welcome/welcome.sh' >> $bashrc
|
||||||
|
echo "Installing to bashrc"
|
||||||
|
elif [[ "$environment" = "/usr/bin/zsh" ]];
|
||||||
|
then
|
||||||
|
echo 'zsh /home/$USER/.welcome/welcome.sh' >> $zshrc
|
||||||
|
echo "Installing to zshrc"
|
||||||
|
fi
|
||||||
|
cd "$originaldir"
|
||||||
tput rc el ed
|
tput rc el ed
|
||||||
echo -e "\e[36mInstalled! \e[0m"
|
echo -e "\e[36mInstalled! \e[0m"
|
||||||
cd "$originaldir"
|
|
||||||
else
|
else
|
||||||
tput sc
|
tput sc
|
||||||
echo -e "\e[35mwelcome.sh\e[0m already installed!"
|
echo -e "\e[35mwelcome.sh\e[0m already installed!"
|
||||||
echo -en "Do you want to \e[31muninstall \e[35mwelcome.sh\e[0m?\n\e[36mY/n\e[0m"
|
echo -en "Do you want to \e[31muninstall \e[35mwelcome.sh\e[0m?\n\e[36mY/n\e[0m"
|
||||||
|
if [[ "$environment" = "/usr/bin/bash" ]]
|
||||||
|
then
|
||||||
read -p " " -n 1 -r
|
read -p " " -n 1 -r
|
||||||
|
elif [[ "$environment" = "/usr/bin/zsh" ]]
|
||||||
|
then
|
||||||
|
read -q "REPLY? " -n 1 -r
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||||
then
|
then
|
||||||
rm /home/$USER/.welcome/welcome.sh
|
rm /home/$USER/.welcome/welcome.sh
|
||||||
rmdir /home/$USER/.welcome
|
rmdir /home/$USER/.welcome
|
||||||
sed -i 's#bash /home/$USER/.welcome/welcome.sh##g' $bashrc
|
sed -i 's#bash /home/$USER/.welcome/welcome.sh##g' $bashrc # Try from both
|
||||||
|
sed -i 's#zsh /home/$USER/.welcome/welcome.sh##g' $zshrc
|
||||||
tput rc el ed
|
tput rc el ed
|
||||||
echo -e "\e[36mUninstalled! \e[0m"
|
echo -e "\e[36mUninstalled! \e[0m"
|
||||||
else
|
else
|
||||||
|
@ -34,3 +52,6 @@ else
|
||||||
echo -e "\e[32mCancelled. \e[0m"
|
echo -e "\e[32mCancelled. \e[0m"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "This script can only be installed in bash or zsh."
|
||||||
|
fi
|
||||||
|
|
|
@ -52,10 +52,10 @@ battery () {
|
||||||
# Set a default to prevent errors
|
# Set a default to prevent errors
|
||||||
batlvl=0
|
batlvl=0
|
||||||
|
|
||||||
if [ -a /sys/class/power_supply/BAT0/capacity ];
|
if [[ -a "/sys/class/power_supply/BAT0/capacity" ]];
|
||||||
then
|
then
|
||||||
batlvl=$(cat /sys/class/power_supply/BAT0/capacity)
|
batlvl=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||||
elif [ -a /sys/class/power_supply/BAT1/capacity ];
|
elif [[ -a "/sys/class/power_supply/BAT1/capacity" ]];
|
||||||
then
|
then
|
||||||
batlvl=$(cat /sys/class/power_supply/BAT1/capacity)
|
batlvl=$(cat /sys/class/power_supply/BAT1/capacity)
|
||||||
fi
|
fi
|
||||||
|
@ -69,7 +69,7 @@ battery () {
|
||||||
if [ $batlvl -le 15 ];
|
if [ $batlvl -le 15 ];
|
||||||
then
|
then
|
||||||
echo -en "${CRIT}$batlvl%${NCOL}. "
|
echo -en "${CRIT}$batlvl%${NCOL}. "
|
||||||
if [ $rechargenotif == "on" ];
|
if [ "$rechargenotif" = "on" ];
|
||||||
then
|
then
|
||||||
echo -en "- ${NORM}You should probably recharge${NCOL}. "
|
echo -en "- ${NORM}You should probably recharge${NCOL}. "
|
||||||
fi
|
fi
|
||||||
|
@ -132,7 +132,7 @@ updates () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for Flatpak
|
# Check for Flatpak
|
||||||
if command -v flatpak &> /dev/null && [ $flatpakupd == "on" ];
|
if command -v flatpak &> /dev/null && [ "$flatpakupd" = "on" ];
|
||||||
then
|
then
|
||||||
flatpak=$(flatpak remote-ls --updates 2> /dev/null | wc -l)
|
flatpak=$(flatpak remote-ls --updates 2> /dev/null | wc -l)
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue