diff --git a/config/files/shared/libexec/atomic-studio-cli/add.nu b/config/files/shared/libexec/atomic-studio-cli/add.nu index fbde933..2ac33e5 100755 --- a/config/files/shared/libexec/atomic-studio-cli/add.nu +++ b/config/files/shared/libexec/atomic-studio-cli/add.nu @@ -1,7 +1,8 @@ #!/usr/bin/env -S nu -use lib/distrobox.nu [gen_export_string, DISTROBOX_DOWNLOAD_URL, distroboxes] -use lib/std.nu [fancy_prompt_message, user_prompt] +use lib/distrobox.nu [gen_export_string, create_container_optional, DISTROBOXES_META] +use lib/user_interaction.nu [fancy_prompt_message, user_prompt] +use lib/generic_install.nu [generic_script_installation, nix_installer, brew_installer, distrobox_installer] const valid_package_managers = ["apt", "brew", "nix", "dnf", "yum", "paru", "pacman", "pipx"] @@ -11,19 +12,16 @@ export def "main add export" [ box_or_subsystem: string, ...packages: string ] { - mut exportPath = "" - if ($export == null) or ($export == "") { + mut exportPath = $export + if $export == null { $exportPath = $"($env.HOME)/.local/bin" - } else { - $exportPath = $export } let export_Path = $exportPath mkdir $export_Path - let selected_box = ($distroboxes | select aliases name | where { |e| ($e.name == $box_or_subsystem) or ($e.aliases == $box_or_subsystem) } | get name | str join) - - let packages_export = ($packages | each {|package| gen_export_string $package $export_Path } | str join " ; ") - distrobox-enter $selected_box -- sh -c $"($packages_export) 2> /dev/null" err> /dev/null + let selected_box = ($DISTROBOXES_META | select aliases name | where { |e| ($e.name == $box_or_subsystem) or ($e.aliases == $box_or_subsystem) } | get name | str join) + let packages_export_cmd: string = (gen_export_string $packages $export_Path) + distrobox-enter $selected_box -- sh -c $"($packages_export_cmd) 2> /dev/null" err> /dev/null } # List all available commands and subsystems @@ -31,10 +29,10 @@ export def "main add list" [ --as-record (-r) ] { if $as_record != null { - return {pkg_managers: $valid_package_managers, distroboxes: $distroboxes} + return {pkg_managers: $valid_package_managers, distroboxes: $DISTROBOXES_META} } - echo $"Valid package managers:\n($valid_package_managers | table)\nSubsystems \(Distroboxes\):\n($distroboxes| table)" + echo $"Valid package managers:\n($valid_package_managers | table)\nSubsystems \(Distroboxes\):\n($DISTROBOXES_META| table)" } # Add a package to your Atomic Studio system by using package subsystems or host-based package managers. @@ -61,19 +59,18 @@ export def "main add" [ } match $package_manager { - nix => { nix_install $yes $packages }, - brew => { brew_install $yes $packages }, - pipx => { pipx_install $yes $packages } - apt | paru | pacman | dnf | yum => { - distrobox_installer_wrapper $package_data (match $package_manager { - apt => { box_distro: "ubuntu", installer_command: "sudo apt install -y" }, - paru => { box_distro: "arch", installer_command: "paru -Syu --noconfirm" } , - pacman => { box_distro:"arch", installer_command: "sudo pacman -Syu --noconfirm" }, - dnf | yum => { box_distro: "fedora", installer_command: "sudo dnf install -y" }, - }) - }, - _ => { echo $"Invalid package manager ($manager).\nValid package managers are ($valid_package_managers)" } + nix => { nix_install $yes $packages ; exit 0 }, + brew => { brew_install $yes $packages ; exit 0}, + pipx => { pipx_install $yes $packages ; exit 0 }, } + + distrobox_installer_wrapper $package_data (match $package_manager { + apt => { box_distro: "ubuntu", installer_command: "sudo apt install -y" }, + paru => { box_distro: "arch", installer_command: "paru -Syu --noconfirm" } , + pacman => { box_distro: "arch", installer_command: "sudo pacman -Syu --noconfirm" }, + dnf | yum => { box_distro: "fedora", installer_command: "sudo dnf install -y" }, + _ => { echo $"Invalid package manager ($manager).\nValid package managers are ($valid_package_managers)" } + }) } def distrobox_installer_wrapper [ @@ -81,27 +78,18 @@ def distrobox_installer_wrapper [ manager: record ] { if (which distrobox | length) == 0 { - fancy_prompt_message "Distrobox" - if not (user_prompt $package_data.no_confirm) { - exit 0 - } - echo "Installing, please wait." - curl -s $DISTROBOX_DOWNLOAD_URL | pkexec sh + generic_script_installation $package_data.no_confirm "distrobox" (distrobox_installer) } - let box_name = ($distroboxes | where aliases == $manager.box_distro | get name).0 - - try { distrobox ls | grep $box_name out> /dev/null } catch { - fancy_prompt_message $"The ($distroboxes | where aliases == $manager.box_distro | get aliases | str join | str capitalize) subsystem" - if not (user_prompt $package_data.no_confirm) { - exit 0 - } - distrobox create -i ($distroboxes | where aliases == $manager.box_distro | get image | str join) --name $manager.box_name -Y --pull - } + let box_name: string = ($DISTROBOXES_META | where aliases == $manager.box_distro | get name).0 + let box_alias: string = ($DISTROBOXES_META | where aliases == $manager.box_distro | get aliases | str join | str capitalize) + let box_image: string = ($DISTROBOXES_META | where aliases == $manager.box_distro | get image | str join) + create_container_optional $package_data.no_confirm {name: $box_name, description: $box_alias, image: $box_image } + mkdir $package_data.export_path - let packages_export = ($package_data.packages | each {|package| gen_export_string $package $package_data.export_path } | str join " ; ") + let packages_export = gen_export_string $package_data.packages $package_data.export_path distrobox enter $box_name -- sh -c $"($manager.installer_command) ($package_data.packages | str join ' ') && ($packages_export) 2> /dev/null" err> /dev/null } @@ -113,30 +101,27 @@ def pipx_install [yes: bool, packages: list] { def brew_install [yes: bool, packages: list] { let brew_path = "/home/linuxbrew/.linuxbrew/bin/brew" - if (which brew | length) == 0) or (not ($brew_path | path exists)) { - fancy_prompt_message Brew - if not (user_prompt $yes) { - exit 0 - } - echo "Installing, please wait. You can check logs in /tmp/brew_install.log" - do { yes | /usr/libexec/brew-install ; echo "PLEASE IGNORE THE INSTRUCTIONS ABOVE. THEY WILL NOT HELP YOU! THE SYSTEM IS ALREADY CONFIGURED TO USE BREW PROPERLY BY DEFAULT :>"} out> /tmp/brew_install.log - echo "Brew installed successfully! Please reload your shell and run this program again." + if ((which brew | length) != 0) or ($brew_path | path exists) { + run-external $brew_path install ($packages | str join) + exit 0 + } + + fancy_prompt_message Brew + if not (user_prompt $yes) { exit 0 } - run-external $brew_path install ($packages | str join) + generic_script_installation $yes "brew" (brew_installer) } def nix_install [yes: bool, packages: list] { - if (which nix | length) == 0 { - fancy_prompt_message Nix - if not (user_prompt $yes) { - exit 0 - } - echo "Installing, please wait. You can check logs in /tmp/nix_install.log" - do { yes | curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install } out> /tmp/nix_install.log - echo "Nix installed successfully! Please reload your shell and run this program again." + if (which nix | length) != 0 { + run-external nix profile install ($packages | each {|value| $"nixpkgs#($value) "} | str join) exit 0 } - run-external nix profile install ($packages | each {|value| $"nixpkgs#($value) "} | str join) + fancy_prompt_message Nix + if not (user_prompt $yes) { + exit 0 + } + generic_script_installation $yes "nix" (nix_installer) } diff --git a/config/files/shared/libexec/atomic-studio-cli/davinci.nu b/config/files/shared/libexec/atomic-studio-cli/davinci.nu index e201631..9862f76 100755 --- a/config/files/shared/libexec/atomic-studio-cli/davinci.nu +++ b/config/files/shared/libexec/atomic-studio-cli/davinci.nu @@ -1,7 +1,8 @@ #!/usr/bin/env -S nu -use lib/distrobox.nu [DISTROBOX_DOWNLOAD_URL] -use lib/std.nu [fancy_prompt_message, user_prompt] +use lib/user_interaction.nu [fancy_prompt_message, user_prompt] +use lib/generic_install.nu [generic_script_installation] +use lib/distrobox.nu [create_container_optional] const INSTALLATION_BOX = "davincibox" const DAVINCI_IMAGE = "ghcr.io/zelikos/davincibox:latest" @@ -10,15 +11,16 @@ const DAVINCI_IMAGE = "ghcr.io/zelikos/davincibox:latest" export def "main davinci remove" [ --yes (-y) # Skip all confirmation prompts, --box_name: string # Name of the distrobox where davinci-installer will be run from + --delete-box # Also delete container ] { if (which distrobox | length) == 0 { - fancy_prompt_message "Distrobox" - if (not (user_prompt $yes)) { + fancy_prompt_message "Distrobox" + if not (user_prompt $yes) { exit 0 } - curl -s $DISTROBOX_DOWNLOAD_URL | pkexec sh + generic_script_installation $yes "Distrobox" (distrobox_installer) } - + mut install_box = "" if $box_name == null { $install_box = $INSTALLATION_BOX @@ -30,6 +32,9 @@ export def "main davinci remove" [ } distrobox enter $install_box '--' sh -c "add-davinci-launcher remove" + if $delete_box != null { + distrobox rm $install_box + } } # Install Davinci Resolve in a compatible distrobox @@ -39,11 +44,11 @@ export def "main davinci" [ script_path: string # The script that will be run to install Davinci Resolve ] { if (which distrobox | length) == 0 { - fancy_prompt_message "Distrobox" - if (not (user_prompt $yes)) { - return + fancy_prompt_message "Distrobox" + if not (user_prompt $yes) { + exit 0 } - curl -s $DISTROBOX_DOWNLOAD_URL | pkexec sh + generic_script_installation $yes "Distrobox" (distrobox_installer) } mut install_box = "" @@ -52,13 +57,7 @@ export def "main davinci" [ } let box_name = $install_box - try { distrobox ls | grep $box_name } catch { - fancy_prompt_message "The Davinci container" - if not (user_prompt $yes) { - return - } - distrobox create -i $DAVINCI_IMAGE --name $box_name -Y --pull - } + create_container_optional $yes {name: $box_name, description: "Davinci container", image: $DAVINCI_IMAGE} distrobox enter $box_name -- sh -c $"setup-davinci ($script_path) distrobox && add-davinci-launcher" } diff --git a/config/files/shared/libexec/atomic-studio-cli/lib/distrobox.nu b/config/files/shared/libexec/atomic-studio-cli/lib/distrobox.nu index d82bbe6..6b7fa1f 100644 --- a/config/files/shared/libexec/atomic-studio-cli/lib/distrobox.nu +++ b/config/files/shared/libexec/atomic-studio-cli/lib/distrobox.nu @@ -1,12 +1,23 @@ -export const DISTROBOX_DOWNLOAD_URL = "https://raw.githubusercontent.com/89luca89/distrobox/main/install" +use user_interaction.nu [fancy_prompt_message] -export def gen_export_string [package: string, export_Path: string] { - return $"distrobox-export --app ($package) ; distrobox-export --export-path ($export_Path) --bin /usr/bin/($package)" +export def gen_export_string [packages: list, export_Path: string] { + return ($packages | each {|package| $"distrobox-export --app ($package) ; distrobox-export --export-path ($export_Path) --bin /usr/bin/($package)" } | str join " ; ") } -export const distroboxes = [ +export const DISTROBOXES_META = [ ["aliases","name", "image", "description"]; ["ubuntu", "ubuntubox", "ghcr.io/ublue-os/ubuntu-toolbox:latest", "Ubuntu based distrobox"] ["arch", "archbox", "ghcr.io/ublue-os/arch-distrobox:latest", "Arch Linux based distrobox with paru pre-installed"] ["fedora", "fedorabox", "ghcr.io/ublue-os/fedora-toolbox", "Fedora based distrobox"] ] + +export def create_container_optional [yes: bool, container: record] { + try { distrobox ls | grep $container.name } catch { + fancy_prompt_message $container.description + if not (user_prompt $yes) { + return 0 + } + distrobox create -Y --pull -i $container.image --name $container.name + } +} + diff --git a/config/files/shared/libexec/atomic-studio-cli/lib/external_programs.nu b/config/files/shared/libexec/atomic-studio-cli/lib/external_programs.nu new file mode 100644 index 0000000..d216f67 --- /dev/null +++ b/config/files/shared/libexec/atomic-studio-cli/lib/external_programs.nu @@ -0,0 +1,4 @@ +export extern "distrobox" [ + create? # Creates distroboxes + +] diff --git a/config/files/shared/libexec/atomic-studio-cli/lib/generic_install.nu b/config/files/shared/libexec/atomic-studio-cli/lib/generic_install.nu new file mode 100644 index 0000000..e2604f3 --- /dev/null +++ b/config/files/shared/libexec/atomic-studio-cli/lib/generic_install.nu @@ -0,0 +1,21 @@ +export const DISTROBOX_DOWNLOAD_URL = "https://raw.githubusercontent.com/89luca89/distrobox/main/install" + +export def generic_script_installation [yes: bool, program_name: string, installation_script: closure] { + let log_file = $"/tmp/($program_name | str trim | str downcase)_install.log" + touch $log_file + echo $"Installing, please wait. You can check logs in ($log_file)" + do $installation_script out> $log_file + echo $"($program_name | str capitalize) installed successfuly! Please reload your shell and run this script again." +} + +export def nix_installer [] { + return { yes | curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install } +} + +export def brew_installer [] { + return { yes | /usr/libexec/brew-install ; echo "PLEASE IGNORE THE INSTRUCTIONS ABOVE. THEY WILL NOT HELP YOU! THE SYSTEM IS ALREADY CONFIGURED TO USE BREW PROPERLY BY DEFAULT :>"} +} + +export def distrobox_installer [] { + return { http get $DISTROBOX_DOWNLOAD_URL | pkexec sh } +} diff --git a/config/files/shared/libexec/atomic-studio-cli/lib/std.nu b/config/files/shared/libexec/atomic-studio-cli/lib/user_interaction.nu similarity index 77% rename from config/files/shared/libexec/atomic-studio-cli/lib/std.nu rename to config/files/shared/libexec/atomic-studio-cli/lib/user_interaction.nu index 12e8975..1c7c669 100644 --- a/config/files/shared/libexec/atomic-studio-cli/lib/std.nu +++ b/config/files/shared/libexec/atomic-studio-cli/lib/user_interaction.nu @@ -10,3 +10,5 @@ export def fancy_prompt_message [package_manager: string] { echo $"($package_manager) is not installed. Do you wish to install it?" } +export const GENERIC_RESET_SESSION_MESSAGE = "Log out and in for changes to take effect." + diff --git a/config/files/shared/libexec/atomic-studio-cli/motd.nu b/config/files/shared/libexec/atomic-studio-cli/motd.nu index 63ae17b..9a26d3c 100755 --- a/config/files/shared/libexec/atomic-studio-cli/motd.nu +++ b/config/files/shared/libexec/atomic-studio-cli/motd.nu @@ -28,16 +28,18 @@ def replace_format [ return final_value } -# Toggle MOTD on and off -export def "main motd toggle" [] { - let MOTD_ENABLED_FILE = $"($env.HOME)/.config/atomic-studio/motd_enabled" - if ($MOTD_ENABLED_FILE | path exists) { - rm $MOTD_ENABLED_FILE - echo "Disabled MOTD for the current user" - } else { - touch $MOTD_ENABLED_FILE - echo "Enabled MOTD for the current user" - } +# Turn MOTD off +export def "main motd off" [] { + let MOTD_DISABLED_FILE = $"($env.HOME)/.config/atomic-studio/motd_enabled" + rm $MOTD_DISABLED_FILE + echo "Disabled MOTD for the current user" +} + +# Turn MOTD on +export def "main motd on" [] { + let MOTD_DISABLED_FILE = $"($env.HOME)/.config/atomic-studio/motd_enabled" + touch $MOTD_DISABLED_FILE + echo "Enabled MOTD for the current user" } # Display current MOTD text @@ -47,6 +49,11 @@ export def "main motd" [ --template_path (-t): string # Which template will be used for displaying the MOTD --no-tip (-n) # Do not display tip ] { + let MOTD_DISABLED_FILE = $"($env.HOME)/.config/atomic-studio/motd_disabled" + if ($MOTD_DISABLED_FILE | path exists) { + exit 0 + } + mut TEMPLATE_PATH = $template_path if $template_path == null { $TEMPLATE_PATH = $STUDIO_TEMPLATE_PATH @@ -63,7 +70,6 @@ export def "main motd" [ let CURRENT_TIP_FILE = (ls $MOTD_PATH | where { |e| ($e.type == "file") and ($e.name | str ends-with md) } | shuffle | get 0.name) let IMAGE_INFO = (open $IMAGE_INFO_PATH | from json) let IMAGE_NAME = ($IMAGE_INFO).image-ref | sed -e 's|ostree-image-signed:docker://ghcr.io/.*/||' -e 's|ostree-unverified-registry:ghcr.io/.*/||' ) - let IMAGE_TAG = ($IMAGE_INFO).image-tag mut TIP = "󰋼 (open ($CURRENT_TIP_FILE) | lines | shuffle | get 0)" let IMAGE_DATE = (rpm-ostree status --booted | sed -n 's/.*Timestamp: \(.*\)/\1/p') @@ -83,8 +89,8 @@ export def "main motd" [ (replace_format [ ["source", "output"]; ["%IMAGE_NAME%" (replace_format $escape_patterns $IMAGE_NAME)] - ["%IMAGE_TAG%" (replace_format $escape_patterns $IMAGE_TAG)] + ["%IMAGE_TAG%" (replace_format $escape_patterns ($IMAGE_INFO).image-tag)] ["%TIP%" (replace_format $escape_patterns ($TIP | lines))] - ] (open $TEMPLATE_PATH | lines -s)) | str join "\n" | glow -s auto - + ] (open $TEMPLATE_PATH | lines -s)) | str join "\n" | run-external glow '-s' auto '-' } diff --git a/config/files/shared/libexec/atomic-studio-cli/pw.nu b/config/files/shared/libexec/atomic-studio-cli/pw.nu index 3ec594f..6d0edca 100755 --- a/config/files/shared/libexec/atomic-studio-cli/pw.nu +++ b/config/files/shared/libexec/atomic-studio-cli/pw.nu @@ -1,9 +1,31 @@ #!/usr/bin/env -S nu +use lib/user_interaction.nu [GENERIC_RESET_SESSION_MESSAGE] + const TARGET_CONFIG_PATH = "/etc/profile.d/atomic-pwjack.sh" const VALID_BFSIZES = [8,16,32,64,128,256,512,1024,2048,4096] const REALTIME_GROUPS = ["realtime", "pipewire"] +def default_reset_message [message: string] { + return $"($message) should be reset now." +} + +export def "main pw reset config" [] { + let pipewire_config_path = $"($env.HOME)/.config/pipewire" + rm -f $pipewire_config_path + systemctl restart --user pipewire.service + echo (default_reset_message "Pipewire user config") +} + +# Resets PIPEWIRE_QUANTUM variable back to its default +export def "main pw reset quantum-buffersize" [] { + rm -f $TARGET_CONFIG_PATH + pw-metadata -n settings 0 clock.force-quantum 0 + systemctl restart --user pipewire.service + echo (default_reset_message "PIPEWIRE_QUANTUM buffer size") + echo $GENERIC_RESET_SESSION_MESSAGE +} + # Set specific buffersize for PIPEWIRE_QUANTUM variable (fixes ardour and carla crashes) export def "main pw set quantum-buffersize" [--buffersize (-b): int] { mut is_valid_thing: bool = false @@ -23,15 +45,14 @@ export def "main pw set quantum-buffersize" [--buffersize (-b): int] { exit 2 } - $"export PIPEWIRE_QUANTUM=\"($buffersize)/48000\"" | save -f /etc/profile.d/atomic-pwjack.sh + $"export PIPEWIRE_QUANTUM=\"($buffersize)/48000\"" | save -f $TARGET_CONFIG_PATH pw-metadata -n settings 0 clock.force-quantum $buffersize - echo "Log out and in for changes to take effect." - exit 0 + echo $GENERIC_RESET_SESSION_MESSAGE } # Edit your own custom configuration for pipewire -export def "main pw edit" [ +export def "main pw set config" [ --system (-s) # Select system configurations to override --user (-u) # Select user configs ] { @@ -60,13 +81,6 @@ export def "main pw edit" [ run-external $editor $"($selected_config_file)" } -# Installs RTCQS in the host system for checking realtime perms -export def "main pw rtcqs" [] { - pipx install rtcqs - pipx ensurepath - echo "Restart your shell and run rtcqs_gui" -} - # Enables realtime in linux kernel arguments export def "main pw enable realtime" [] { rpm-ostree kargs --append-if-missing="preempt=full" diff --git a/config/files/shared/libexec/atomic-studio-cli/setup.nu b/config/files/shared/libexec/atomic-studio-cli/setup.nu index 1d4b389..95f104d 100755 --- a/config/files/shared/libexec/atomic-studio-cli/setup.nu +++ b/config/files/shared/libexec/atomic-studio-cli/setup.nu @@ -1,49 +1,62 @@ -use lib/std.nu [user_prompt, fancy_prompt_message] -use lib/distrobox.nu [DISTROBOX_DOWNLOAD_URL, distroboxes] - -const opentabletdriver_service = " -[Unit] -Description=OpenTabletDriver Daemon -PartOf=graphical-session.target -After=graphical-session.target -ConditionEnvironment=|WAYLAND_DISPLAY -ConditionEnvironment=|DISPLAY - -[Service] -ExecStart=/usr/bin/distrobox-enter -n archbox -- ' /usr/bin/otd-daemon' -Restart=always -RestartSec=3 - -[Install] -WantedBy=graphical-session.target -" +use lib/user_interaction.nu [user_prompt, fancy_prompt_message] +use lib/distrobox.nu [DISTROBOXES_META, create_container_optional] # Setup Atomic Studio supported apps export def "main setup" [] { echo "Usage setup ." } -# Install Davinci Resolve in a compatible distrobox +# Disable Supergfxctl, a GPU switcher for hybrid laptops +export def "main uninstall supergfxctl" [] { + systemctl disable --now supergfxd.service +} + +# Uninstall LACT, an overclocking utility for AMD cards +export def "main uninstall amd-lact" [] { + systemctl disable --now lactd + rpm-ostree uninstall lact +} + +# Removes OpenTabletDriver services and the installation from container (does not delete the container itself.) +export def "main uninstall opentabletdriver" [] { + let archbox_entry = ($DISTROBOXES_META | select aliases name image | where aliases == arch).0 + rm -f $"($env.HOME)/.config/systemd/user/($archbox_entry.name)-opentabletdriver.service" + systemctl --user daemon-reload + systemctl enable --user --now $"($archbox_entry.name)-opentabletdriver.service" + distrobox enter -n $archbox_entry.name -- ' paru -Rns opentabletdriver --noconfirm' +} + +# Removes RTCQS from the host system +export def "main uninstall rtcqs" [] { + pipx uninstall rtcqs +} + +# Install OpenTabletDriver in a container export def "main setup opentabletdriver" [ --yes (-y) # Skip all confirmation prompts ] { - if (which distrobox | length) == 0 { - fancy_prompt_message "Distrobox" - if not (user_prompt $yes) { - return - } - curl -s $DISTROBOX_DOWNLOAD_URL | pkexec sh - } - - let archbox_entry = ($distroboxes | select aliases name image | where aliases == arch).0 - - try { distrobox ls | grep ($archbox_entry.name) } catch { - fancy_prompt_message "The Arch Linux subsystem" - if not (user_prompt $yes) { - return - } - distrobox create -i $archbox_entry.image --name $archbox_entry.name -Y --pull - } + install_distrobox_if_not_exists $yes + + let archbox_entry = ($DISTROBOXES_META | select aliases name image | where aliases == arch).0 + + let opentabletdriver_service = $" + [Unit] + Description=OpenTabletDriver Daemon + PartOf=graphical-session.target + After=graphical-session.target + ConditionEnvironment=|WAYLAND_DISPLAY + ConditionEnvironment=|DISPLAY + + [Service] + ExecStart=/usr/bin/distrobox-enter -n ($archbox_entry.name) -- ' /usr/bin/otd-daemon' + Restart=always + RestartSec=3 + + [Install] + WantedBy=graphical-session.target + " + + create_container_optional $yes {name: $archbox_entry.name, description: "Arch Linux subsystem", image: $archbox_entry.image} distrobox enter -n $archbox_entry.name -- ' paru -S opentabletdriver --noconfirm' mkdir $"($env.HOME)/.config/systemd/user" @@ -56,3 +69,28 @@ export def "main setup opentabletdriver" [ distrobox enter -n $archbox_entry.name -- 'distrobox-export --app otd-gui' } + +# Installs RTCQS in the host system for checking realtime perms +export def "main setup rtcqs" [] { + pipx install rtcqs + echo "Restart your shell and run rtcqs_gui" +} + + +# Enable Supergfxctl, a GPU switcher for hybrid laptops +export def "main setup supergfxctl" [] { + systemctl enable --now supergfxd.service +} + +# Set up LACT, an overclocking utility for AMD cards +export def "main setup amd-lact" [] { + ublue-update --wait + echo 'Installing LACT...' + http get (http get "https://api.github.com/repos/ilya-zlobintsev/LACT/releases/latest" | get assets | where {|e| $e.name | str ends-with "fedora-39.rpm"}).0.browser_download_url | save -f /tmp/lact.rpm + rpm-ostree install --apply-live -y /tmp/lact.rpm + systemctl enable --now lactd + rm /tmp/lact.rpm + echo 'Complete.' +} + + diff --git a/config/files/shared/libexec/atomic-studio-cli/update.nu b/config/files/shared/libexec/atomic-studio-cli/update.nu index 4f0ec4c..8219067 100755 --- a/config/files/shared/libexec/atomic-studio-cli/update.nu +++ b/config/files/shared/libexec/atomic-studio-cli/update.nu @@ -1,35 +1,35 @@ #!/usr/bin/env -S nu +# Unpin a certain system version +export def "main update unpin" [ + number: int # Which deployment will be unpinned +] { + ostree admin pin --unpin $number +} + +# Pin a certain system version +export def "main update pin" [ + number: int # Which deployment will be pinned +] { + ostree admin pin $number +} + +# Rollback an update +export def "main update rollback" [] { + rpm-ostree rollback +} + # Show changelogs for the current system export def "main update changelog" [] { rpm-ostree db diff --changelogs } -# Toggle automatic upgrades -# -# Use 'enable' to Enable automatic updates. -# Use 'disable' to Disable automatic updates. -export def "main update toggle" [option?: string] { - mut CURRENT_STATE = "disabled" - if (run-external --redirect-combine systemctl is-enabled ublue-update.timer | complete).stdout == "enabled" { - $CURRENT_STATE = "enabled" - } - - mut opt = $option - if $option == null { - $opt = "prompt" - } - - if "$OPTION" == "prompt" { - echo $"Automatic updates are currently: ($CURRENT_STATE)" - echo "Enable or Disable automatic updates?" - $opt = (gum choose Enable Disable) - } +export def "main update auto off" [] { + systemctl disable --now ublue-update.timer +} - pkexec systemctl (match ($opt | str downcase) { - "disable" | "enable" => ($opt | str downcase), - _ => { echo "Invalid option" ; exit } - }) --now ublue-update.timer +export def "main update auto on" [] { + systemctl enable --now ublue-update.timer } # Run topgrade transaction for general upgrades @@ -41,5 +41,6 @@ export def "main update" [ $config_file = "/usr/share/ublue-os/topgrade.toml" } - topgrade --keep --config $config_file + run-external ublue-update '--wait' + run-external topgrade '--keep' '--config' $config_file } diff --git a/config/files/shared/libexec/topgrade/lact-update b/config/files/shared/libexec/topgrade/lact-update new file mode 100644 index 0000000..fa39f95 --- /dev/null +++ b/config/files/shared/libexec/topgrade/lact-update @@ -0,0 +1,20 @@ +#!/usr/bin/bash +shopt -s nullglob +# Got straight from Bazzite! + +echo "Looking for updates..." + +if [[ $(rpm -qa | grep lact) ]]; then + LACT_VERSION=$(curl -s https://api.github.com/repos/ilya-zlobintsev/LACT/releases/latest | jq -r '.tag_name | ltrimstr("v")') + if [[ ! $(rpm-ostree status | grep lact | grep $LACT_VERSION) ]]; then + # This will check if *any* rpm-ostree pin has the newest version, so we don't update needlessly if a user just needs to reboot or is trying an older pin. + echo "Found upstream version v$LACT_VERSION, updating..." + rpm-ostree remove $(rpm -qa | grep lact) -y + studio setup lact -y + echo "Update complete" + fi +else + echo "LACT not installed, skipping." +fi + +exit 0 diff --git a/config/files/shared/share/ublue-os/atomic-studio/motd/templates/main.md b/config/files/shared/share/ublue-os/atomic-studio/motd/templates/main.md index 16cc633..7f93ff8 100644 --- a/config/files/shared/share/ublue-os/atomic-studio/motd/templates/main.md +++ b/config/files/shared/share/ublue-os/atomic-studio/motd/templates/main.md @@ -1,14 +1,14 @@ -# 󱍢 Welcome to Atomic Studio (Alpha)  +#  Welcome to Atomic Studio (Alpha) 󱋩 `%IMAGE_NAME%:%IMAGE_TAG%` |  Command | Description | | ------- | ----------- | -| `studio-commands` | List all available commands | -| `studio-motd toggle` | Toggle this banner on/off | -| `studio-add -m brew package` | Install Homebrew (Recommended) | +| `studio --help` | List all available commands | +| `studio motd off` | Toggle this banner on/off | +| `studio add package` | Install Packages | %TIP% -- 󰊤 [Issues](https://issues.projectbluefin.io) -- 󰈙 [Documentation](http://docs.projectbluefin.io/) -- 󰊌 [Discuss](https://community.projectbluefin.io/) +- 󰊤 [Issues](https://github.com/atomic-studio-org/Atomic-Studio/issues) +- 󰈙 [Documentation](https://github.com/atomic-studio-org/Atomic-Studio) +- 󰊌 [Discuss](https://github.com/orgs/atomic-studio-org/discussions) diff --git a/config/files/shared/share/ublue-os/atomic-studio/motd/tips/tips.md b/config/files/shared/share/ublue-os/atomic-studio/motd/tips/tips.md index ed2315a..7d4fe03 100644 --- a/config/files/shared/share/ublue-os/atomic-studio/motd/tips/tips.md +++ b/config/files/shared/share/ublue-os/atomic-studio/motd/tips/tips.md @@ -1,3 +1,3 @@ -* Use studio-add to add packages to your system easier -* You can use studio-reporter to report information about your system for support -* You can check out what updated on your current image by running studio-update changelog +* Use studio add to add packages to your system easier +* You can use studio reporter to report information about your system for support +* You can check out what updated on your current image by running studio update changelog diff --git a/config/files/shared/share/ublue-os/firstboot/yafti.yml b/config/files/shared/share/ublue-os/firstboot/yafti.yml index 34782dd..2e98a50 100644 --- a/config/files/shared/share/ublue-os/firstboot/yafti.yml +++ b/config/files/shared/share/ublue-os/firstboot/yafti.yml @@ -51,6 +51,27 @@ screens: packages: - Setup obs-studio-portable: distrobox create --image ghcr.io/ublue-os/obs-studio-portable:latest --name obs-studio-portable --pull --additional-packages nvidia-driver-535 - Installing obs-portable launcher: sh -c "mkdir -p $HOME/.local/bin && echo distrobox enter --name obs -- /opt/obs-portable/obs-portable | tee $HOME/.local/bin" + amd-additions: + source: yafti.screen.package + values: + title: AMD Additions + condition: + run: grep -qv 'nvidia' <<< $(jq -r '."image-flavor"' < /usr/share/ublue-os/image-info.json) + show_terminal: true + package_manager: yafti.plugin.run + packages: + - LACT (GPU Overclocking): studio setup amd-lact + nvidia-additions: + source: yafti.screen.package + values: + title: Nvidia Additions + condition: + run: grep -q 'nvidia' <<< $(jq -r '."image-flavor"' < /usr/share/ublue-os/image-info.json) + show_terminal: true + package_manager: yafti.plugin.run + packages: + - GreenWithEnvy (GPU Overclocking): flatpak install --user --noninteractive com.leinardi.gwe + - Supergfxctl (Hybrid GPU Switching): studio setup supergfxctl check-user-flathub: source: yafti.screen.consent values: diff --git a/config/files/shared/share/ublue-os/topgrade.toml b/config/files/shared/share/ublue-os/topgrade.toml index 656470a..ba8b8cd 100644 --- a/config/files/shared/share/ublue-os/topgrade.toml +++ b/config/files/shared/share/ublue-os/topgrade.toml @@ -7,3 +7,6 @@ no_retry = false [linux] rpm_ostree = true + +[commands] +"Linux AMDGPU Control Application" = "/usr/libexec/topgrade/lact-update"