Skip to content

Commit

Permalink
feat(just): add quick options for use in yafti
Browse files Browse the repository at this point in the history
  • Loading branch information
HikariKnight committed Jan 7, 2024
1 parent b069be4 commit 36654a0
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 39 deletions.
21 changes: 15 additions & 6 deletions build/ublue-os-just/10-update.just
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,33 @@ update-firmware:
fwupdmgr update

# Turn automatic updates on or off
toggle-updates:
toggle-updates ARG="prompt":
#!/usr/bin/env bash
CURRENT_STATE="Disabled"
if systemctl is-enabled ublue-update.timer | grep -q enabled; then
CURRENT_STATE="Enabled"
fi
bold=$(tput bold)
normal=$(tput sgr0)
echo "Automatic updates are currently: ${bold}${CURRENT_STATE}${normal}"
echo "Enable or Disable automatic updates?"
OPTION=$(ugum choose Enable Disable)
if [ "$OPTION" == "Enable" ]; then
OPTION={{ARG}}
if [ "$OPTION" == "prompt" ]; then
echo "Automatic updates are currently: ${bold}${CURRENT_STATE}${normal}"
echo "Enable or Disable automatic updates?"
OPTION=$(ugum choose Enable Disable)
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust toggle-updates <option>"
echo " <option>: Specify the quick option - 'enable' or 'disable'"
echo " Use 'enable' to Enable automatic updates."
echo " Use 'disable' to Disable automatic updates."
exit 0
fi
if [ "${OPTION,,}" == "Enable" ]; then
sudo systemctl enable ublue-update.timer
if systemctl is-enabled flatpak-system-update.timer | grep -q disabled; then
sudo systemctl enable --now flatpak-system-update.timer rpm-ostreed-automatic.timer
systemctl enable --now --user flatpak-user-update.timer
fi
elif [ "$OPTION" == "Disable" ]; then
elif [ "${OPTION,,}" == "Disable" ]; then
sudo systemctl disable ublue-update.timer
if systemctl is-enabled flatpak-system-update.timer | grep -q enabled; then
sudo systemctl disable --now flatpak-system-update.timer rpm-ostreed-automatic.timer
Expand Down
24 changes: 17 additions & 7 deletions build/ublue-os-just/40-nvidia.just
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# vim: set ft=make :

# Configure the Nvidia driver
configure-nvidia:
configure-nvidia ARG="prompt":
#!/usr/bin/env bash
bold=$(tput bold)
normal=$(tput sgr0)
echo "${bold}Configuring Nvidia drivers${normal}"
echo 'What would you like to do?'
OPTION=$(ugum choose "Set needed kernel arguments" "Test CUDA support" "Enable Nvidia VAAPI in Firefox Flatpak")
if [ "$OPTION" == "Set needed kernel arguments" ]; then
OPTION={{ARG}}
if [ "$OPTION" == "prompt" ]; then
echo "${bold}Configuring Nvidia drivers${normal}"
echo 'What would you like to do?'
OPTION=$(ugum choose "Set needed kernel arguments" "Test CUDA support" "Enable Nvidia VAAPI in Firefox Flatpak")
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust configure-nvidia <option>"
echo " <option>: Specify the quick option - 'kargs', 'test-cuda' or 'firefox-vaapi'"
echo " Use 'kargs' to Set needed kernel arguments"
echo " Use 'test-cuda' to Test CUDA support"
echo " Use 'firefox-vaapi' to Enable Nvidia VAAPI in Firefox Flatpak."
exit 0
fi
if [ "$OPTION" == "Set needed kernel arguments" ] || [ "${OPTION,,}" == "kargs" ]; then
if command -v nvidia-smi; then
rpm-ostree kargs \
--append-if-missing=rd.driver.blacklist=nouveau \
Expand All @@ -18,7 +28,7 @@ configure-nvidia:
else
echo 'You do not appear to be on a Nvidia image, please refer to the README for your uBlue-OS image.'
fi
elif [ "$OPTION" == "Test CUDA support" ]; then
elif [ "$OPTION" == "Test CUDA support" ] || [ "${OPTION,,}" == "test-cuda" ]; then
if lsmod | grep -wq "nvidia"; then
podman run \
--user 1000:1000 \
Expand All @@ -30,7 +40,7 @@ configure-nvidia:
else
echo 'The Nvidia kernel module is not loaded. You may be using secure boot without the needed signing key, lacking the needed kargs, or may not be on a Nvidia image. See "just enroll-secure-boot-key" and "just nvidia-set-kargs".'
fi
elif [ "$OPTION" == "Enable Nvidia VAAPI in Firefox Flatpak" ]; then
elif [ "$OPTION" == "Enable Nvidia VAAPI in Firefox Flatpak" ] || [ "${OPTION,,}" == "firefox-vaapi" ]; then
if lsmod | grep -wq "nvidia"; then
flatpak override \
--user \
Expand Down
50 changes: 36 additions & 14 deletions build/ublue-os-just/50-akmods.just
Original file line number Diff line number Diff line change
@@ -1,39 +1,61 @@
# vim: set ft=make :

