diff --git a/config/files/shared/libexec/atomic-studio-cli/davinci.nu b/config/files/shared/libexec/atomic-studio-cli/davinci.nu old mode 100755 new mode 100644 index 63a52d5..fc097f6 --- a/config/files/shared/libexec/atomic-studio-cli/davinci.nu +++ b/config/files/shared/libexec/atomic-studio-cli/davinci.nu @@ -4,64 +4,5 @@ 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" -# Delete Davinci Resolve in a from a distrobox -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) { - exit 0 - } - generic_script_installation $yes "Distrobox" (distrobox_installer) - } - mut install_box = "" - if $box_name == null { - $install_box = $INSTALLATION_BOX - } - - try { distrobox ls | grep $install_box } catch { - echo "The selected box ($install_box) is not created yet." - exit 1 - } - - 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 -export def "main davinci" [ - --yes (-y) # Skip all confirmation prompts - --box_name: string # Name of the distrobox where davinci-installer will be run from - 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) { - exit 0 - } - generic_script_installation $yes "Distrobox" (distrobox_installer) - } - - mut install_box = "" - if $box_name == null { - $install_box = $INSTALLATION_BOX - } - let box_name = $install_box - - create_container_optional $yes {name: $box_name, description: "Davinci container", image: $DAVINCI_IMAGE} - - mkdir $"($env.HOME)/.cache/davincibox" - cp -f $script_path $"($env.HOME)/.cache/davincibox/dresolve.run" - distrobox enter $box_name -- bash -c $"pushd ($env.HOME)/.cache/davincibox && ./dresolve.run --appimage-extract && popd" - distrobox enter $box_name -- sh -c $"setup-davinci ($env.HOME)/.cache/davincibox/squashfs-root/AppRun distrobox && add-davinci-launcher distrobox" - rm -rf $"($env.HOME)/.cache/davincibox" -} diff --git a/config/files/shared/libexec/atomic-studio-cli/lib/manager_lib.nu b/config/files/shared/libexec/atomic-studio-cli/lib/manager_installers.nu similarity index 96% rename from config/files/shared/libexec/atomic-studio-cli/lib/manager_lib.nu rename to config/files/shared/libexec/atomic-studio-cli/lib/manager_installers.nu index 42e994e..2cf9932 100644 --- a/config/files/shared/libexec/atomic-studio-cli/lib/manager_lib.nu +++ b/config/files/shared/libexec/atomic-studio-cli/lib/manager_installers.nu @@ -11,7 +11,12 @@ export def distrobox_install [ manager: record ] { if (which distrobox | length) == 0 { + fancy_prompt_message "Distrobox" + if not (user_prompt $package_data.no_confirm) { + exit 0 + } generic_script_installation $package_data.no_confirm "distrobox" (distrobox_installer) + exit 0 } let box_name: string = ($DISTROBOXES_META | where aliases == $manager.box_distro | get name).0 diff --git a/config/files/shared/libexec/atomic-studio-cli/manager.nu b/config/files/shared/libexec/atomic-studio-cli/manager.nu index 52712a8..47dcff9 100755 --- a/config/files/shared/libexec/atomic-studio-cli/manager.nu +++ b/config/files/shared/libexec/atomic-studio-cli/manager.nu @@ -2,7 +2,7 @@ use lib/user_interaction.nu [user_prompt] use lib/distrobox.nu [DISTROBOXES_META] -use lib/manager_lib.nu [brew_install, nix_install, distrobox_install, pipx_install, brew_uninstall, nix_uninstall, distrobox_uninstall, pipx_uninstall] +use lib/manager_installers.nu [brew_install, nix_install, distrobox_install, pipx_install, brew_uninstall, nix_uninstall, distrobox_uninstall, pipx_uninstall] # Available package managers: ["apt", "brew", "nix", "dnf", "yum", "paru", "pacman", "pipx"] export def "main manager" [] { diff --git a/config/files/shared/libexec/atomic-studio-cli/mod.nu b/config/files/shared/libexec/atomic-studio-cli/mod.nu index ab4bcb5..43bad01 100755 --- a/config/files/shared/libexec/atomic-studio-cli/mod.nu +++ b/config/files/shared/libexec/atomic-studio-cli/mod.nu @@ -1,5 +1,4 @@ export use manager.nu * -export use davinci.nu * export use motd.nu * export use reporter.nu * export use speaker-test.nu * diff --git a/config/files/shared/libexec/atomic-studio-cli/motd.nu b/config/files/shared/libexec/atomic-studio-cli/motd.nu index 9a26d3c..bcc44e5 100755 --- a/config/files/shared/libexec/atomic-studio-cli/motd.nu +++ b/config/files/shared/libexec/atomic-studio-cli/motd.nu @@ -30,15 +30,24 @@ def replace_format [ # Turn MOTD off export def "main motd off" [] { - let MOTD_DISABLED_FILE = $"($env.HOME)/.config/atomic-studio/motd_enabled" - rm $MOTD_DISABLED_FILE + let MOTD_DISABLED_FILE = $"($env.HOME)/.config/atomic-studio/motd_disabled" + if not ($MOTD_DISABLED_FILE | path exists) { + echo "MOTD is already disabled" + exit 0 + } + mkdir ($MOTD_DISABLED_FILE | path dirname) + touch $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 + let MOTD_DISABLED_FILE = $"($env.HOME)/.config/atomic-studio/motd_disabled" + if not ($MOTD_DISABLED_FILE | path exists) { + echo "MOTD is already enabled" + exit 0 + } + rm $MOTD_DISABLED_FILE echo "Enabled MOTD for the current user" } @@ -54,17 +63,19 @@ export def "main motd" [ exit 0 } - mut TEMPLATE_PATH = $template_path - if $template_path == null { - $TEMPLATE_PATH = $STUDIO_TEMPLATE_PATH + mut TEMPLATE_PATH = $STUDIO_TEMPLATE_PATH + if $template_path != null { + $TEMPLATE_PATH = $template_path } - mut MOTD_PATH = $motd_path - if $motd_path == null { - $MOTD_PATH = "/usr/share/ublue-os/atomic-studio/motd/tips" + + mut MOTD_PATH = "/usr/share/ublue-os/atomic-studio/motd/tips" + if $motd_path != null { + $MOTD_PATH = $motd_path } - mut IMAGE_INFO_PATH = $image_info_path - if $image_info_path == null { - $IMAGE_INFO_PATH = "/usr/share/ublue-os/image-info.json" + + mut IMAGE_INFO_PATH = "/usr/share/ublue-os/image-info.json" + if $image_info_path != null { + $IMAGE_INFO_PATH = $image_info_path } let CURRENT_TIP_FILE = (ls $MOTD_PATH | where { |e| ($e.type == "file") and ($e.name | str ends-with md) } | shuffle | get 0.name) diff --git a/config/files/shared/libexec/atomic-studio-cli/pw.nu b/config/files/shared/libexec/atomic-studio-cli/pw.nu index 6d0edca..2ee6436 100755 --- a/config/files/shared/libexec/atomic-studio-cli/pw.nu +++ b/config/files/shared/libexec/atomic-studio-cli/pw.nu @@ -27,7 +27,7 @@ export def "main pw reset quantum-buffersize" [] { } # Set specific buffersize for PIPEWIRE_QUANTUM variable (fixes ardour and carla crashes) -export def "main pw set quantum-buffersize" [--buffersize (-b): int] { +export def "main pw set quantum-buffersize" [buffersize: int] { mut is_valid_thing: bool = false mut iter = 0 let max_iter = ($VALID_BFSIZES | length) @@ -38,6 +38,7 @@ export def "main pw set quantum-buffersize" [--buffersize (-b): int] { if VALID_BFSIZES.$iter == $buffersize { $is_valid_thing = true } + $iter = $iter + 1 } if not is_valid_thing { @@ -53,7 +54,6 @@ export def "main pw set quantum-buffersize" [--buffersize (-b): int] { # Edit your own custom configuration for pipewire export def "main pw set config" [ - --system (-s) # Select system configurations to override --user (-u) # Select user configs ] { let pipewire_config_path = $"($env.HOME)/.config/pipewire" @@ -62,16 +62,14 @@ export def "main pw set config" [ mkdir $pipewire_config_path mut target_fpath = "" - if $system != null { - $target_fpath = $pipewire_sys_path - } + $target_fpath = $pipewire_sys_path if $user != null { $target_fpath = $pipewire_config_path } let selected_config_file = (gum file $target_fpath) - if $system != null { + if $user == null { cp $selected_config_file $pipewire_config_path } mut editor = "nano" @@ -87,7 +85,7 @@ export def "main pw enable realtime" [] { rpm-ostree kargs --append-if-missing="threadirqs" for $group in $REALTIME_GROUPS { - usermod -a -G $group $env.USER + pkexec usermod -a -G $group $env.USER } echo "Reboot for changes to take effect." } @@ -98,7 +96,7 @@ export def "main pw disable realtime" [] { rpm-ostree kargs --delete-if-present="threadirqs" for $group in $REALTIME_GROUPS { - usermod -R $group $env.USER + pkexec usermod -R $group $env.USER } echo "Reboot for changes to take effect." } diff --git a/config/files/shared/libexec/atomic-studio-cli/reporter.nu b/config/files/shared/libexec/atomic-studio-cli/reporter.nu index 9ab92f2..411fc13 100755 --- a/config/files/shared/libexec/atomic-studio-cli/reporter.nu +++ b/config/files/shared/libexec/atomic-studio-cli/reporter.nu @@ -27,7 +27,7 @@ export def "main reporter" [ $method_command = match $method { termbin => "nc termbin.com 9999", fpaste => "fpaste" - loopback => "echo $in", + loopback | loop | lp => "echo $in", } if $method == null { $method_command = "fpaste" @@ -40,13 +40,12 @@ export def "main reporter" [ $fetch | each { |fetch_arg| table_commands ...(match $fetch_arg { - hw => { ["lscpu" "lsmem" "lsblk" "mount"] }, audio => { ["pactl info", "pw-dump"] }, packages => { ["rpm -qa" "rpm-ostree status -v"] }, distrobox => { ["podman images" "distrobox ls" "podman ps -a"] }, systemd => { ["systemctl status" "systemctl status --user"] }, - env => { ["$env"] } - _ => [], + env => { ["$env"] }, + _ => { ["lscpu" "lsmem" "lsblk" "mount"] } }) } | table -e --theme basic | nu --stdin -c $"($method_command)" } diff --git a/config/files/shared/libexec/atomic-studio-cli/setup.nu b/config/files/shared/libexec/atomic-studio-cli/setup.nu index dcb3562..67d5e5b 100755 --- a/config/files/shared/libexec/atomic-studio-cli/setup.nu +++ b/config/files/shared/libexec/atomic-studio-cli/setup.nu @@ -1,42 +1,53 @@ use lib/user_interaction.nu [user_prompt, fancy_prompt_message] use lib/distrobox.nu [DISTROBOXES_META, create_container_optional] +const INSTALLATION_BOX = "davincibox" +const DAVINCI_IMAGE = "ghcr.io/zelikos/davincibox:latest" + # Setup Atomic Studio supported apps export def "main setup" [] { echo "Usage setup ." } +# This only works for Nvidia! # Disable Supergfxctl, a GPU switcher for hybrid laptops -export def "main uninstall supergfxctl" [] { +export def "main setup remove supergfxctl" [] { systemctl disable --now supergfxd.service } # Uninstall LACT, an overclocking utility for AMD cards -export def "main uninstall amd-lact" [] { +export def "main setup remove amd-lact" [] { systemctl disable --now lactd - rpm-ostree remove (rpm -qa | grep lact) -y + rpm-ostree remove (rpm -qa | grep lact) -y --apply-live } # Removes OpenTabletDriver services and the installation from container (does not delete the container itself.) -export def "main uninstall opentabletdriver" [] { +export def "main setup remove 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' + distrobox enter -n $archbox_entry.name -- 'paru -Rns opentabletdriver --noconfirm' } # Removes RTCQS from the host system -export def "main uninstall rtcqs" [] { +export def "main setup remove rtcqs" [] { pipx uninstall rtcqs } # Install OpenTabletDriver in a container -export def "main setup opentabletdriver" [ +export def "main setup install opentabletdriver" [ --yes (-y) # Skip all confirmation prompts ] { - install_distrobox_if_not_exists $yes - + if (which distrobox | length) == 0 { + fancy_prompt_message "Distrobox" + if not (user_prompt $yes) { + exit 0 + } + generic_script_installation $yes "distrobox" (distrobox_installer) + exit 0 + } + let archbox_entry = ($DISTROBOXES_META | select aliases name image | where aliases == arch).0 let opentabletdriver_service = $" @@ -58,7 +69,7 @@ export def "main setup opentabletdriver" [ 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' + distrobox enter -n $archbox_entry.name -- 'paru -S opentabletdriver --noconfirm' mkdir $"($env.HOME)/.config/systemd/user" try { rm -f $"($env.HOME)/.config/systemd/user/($archbox_entry.name)-opentabletdriver.service" } catch { } @@ -71,26 +82,86 @@ export def "main setup opentabletdriver" [ } # Installs RTCQS in the host system for checking realtime perms -export def "main setup rtcqs" [] { +export def "main setup install rtcqs" [] { pipx install rtcqs echo "Restart your shell and run rtcqs_gui" } - +# This only works for Nvidia! # Enable Supergfxctl, a GPU switcher for hybrid laptops -export def "main setup supergfxctl" [] { +export def "main setup install supergfxctl" [] { systemctl enable --now supergfxd.service } # Set up LACT, an overclocking utility for AMD cards -export def "main setup amd-lact" [] { +export def "main setup install 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 + sleep 2sec + systemctl daemon-reload systemctl enable --now lactd rm /tmp/lact.rpm echo 'Complete.' } +# Install Davinci Resolve in a compatible distrobox +export def "main setup install davinci" [ + --yes (-y) # Skip all confirmation prompts + --box_name: string # Name of the distrobox where davinci-installer will be run from + 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) { + exit 0 + } + generic_script_installation $yes "Distrobox" (distrobox_installer) + } + + mut install_box = "" + if $box_name == null { + $install_box = $INSTALLATION_BOX + } + let box_name = $install_box + + create_container_optional $yes {name: $box_name, description: "Davinci container", image: $DAVINCI_IMAGE} + + mkdir $"($env.HOME)/.cache/davincibox" + cp -f $script_path $"($env.HOME)/.cache/davincibox/dresolve.run" + distrobox enter $box_name -- bash -c $"pushd ($env.HOME)/.cache/davincibox && ./dresolve.run --appimage-extract && popd" + distrobox enter $box_name -- sh -c $"setup-davinci ($env.HOME)/.cache/davincibox/squashfs-root/AppRun distrobox && add-davinci-launcher distrobox" + rm -rf $"($env.HOME)/.cache/davincibox" +} + +# Delete Davinci Resolve in a from a distrobox +export def "main setup remove davinci" [ + --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) { + exit 0 + } + generic_script_installation $yes "Distrobox" (distrobox_installer) + } + + mut install_box = "" + if $box_name == null { + $install_box = $INSTALLATION_BOX + } + + try { distrobox ls | grep $install_box } catch { + echo "The selected box ($install_box) is not created yet." + exit 1 + } + + distrobox enter $install_box '--' sh -c "add-davinci-launcher remove" + if $delete_box != null { + distrobox rm $install_box + } +} diff --git a/config/files/shared/libexec/atomic-studio-cli/speaker-test.nu b/config/files/shared/libexec/atomic-studio-cli/speaker-test.nu index 111c4fd..b713e86 100755 --- a/config/files/shared/libexec/atomic-studio-cli/speaker-test.nu +++ b/config/files/shared/libexec/atomic-studio-cli/speaker-test.nu @@ -25,13 +25,15 @@ export def "main speaker-test" [ $speak_text = $text } + echo "Running audio test, input CTRL+C to exit this program" mut iterations = 0 loop { if $iterations == $exit { exit 0 } + sleep $wait_time + echo $"Running espeak: ($speak_text | str join ' ')" espeak-ng -v en+13 ...$speak_text - sleep $wait_time $iterations += 1 } } diff --git a/config/files/shared/libexec/atomic-studio-cli/update.nu b/config/files/shared/libexec/atomic-studio-cli/update.nu index 8219067..83ca602 100755 --- a/config/files/shared/libexec/atomic-studio-cli/update.nu +++ b/config/files/shared/libexec/atomic-studio-cli/update.nu @@ -4,14 +4,14 @@ export def "main update unpin" [ number: int # Which deployment will be unpinned ] { - ostree admin pin --unpin $number + pkexec 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 + pkexec ostree admin pin $number } # Rollback an update diff --git a/config/files/shared/share/ublue-os/topgrade.toml b/config/files/shared/share/ublue-os/topgrade.toml index ba8b8cd..b2e2d68 100644 --- a/config/files/shared/share/ublue-os/topgrade.toml +++ b/config/files/shared/share/ublue-os/topgrade.toml @@ -1,7 +1,7 @@ [misc] no_self_update = true disable = ["self_update", "toolbx", "containers", "helm"] -ignore_failures = ["distrobox", "flatpak", "brew_cask", "brew_formula", "nix", "npm", "pip3", "home_manager", "firmware"] +ignore_failures = ["distrobox", "flatpak", "brew_cask", "brew_formula", "nix", "pip3", "home_manager", "firmware"] assume_yes = true no_retry = false