mirror of
https://github.com/xsghetti/HyprCrux.git
synced 2025-07-03 05:40:38 -04:00
110 lines
2.2 KiB
Bash
110 lines
2.2 KiB
Bash
#!/bin/bash
|
|
#|---/ /+------------------+---/ /|#
|
|
#|--/ /-| Global functions |--/ /-|#
|
|
#|-/ /--| Prasanth Rangan |-/ /--|#
|
|
#|/ /---+------------------+/ /---|#
|
|
|
|
set -e
|
|
|
|
CloneDir=`dirname "$(dirname "$(realpath "$0")")"`
|
|
ConfDir="${XDG_CONFIG_HOME:-$HOME/.config}"
|
|
HyprdotsDir="${ConfDir}/hyprdots"
|
|
ThemeCtl="${HyprdotsDir}/theme.ctl"
|
|
|
|
service_ctl()
|
|
{
|
|
local ServChk=$1
|
|
|
|
if [[ $(systemctl list-units --all -t service --full --no-legend "${ServChk}.service" | sed 's/^\s*//g' | cut -f1 -d' ') == "${ServChk}.service" ]]
|
|
then
|
|
echo "$ServChk service is already enabled, enjoy..."
|
|
else
|
|
echo "$ServChk service is not running, enabling..."
|
|
sudo systemctl enable ${ServChk}.service
|
|
sudo systemctl start ${ServChk}.service
|
|
echo "$ServChk service enabled, and running..."
|
|
fi
|
|
}
|
|
|
|
pkg_installed()
|
|
{
|
|
local PkgIn=$1
|
|
|
|
if pacman -Qi $PkgIn &> /dev/null
|
|
then
|
|
#echo "${PkgIn} is already installed..."
|
|
return 0
|
|
else
|
|
#echo "${PkgIn} is not installed..."
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
pkg_available()
|
|
{
|
|
local PkgIn=$1
|
|
|
|
if pacman -Si $PkgIn &> /dev/null
|
|
then
|
|
#echo "${PkgIn} available in arch repo..."
|
|
return 0
|
|
else
|
|
#echo "${PkgIn} not available in arch repo..."
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
chk_aurh()
|
|
{
|
|
if pkg_installed yay
|
|
then
|
|
aurhlpr="yay"
|
|
elif pkg_installed paru
|
|
then
|
|
aurhlpr="paru"
|
|
fi
|
|
}
|
|
|
|
aur_available()
|
|
{
|
|
local PkgIn=$1
|
|
chk_aurh
|
|
|
|
if $aurhlpr -Si $PkgIn &> /dev/null
|
|
then
|
|
#echo "${PkgIn} available in aur repo..."
|
|
return 0
|
|
else
|
|
#echo "aur helper is not installed..."
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
nvidia_detect()
|
|
{
|
|
if [ `lspci -k | grep -A 2 -E "(VGA|3D)" | grep -i nvidia | wc -l` -gt 0 ]
|
|
then
|
|
#echo "nvidia card detected..."
|
|
return 0
|
|
else
|
|
#echo "nvidia card not detected..."
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
prompt_timer()
|
|
{
|
|
set +e
|
|
local timsec=$1
|
|
local msg=$2
|
|
local pread=""
|
|
while [[ $timsec -ge 0 ]] ; do
|
|
echo -ne "\033[0K\r${msg} (${timsec}s) : "
|
|
read -t 1 -n 1 -s promptIn
|
|
[ $? -eq 0 ] && break
|
|
((timsec--))
|
|
done
|
|
export promptIn
|
|
echo ${promptIn}
|
|
set -e
|
|
}
|