# Configure gamepad drivers
configure-gamepads:
configure-gamepads ARG="prompt":
#!/usr/bin/env bash
bold=$(tput bold)
normal=$(tput sgr0)
echo "${bold}Configuring gamepad drivers${normal}"
echo 'Which drivers do you want to use?'
echo 'Note: Enabling xone and xpadneo can break some 3rd party controllers'
OPTION=$(ugum choose "Default Fedora drivers" "Enable xone and xpadneo" )
if [ "$OPTION" == "Enable xone and xpadneo" ]; then
OPTION={{ARG}}
if [ "$OPTION" == "prompt" ]; then
echo "${bold}Configuring gamepad drivers${normal}"
echo 'Which drivers do you want to use?'
echo 'Note: Enabling xone and xpadneo can break some 3rd party controllers'
OPTION=$(ugum choose "Default Fedora drivers" "Enable xone and xpadneo")
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust configure-gamepads <option>"
echo " <option>: Specify the quick option - 'stock' or 'ublue'"
echo " Use 'stock' to select Default Fedora Drivers"
echo " Use 'ublue' to select Enable xone and xpadneo"
exit 0
fi
if [ "$OPTION" == "Enable xone and xpadneo" ] || [ "$OPTION" == "ublue" ]; then
sudo rm -f /etc/modprobe.d/xone.conf
sudo rm -f /etc/modprobe.d/xpadneo.conf
sudo rm -f /etc/modprobe.d/xpad-noone-blacklist.conf
sudo rm -f /etc/modules-load.d/xpad-noone.conf
elif [ "$OPTION" == "Default Fedora drivers" ]; then
echo "${bold}Enabled${normal} xone and xpadneo, please reboot for changes to take effect"
elif [ "$OPTION" == "Default Fedora drivers" ] || [ "$OPTION" == "stock" ]; then
sudo bash -c '> /etc/modprobe.d/xone.conf'
sudo bash -c '> /etc/modprobe.d/xpadneo.conf'
sudo bash -c '> /etc/modprobe.d/xpad-noone-blacklist.conf'
sudo bash -c '> /etc/modules-load.d/xpad-noone.conf'
echo "${bold}Disabled${normal} xone and xpadneo, please reboot for changes to take effect"
fi

# Configure Broadcom WL driver (Enabling WL breaks numerous other Wi-Fi adapters)
configure-broadcom-wl:
configure-broadcom-wl ARG="prompt":
#!/usr/bin/env bash
bold=$(tput bold)
normal=$(tput sgr0)
echo "${bold}Configuring Broadcom Wi-Fi${normal}"
echo 'Enabling Broadcom WL driver will break numerous other Wi-Fi adapters.'
echo 'Enable or Disable Broadcom Wl?'
OPTION=$(ugum choose Enable Disable)
if [ "$OPTION" == "Enable" ]; then
OPTION={{ARG}}
if [ "$OPTION" == "prompt" ]; then
echo "${bold}Configuring Broadcom Wi-Fi${normal}"
echo 'Enabling Broadcom WL driver will break numerous other Wi-Fi adapters.'
echo 'Enable or Disable Broadcom Wl?'
OPTION=$(ugum choose Enable Disable)
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust configure-broadcom-wl <option>"
echo " <option>: Specify the quick option - 'enable' or 'disable'"
echo " Use 'enable' to select Enable"
echo " Use 'disable' to select Disable"
exit 0
fi
if [ "${OPTION,,}" == "enable" ]; then
sudo rm -f /etc/modprobe.d/broadcom-wl-blacklist.conf
sudo rm -f /etc/modprobe.d/default-disable-broadcom-wl.conf
elif [ "$OPTION" == "Disable" ]; then
echo "${bold}Enabled${normal} Broadcom Wireless, please reboot for changes to take effect"
elif [ "${OPTION,,}" == "disable" ]; then
sudo bash -c '> /etc/modules-load.d/broadcom-wl-blacklist.conf'
sudo bash -c 'echo "blacklist wl" > /etc/modules-load.d/default-disable-broadcom-wl.conf'
echo "${bold}Disabled${normal} Broadcom Wireless, please reboot for changes to take effect"
fi
43 changes: 31 additions & 12 deletions build/ublue-os-just/70-nix.just
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,35 @@ setup-nix:
fi

