Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doas support❗ #1390

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Configs/.local/share/bin/globalcontrol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ export thmbDir="${cacheDir}/thumbs"
export dcolDir="${cacheDir}/dcols"
export hashMech="sha1sum"

# Function to execute a command with elevated privileges
SUPER() {
local command="$*"
print_prompt -y "[ROOT] " "${command}"
if command -v doas >/dev/null 2>&1 && [ -f /etc/doas.conf ]; then
doas sh -c "$command"
else
sudo sh -c "$command"
fi
}

export -f SUPER
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exported it just to be safe in case the script is nested.

get_hashmap()
{
unset wallHash
Expand Down
5 changes: 5 additions & 0 deletions Configs/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ function in {

if [[ ${#arch[@]} -gt 0 ]]; then
sudo pacman -S "${arch[@]}"
if command -v doas >/dev/null 2>&1 && [ -f /etc/doas.conf ]; then
doas pacman -S "${arch[@]}"
else
sudo pacman -S "${arch[@]}"
fi
fi

if [[ ${#aur[@]} -gt 0 ]]; then
Expand Down
2 changes: 1 addition & 1 deletion Scripts/.extra/install_fpk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [ $? -ne 0 ]; then
fi

if ! pkg_installed flatpak; then
sudo pacman -S flatpak
SUPER pacman -S flatpak
fi

flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Expand Down
6 changes: 3 additions & 3 deletions Scripts/.extra/install_mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

if [ $(lspci -k | grep -A 2 -E "(VGA|3D)" | grep -i nvidia | wc -l) -gt 0 ]; then
if [ $(grep 'MODULES=' /etc/mkinitcpio.conf | grep nvidia | wc -l) -eq 0 ]; then
sudo sed -i "/MODULES=/ s/)$/ nvidia nvidia_modeset nvidia_uvm nvidia_drm)/" /etc/mkinitcpio.conf
sudo mkinitcpio -P
SUPER sed -i "/MODULES=/ s/)$/ nvidia nvidia_modeset nvidia_uvm nvidia_drm)/" /etc/mkinitcpio.conf
SUPER mkinitcpio -P
if [ $(grep 'options nvidia-drm modeset=1' /etc/modprobe.d/nvidia.conf | wc -l) -eq 0 ]; then
echo 'options nvidia-drm modeset=1' | sudo tee -a /etc/modprobe.d/nvidia.conf
echo 'options nvidia-drm modeset=1' | SUPER tee -a /etc/modprobe.d/nvidia.conf
fi
fi
fi
8 changes: 4 additions & 4 deletions Scripts/.extra/restore_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ cloneDir=$(dirname "$(realpath "$cloneDir")")
#// icons

if [ -f /usr/share/applications/rofi-theme-selector.desktop ] && [ -f /usr/share/applications/rofi.desktop ]; then
sudo rm /usr/share/applications/rofi-theme-selector.desktop
sudo rm /usr/share/applications/rofi.desktop
SUPER rm /usr/share/applications/rofi-theme-selector.desktop
SUPER rm /usr/share/applications/rofi.desktop
fi
sudo sed -i "/^Icon=/c\Icon=adjust-colors" /usr/share/applications/nwg-look.desktop
sudo sed -i "/^Icon=/c\Icon=spectacle" /usr/share/applications/swappy.desktop
SUPER sed -i "/^Icon=/c\Icon=adjust-colors" /usr/share/applications/nwg-look.desktop
SUPER sed -i "/^Icon=/c\Icon=spectacle" /usr/share/applications/swappy.desktop


#// firefox
Expand Down
13 changes: 13 additions & 0 deletions Scripts/global_fn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ cacheDir="$HOME/.cache/hyde"
aurList=(yay paru)
shlList=(zsh fish)

# Function to execute a command with elevated privileges
SUPER() {
local command="$*"
print_prompt -y "[ROOT] " "${command}"
if command -v doas >/dev/null 2>&1 && [ -f /etc/doas.conf ]; then
doas sh -c "$command"
else
sudo sh -c "$command"
fi
}

export -f SUPER

pkg_installed() {
local PkgIn=$1

Expand Down
4 changes: 2 additions & 2 deletions Scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ EOF
echo -e "\033[0;33m[SKIP]\033[0m ${servChk} service is active..."
else
echo -e "\033[0;32m[systemctl]\033[0m starting ${servChk} system service..."
sudo systemctl enable "${servChk}.service"
sudo systemctl start "${servChk}.service"
SUPER systemctl enable "${servChk}.service"
SUPER systemctl start "${servChk}.service"
fi

done < "${scrDir}/system_ctl.lst"
Expand Down
2 changes: 1 addition & 1 deletion Scripts/install_pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ done < <(cut -d '#' -f 1 "${listPkg}")
IFS=${ofs}

if [[ ${#archPkg[@]} -gt 0 ]]; then
sudo pacman ${use_default} -S "${archPkg[@]}"
SUPER pacman ${use_default} -S "${archPkg[@]}"
fi

if [[ ${#aurhPkg[@]} -gt 0 ]]; then
Expand Down
28 changes: 14 additions & 14 deletions Scripts/install_pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ if pkg_installed grub && [ -f /boot/grub/grub.cfg ]; then

if [ ! -f /etc/default/grub.t2.bkp ] && [ ! -f /boot/grub/grub.t2.bkp ]; then
echo -e "\033[0;32m[BOOTLOADER]\033[0m configuring grub..."
sudo cp /etc/default/grub /etc/default/grub.t2.bkp
sudo cp /boot/grub/grub.cfg /boot/grub/grub.t2.bkp
SUPER cp /etc/default/grub /etc/default/grub.t2.bkp
SUPER cp /boot/grub/grub.cfg /boot/grub/grub.t2.bkp

if nvidia_detect; then
echo -e "\033[0;32m[BOOTLOADER]\033[0m nvidia detected, adding nvidia_drm.modeset=1 to boot option..."
gcld=$(grep "^GRUB_CMDLINE_LINUX_DEFAULT=" "/etc/default/grub" | cut -d'"' -f2 | sed 's/\b nvidia_drm.modeset=.\b//g')
sudo sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT=/c\GRUB_CMDLINE_LINUX_DEFAULT=\"${gcld} nvidia_drm.modeset=1\"" /etc/default/grub
SUPER sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT=/c\GRUB_CMDLINE_LINUX_DEFAULT=\"${gcld} nvidia_drm.modeset=1\"" /etc/default/grub
fi

echo -e "Select grub theme:\n[1] Retroboot (dark)\n[2] Pochita (light)"
Expand All @@ -36,18 +36,18 @@ if pkg_installed grub && [ -f /boot/grub/grub.cfg ]; then

if [ "${grubtheme}" == "None" ]; then
echo -e "\033[0;32m[BOOTLOADER]\033[0m Skippinng grub theme..."
sudo sed -i "s/^GRUB_THEME=/#GRUB_THEME=/g" /etc/default/grub
SUPER sed -i "s/^GRUB_THEME=/#GRUB_THEME=/g" /etc/default/grub
else
echo -e "\033[0;32m[BOOTLOADER]\033[0m Setting grub theme // ${grubtheme}"
sudo tar -xzf ${cloneDir}/Source/arcs/Grub_${grubtheme}.tar.gz -C /usr/share/grub/themes/
sudo sed -i "/^GRUB_DEFAULT=/c\GRUB_DEFAULT=saved
SUPER tar -xzf ${cloneDir}/Source/arcs/Grub_${grubtheme}.tar.gz -C /usr/share/grub/themes/
SUPER sed -i "/^GRUB_DEFAULT=/c\GRUB_DEFAULT=saved
/^GRUB_GFXMODE=/c\GRUB_GFXMODE=1280x1024x32,auto
/^GRUB_THEME=/c\GRUB_THEME=\"/usr/share/grub/themes/${grubtheme}/theme.txt\"
/^#GRUB_THEME=/c\GRUB_THEME=\"/usr/share/grub/themes/${grubtheme}/theme.txt\"
/^#GRUB_SAVEDEFAULT=true/c\GRUB_SAVEDEFAULT=true" /etc/default/grub
fi

sudo grub-mkconfig -o /boot/grub/grub.cfg
SUPER grub-mkconfig -o /boot/grub/grub.cfg
else
echo -e "\033[0;33m[SKIP]\033[0m grub is already configured..."
fi
Expand All @@ -60,9 +60,9 @@ if pkg_installed systemd && nvidia_detect && [ $(bootctl status 2> /dev/null | a
if [ $(ls -l /boot/loader/entries/*.conf.t2.bkp 2> /dev/null | wc -l) -ne $(ls -l /boot/loader/entries/*.conf 2> /dev/null | wc -l) ]; then
echo "nvidia detected, adding nvidia_drm.modeset=1 to boot option..."
find /boot/loader/entries/ -type f -name "*.conf" | while read imgconf; do
sudo cp ${imgconf} ${imgconf}.t2.bkp
SUPER cp ${imgconf} ${imgconf}.t2.bkp
sdopt=$(grep -w "^options" ${imgconf} | sed 's/\b quiet\b//g' | sed 's/\b splash\b//g' | sed 's/\b nvidia_drm.modeset=.\b//g')
sudo sed -i "/^options/c${sdopt} quiet splash nvidia_drm.modeset=1" ${imgconf}
SUPER sed -i "/^options/c${sdopt} quiet splash nvidia_drm.modeset=1" ${imgconf}
done
else
echo -e "\033[0;33m[SKIP]\033[0m systemd-boot is already configured..."
Expand All @@ -73,14 +73,14 @@ fi
if [ -f /etc/pacman.conf ] && [ ! -f /etc/pacman.conf.t2.bkp ]; then
echo -e "\033[0;32m[PACMAN]\033[0m adding extra spice to pacman..."

sudo cp /etc/pacman.conf /etc/pacman.conf.t2.bkp
sudo sed -i "/^#Color/c\Color\nILoveCandy
SUPER cp /etc/pacman.conf /etc/pacman.conf.t2.bkp
SUPER sed -i "/^#Color/c\Color\nILoveCandy
/^#VerbosePkgLists/c\VerbosePkgLists
/^#ParallelDownloads/c\ParallelDownloads = 5" /etc/pacman.conf
sudo sed -i '/^#\[multilib\]/,+1 s/^#//' /etc/pacman.conf
SUPER sed -i '/^#\[multilib\]/,+1 s/^#//' /etc/pacman.conf

sudo pacman -Syyu
sudo pacman -Fy
SUPER pacman -Syyu
SUPER pacman -Fy

else
echo -e "\033[0;33m[SKIP]\033[0m pacman is already configured..."
Expand Down
12 changes: 6 additions & 6 deletions Scripts/install_pst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if pkg_installed sddm; then

echo -e "\033[0;32m[DISPLAYMANAGER]\033[0m detected // sddm"
if [ ! -d /etc/sddm.conf.d ]; then
sudo mkdir -p /etc/sddm.conf.d
SUPER mkdir -p /etc/sddm.conf.d
fi

if [ ! -f /etc/sddm.conf.d/kde_settings.t2.bkp ]; then
Expand All @@ -29,16 +29,16 @@ if pkg_installed sddm; then
*) sddmtheme="Corners" ;;
esac

sudo tar -xzf ${cloneDir}/Source/arcs/Sddm_${sddmtheme}.tar.gz -C /usr/share/sddm/themes/
sudo touch /etc/sddm.conf.d/kde_settings.conf
sudo cp /etc/sddm.conf.d/kde_settings.conf /etc/sddm.conf.d/kde_settings.t2.bkp
sudo cp /usr/share/sddm/themes/${sddmtheme}/kde_settings.conf /etc/sddm.conf.d/
SUPER tar -xzf ${cloneDir}/Source/arcs/Sddm_${sddmtheme}.tar.gz -C /usr/share/sddm/themes/
SUPER touch /etc/sddm.conf.d/kde_settings.conf
SUPER cp /etc/sddm.conf.d/kde_settings.conf /etc/sddm.conf.d/kde_settings.t2.bkp
SUPER cp /usr/share/sddm/themes/${sddmtheme}/kde_settings.conf /etc/sddm.conf.d/
else
echo -e "\033[0;33m[SKIP]\033[0m sddm is already configured..."
fi

if [ ! -f /usr/share/sddm/faces/${USER}.face.icon ] && [ -f ${cloneDir}/Source/misc/${USER}.face.icon ]; then
sudo cp ${cloneDir}/Source/misc/${USER}.face.icon /usr/share/sddm/faces/
SUPER cp ${cloneDir}/Source/misc/${USER}.face.icon /usr/share/sddm/faces/
echo -e "\033[0;32m[DISPLAYMANAGER]\033[0m avatar set for ${USER}..."
fi

Expand Down
4 changes: 2 additions & 2 deletions Scripts/restore_fnt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ cat "${scrDir}/restore_fnt.lst" | while read lst; do
fi

if [ ! -d "${tgt}" ]; then
mkdir -p "${tgt}" || echo "creating the directory as root instead..." && sudo mkdir -p "${tgt}"
mkdir -p "${tgt}" || echo "creating the directory as root instead..." && SUPER mkdir -p "${tgt}"
echo -e "\033[0;32m[extract]\033[0m ${tgt} directory created..."
fi

sudo tar -xzf "${cloneDir}/Source/arcs/${fnt}.tar.gz" -C "${tgt}/"
SUPER tar -xzf "${cloneDir}/Source/arcs/${fnt}.tar.gz" -C "${tgt}/"
echo -e "\033[0;32m[extract]\033[0m ${fnt}.tar.gz --> ${tgt}..."

done
Expand Down
2 changes: 1 addition & 1 deletion Scripts/restore_shl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if pkg_installed zsh && pkg_installed oh-my-zsh-git; then
while read r_plugin; do
z_plugin=$(echo "${r_plugin}" | awk -F '/' '{print $NF}')
if [ "${r_plugin:0:4}" == "http" ] && [ ! -d "${Zsh_Plugins}/${z_plugin}" ]; then
sudo git clone "${r_plugin}" "${Zsh_Plugins}/${z_plugin}"
SUPER git clone "${r_plugin}" "${Zsh_Plugins}/${z_plugin}"
fi
if [ "${z_plugin}" == "zsh-completions" ] && [ "$(grep 'fpath+=.*plugins/zsh-completions/src' "${Zsh_rc}" | wc -l)" -eq 0 ]; then
Fix_Completion='\nfpath+=${ZSH_CUSTOM:-${ZSH:-/usr/share/oh-my-zsh}/custom}/plugins/zsh-completions/src'
Expand Down