# Install, uninstall or configure Fleek (https://getfleek.dev/)
setup-fleek:
setup-fleek ARG="prompt":
#!/usr/bin/env bash
if [ ! -f "/etc/systemd/system/nix-daemon.socket" ]; then
echo "Please install nix first by running ujust setup-nix"
exit 0
fi
echo 'What would you like to do with Fleek?'
OPTION=$(ugum choose "Install Fleek" "Uninstall Fleek" "Integrate Nix/Fleek applications with system theme")
if [ "$OPTION" == "Install Fleek" ]; then
OPTION={{ARG}}
if [ "$OPTION" == "prompt" ]; then
echo 'What would you like to do with Fleek?'
OPTION=$(ugum choose "Install Fleek" "Uninstall Fleek" "Integrate Nix/Fleek applications with system theme")
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust setup-fleek <option>"
echo " <option>: Specify the quick option - 'install', 'remove', or 'integrate'"
echo " Use 'install' to select install"
echo " Use 'remove' to select uninstall"
echo " Use 'integrate' to integrate nix applications with system theme."
exit 0
fi
if [ "$OPTION" == "Install Fleek" ] || [ "${OPTION,,} == "install" ]; then
mkdir -p $HOME/.config/nix
echo "experimental-features = nix-command flakes" >> $HOME/.config/nix/nix.conf
curl -fsSL https://getfleek.dev/installer | env FORCE=1 bash
elif [ "$OPTION" == "Uninstall Fleek" ]; then
elif [ "$OPTION" == "Uninstall Fleek" ] || [ "${OPTION,,} == "remove" ]; then
if [[ -x "/var/usrlocal/bin/fleek" ]]; then
sudo rm -f /var/usrlocal/bin/fleek
else
echo "Fleek is not installed or has been already removed"
fi
elif [ "$OPTION" == "Integrate Nix/Fleek applications with system theme" ]; then
elif [ "$OPTION" == "Integrate Nix/Fleek applications with system theme" ] || [ "${OPTION,,} == "integrate" ]; then
if [[ -x "/var/usrlocal/bin/fleek" ]]; then
if command -v mutter; then
fleek add adw-gtk3 --apply
Expand All @@ -86,7 +96,7 @@ setup-fleek:
fi

# Install or uninstall devbox
setup-devbox:
setup-devbox ARG="prompt":
#!/usr/bin/env bash
if [ ! -f "/etc/systemd/system/nix-daemon.socket" ]; then
echo "Please install nix first by running ujust setup-nix"
Expand All @@ -98,12 +108,21 @@ setup-devbox:
fi
bold=$(tput bold)
normal=$(tput sgr0)
echo "Devbox is currently: ${bold}${CURRENT_STATE}${normal}"
echo 'What would you like to do with devbox?'
OPTION=$(ugum choose Install Uninstall)
if [ "$OPTION" == "Install" ]; then
OPTION={{ARG}}
if [ "$OPTION" == "prompt" ]; then
echo "Devbox is currently: ${bold}${CURRENT_STATE}${normal}"
echo 'What would you like to do with devbox?'
OPTION=$(ugum choose Install Uninstall)
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust toggle-updates <option>"
echo " <option>: Specify the quick option - 'install' or 'remove'"
echo " Use 'install' to Install devbox"
echo " Use 'remove' to Remove devbox."
exit 0
fi
if [ "${OPTION,,}" == "Install" ]; then
curl -fsSL https://get.jetpack.io/devbox | bash
elif [ "$OPTION" == "Uninstall" ]; then
elif [ "${OPTION,,}" == "Uninstall" ] || [ "${OPTION,,}" == "remove" ]; then
if [[ -x "/var/usrlocal/bin/devbox" ]]; then
sudo rm -f /var/usrlocal/bin/devbox
else
Expand Down

0 comments on commit 36654a0

Please sign in to comment.