From 8386ea093100f197eed4ab00a45858d4e9022b2b Mon Sep 17 00:00:00 2001 From: Tulili Date: Wed, 6 Mar 2024 03:01:53 -0300 Subject: [PATCH] feat: unified studio cli --- config/files/shared/bin/pwjack-config | 33 ----- config/files/shared/bin/studio | 9 ++ config/files/shared/bin/studio-commands | 16 --- config/files/shared/bin/studio-custom-jackd | 65 ---------- config/files/shared/bin/studio-toggle-jack | 45 ------- .../atomic-studio-cli/add.nu} | 15 +-- .../atomic-studio-cli/davinci.nu} | 10 +- .../shared/libexec/atomic-studio-cli/jackd.nu | 119 ++++++++++++++++++ .../shared/libexec/atomic-studio-cli/mod.nu | 8 ++ .../atomic-studio-cli/motd.nu} | 48 +++---- .../libexec/atomic-studio-cli/pwjack.nu | 46 +++++++ .../atomic-studio-cli/reporter.nu} | 10 +- .../atomic-studio-cli/speaker-test.nu} | 3 +- .../atomic-studio-cli/update.nu} | 7 +- 14 files changed, 225 insertions(+), 209 deletions(-) delete mode 100755 config/files/shared/bin/pwjack-config create mode 100755 config/files/shared/bin/studio delete mode 100755 config/files/shared/bin/studio-commands delete mode 100755 config/files/shared/bin/studio-custom-jackd delete mode 100755 config/files/shared/bin/studio-toggle-jack rename config/files/shared/{bin/studio-add => libexec/atomic-studio-cli/add.nu} (95%) rename config/files/shared/{bin/studio-davinci-installer => libexec/atomic-studio-cli/davinci.nu} (88%) create mode 100755 config/files/shared/libexec/atomic-studio-cli/jackd.nu create mode 100644 config/files/shared/libexec/atomic-studio-cli/mod.nu rename config/files/shared/{bin/studio-motd => libexec/atomic-studio-cli/motd.nu} (64%) create mode 100755 config/files/shared/libexec/atomic-studio-cli/pwjack.nu rename config/files/shared/{bin/studio-reporter => libexec/atomic-studio-cli/reporter.nu} (85%) rename config/files/shared/{bin/studio-speaker-test => libexec/atomic-studio-cli/speaker-test.nu} (91%) rename config/files/shared/{bin/studio-update => libexec/atomic-studio-cli/update.nu} (90%) diff --git a/config/files/shared/bin/pwjack-config b/config/files/shared/bin/pwjack-config deleted file mode 100755 index c76bef4..0000000 --- a/config/files/shared/bin/pwjack-config +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -set -e - -if [ "$1" = "" ] || [ "$1" = "-h" ]; then - echo "Usage: $0 BUFFERSIZE | enable | disable" - echo " where BUFFERSIZE is 8, 16, 32, 64, 128, 256, 512, 1024, 2048, or 4096" - exit 1 -elif [ "$1" = "enable" ]; then - ln -fs /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*-linux-gnu.conf \ - /etc/ld.so.conf.d/pipewire-jack.conf - ldconfig - systemctl mask pulseaudio-enable-autospawn.service || true - echo "Reboot for changes to take effect." - exit 0 -elif [ "$1" = "disable" ]; then - rm /etc/ld.so.conf.d/pipewire-jack.conf || true - ldconfig - systemctl unmask pulseaudio-enable-autospawn.service || true - echo "Reboot for changes to take effect." - exit 0 -elif [ "$1" = "8" ] || [ "$1" = "16" ] || [ "$1" = "32" ] || [ "$1" = "64" ] ||\ - [ "$1" = "128" ] || [ "$1" = "256" ] || [ "$1" = "512" ] || [ "$1" = "1024" ] ||\ - [ "$1" = "2048" ] || [ "$1" = "4096" ]; then - writefile=$(cat << EOF -export PIPEWIRE_QUANTUM="$1/48000" -EOF - ) - echo "${writefile}" > /etc/profile.d/atomic-pwjack.sh - echo "Log out and in for changes to take effect." -else - echo "Invalid Value" - exit 2 -fi diff --git a/config/files/shared/bin/studio b/config/files/shared/bin/studio new file mode 100755 index 0000000..338af8c --- /dev/null +++ b/config/files/shared/bin/studio @@ -0,0 +1,9 @@ +#!/usr/bin/env -S nu + +use ../libexec/atomic-studio-cli/mod.nu * + +# The main Atomic Studio CLI. +# You can use this to run Atomic Studio-specific commands +def "main" [] { + echo "Usage: studio ." +} diff --git a/config/files/shared/bin/studio-commands b/config/files/shared/bin/studio-commands deleted file mode 100755 index 5a624c1..0000000 --- a/config/files/shared/bin/studio-commands +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env -S nu - -#TODO: Implement Verbose arg - -# List all Atomic Studio commands -def "main" [ - --verbose (-v) # Show all help - prefix?: string # Path where binaries are -] { - mut folder_prefix = $"($prefix)" - if $prefix == null { - $folder_prefix = "/usr/bin" - } - - echo (ls $folder_prefix | where { |e| ($e.name | str starts-with "studio-") }) -} diff --git a/config/files/shared/bin/studio-custom-jackd b/config/files/shared/bin/studio-custom-jackd deleted file mode 100755 index 5a84b20..0000000 --- a/config/files/shared/bin/studio-custom-jackd +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env -S nu - -let USER_JACKD_ENABLED = $"($env.HOME)/.config/atomic-studio/jack/user_custom_jackd" -let SYSTEM_JACKD_SCRIPT_PATH = "/usr/libexec/studio-jackd-default" -let DEFAULT_CUSTOM_SCRIPT_PATH = $"($env.HOME)/.config/atomic-studio/jack/custom-jackd.nu" - -let DEFAULT_SCRIPT = "#!/usr/bin/env -S nu -jack_control start -jack_control ds alsa -jack_control dps rate 48000 -jack_control dps nperiods 2 -jack_control dps period 64 -sleep 5sec -a2j_control --ehw -a2j_control --start -sleep 5sec -qjackctl &" - -# Do not use the users jackd script instead of the predefined system script -def "main disable-user" [] { - if not ($USER_JACKD_ENABLED | path exists) { - echo "Custom JackD script for the user not enabled" - exit 0 - } - - rm $USER_JACKD_ENABLED - echo "Sucessfully disabled custom user jack script" -} - -# Use the users jackd script instead of the predefined system script -def "main enable-user" [] { - if ($USER_JACKD_ENABLED | path exists) { - echo "Custom JackD script for the user already is enabled" - exit 0 - } - - mkdir ($DEFAULT_CUSTOM_SCRIPT_PATH | path dirname) - touch $USER_JACKD_ENABLED - $DEFAULT_SCRIPT | save -f $DEFAULT_CUSTOM_SCRIPT_PATH - echo "Sucessfully enabled custom user jack script" -} - -# Run jackd with a specific script -def "main" [ - --entrypoint (-e): string # Entrypoint script for running jackd (default: ~/.config/atomic-studio/jack/custom-jackd.nu) - ...args # Arguments that will be passed to the script -] { - mut entrypoint_path = "" - if $entrypoint == null { - # There is something very... wrong with this but it seems to work? - if ($USER_JACKD_ENABLED | path exists) { - $entrypoint_path = $SYSTEM_JACKD_SCRIPT_PATH - } else { - $entrypoint_path = $DEFAULT_CUSTOM_SCRIPT_PATH - } - } - - if not ($entrypoint_path | path exists) { - mkdir ($entrypoint_path | path dirname) - $DEFAULT_SCRIPT | save -f $entrypoint_path - chmod +x $entrypoint_path - } - - run-external $entrypoint_path ...$args -} diff --git a/config/files/shared/bin/studio-toggle-jack b/config/files/shared/bin/studio-toggle-jack deleted file mode 100755 index 9b54d87..0000000 --- a/config/files/shared/bin/studio-toggle-jack +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env -S nu - -def user_prompt [yes: bool] { - let user_response = input "[Y/n]> " - return (($user_response =~ "(?i)yes") or ($user_response =~ "(?i)y")) -} - -let CURRENT_IMAGE = (rpm-ostree status -b --json | jq -r '.deployments[0]."container-image-reference"') - -if ($CURRENT_IMAGE | grep -q "/var/ublue-os/image") { - echo "Before we can switch to the Jack image,the current system needs an update. Do you wish to update?" - - if (not (user_prompt $yes)) { - exit 0 - } - - ujust update - exit 0 -} - -mut CURRENT_STATE = "disabled" -if ($CURRENT_IMAGE | grep -q "jack") { - CURRENT_STATE="enabled" -} - -echo "Jack-only mode is currently ${CURRENT_STATE}" -echo "Enable or Disable jack-only mode" -let OPTION = (gum choose Enable Disable) - -if "$OPTION" == "Enable" { - if "$CURRENT_STATE" == "enabled" { - echo "You are already on a jack image" - } else { - echo "Rebasing to a pipewire image" - let base_image_name = ($CURRENT_IMAGE | sed 's|^ostree-image-signed:docker://ghcr.io/.*/||') - rpm-ostree rebase $"ostree-image-signed:docker://($base_image_name)-jack:latest" - } -} else if "$OPTION" == "Disable" { - if "$CURRENT_STATE" == "enabled" { - echo "Rebasing to a pipewire image" - rpm-ostree rebase ($CURRENT_IMAGE | sed "s/\-jack//") - } else { - echo "You are currently not on a pipewire image" - } -} diff --git a/config/files/shared/bin/studio-add b/config/files/shared/libexec/atomic-studio-cli/add.nu similarity index 95% rename from config/files/shared/bin/studio-add rename to config/files/shared/libexec/atomic-studio-cli/add.nu index aff1fd1..4bbe581 100755 --- a/config/files/shared/bin/studio-add +++ b/config/files/shared/libexec/atomic-studio-cli/add.nu @@ -1,10 +1,8 @@ #!/usr/bin/env -S nu -$env.DBX_SUDO_PROGRAM = "pkexec" -let DISTROBOX_DOWNLOAD_URL = "https://raw.githubusercontent.com/89luca89/distrobox/main/install" - -let valid_package_managers = ["apt", "brew", "nix", "dnf", "yum", "paru", "pacman"] -let distroboxes = [ +const DISTROBOX_DOWNLOAD_URL = "https://raw.githubusercontent.com/89luca89/distrobox/main/install" +const valid_package_managers = ["apt", "brew", "nix", "dnf", "yum", "paru", "pacman"] +const distroboxes = [ ["aliases","name", "image"]; ["ubuntu", "ubuntubox", "ghcr.io/ublue-os/ubuntu-toolbox:latest"] ["arch", "archbox", "ghcr.io/ublue-os/arch-distrobox:latest"] @@ -12,12 +10,11 @@ let distroboxes = [ ] # Export selected packages from selected subsystem to the host system -def "main export" [ +export def "main add export" [ --export (-e): string # Path where packages will be exported to (default: ~/.local/bin), box_or_subsystem: string, ...packages: string ] { - mut exportPath = "" if ($export == null) or ($export == "") { $exportPath = $"($env.HOME)/.local/bin" @@ -34,12 +31,12 @@ def "main export" [ } # List all available commands and subsystems -def "main list" [] { +export def "main add list" [] { echo $"Valid package managers:\n($valid_package_managers | table)\nSubsystems \(Distroboxes\):\n($distroboxes| table)" } # Add a package to your Atomic Studio system by using package subsystems or host-based package managers. -def "main" [ +export def "main add" [ --yes (-y) # Skip all confirmation prompts, --export (-e): string # Path where packages will be exported to (default: ~/.local/bin) --manager (-m): string # Package manager that will be used (default: brew) diff --git a/config/files/shared/bin/studio-davinci-installer b/config/files/shared/libexec/atomic-studio-cli/davinci.nu similarity index 88% rename from config/files/shared/bin/studio-davinci-installer rename to config/files/shared/libexec/atomic-studio-cli/davinci.nu index e04f1a7..dc07fc7 100755 --- a/config/files/shared/bin/studio-davinci-installer +++ b/config/files/shared/libexec/atomic-studio-cli/davinci.nu @@ -1,8 +1,8 @@ #!/usr/bin/env -S nu -let DISTROBOX_DOWNLOAD_URL = "https://raw.githubusercontent.com/89luca89/distrobox/main/install" -let INSTALLATION_BOX = "davincibox" -let DAVINCI_IMAGE = "ghcr.io/zelikos/davincibox:latest" +const DISTROBOX_DOWNLOAD_URL = "https://raw.githubusercontent.com/89luca89/distrobox/main/install" +const INSTALLATION_BOX = "davincibox" +const DAVINCI_IMAGE = "ghcr.io/zelikos/davincibox:latest" def user_prompt [yes: bool] { if $yes { @@ -17,7 +17,7 @@ def fancy_prompt_message [package_manager: string] { } # Delete Davinci Resolve in a from a distrobox -def "main remove" [ +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 ] { @@ -43,7 +43,7 @@ def "main remove" [ } # Install Davinci Resolve in a compatible distrobox -def "main" [ +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 diff --git a/config/files/shared/libexec/atomic-studio-cli/jackd.nu b/config/files/shared/libexec/atomic-studio-cli/jackd.nu new file mode 100755 index 0000000..7ae45ee --- /dev/null +++ b/config/files/shared/libexec/atomic-studio-cli/jackd.nu @@ -0,0 +1,119 @@ +#!/usr/bin/env -S nu + +const SYSTEM_JACKD_SCRIPT_PATH = "/usr/libexec/studio-jackd-default" + +const DEFAULT_SCRIPT = "#!/usr/bin/env -S nu +jack_control start +jack_control ds alsa +jack_control dps rate 48000 +jack_control dps nperiods 2 +jack_control dps period 64 +sleep 5sec +a2j_control --ehw +a2j_control --start +sleep 5sec +qjackctl &" + + +def user_prompt [yes: bool] { + let user_response = input "[Y/n]> " + return (($user_response =~ "(?i)yes") or ($user_response =~ "(?i)y")) +} + +# Toggle Jackd only mode +export def "main jackd toggle" [ + --yes (-y) # Skip confirmation prompts +] { + let CURRENT_IMAGE = (rpm-ostree status -b --json | jq -r '.deployments[0]."container-image-reference"') + + if ($CURRENT_IMAGE | grep -q "/var/ublue-os/image") { + echo "Before we can switch to the Jack image,the current system needs an update. Do you wish to update?" + + if (not (user_prompt $yes)) { + exit 0 + } + + studio update + exit 0 + } + + mut CURRENT_STATE = "disabled" + if ($CURRENT_IMAGE | grep -q "jack") { + $CURRENT_STATE = "enabled" + } + + echo "Jack-only mode is currently ${CURRENT_STATE}" + echo "Enable or Disable jack-only mode" + let OPTION = (gum choose Enable Disable) + + if "$OPTION" == "Enable" { + if "$CURRENT_STATE" == "enabled" { + echo "You are already on a jack image" + } else { + echo "Rebasing to a pipewire image" + let base_image_name = ($CURRENT_IMAGE | sed 's|^ostree-image-signed:docker://ghcr.io/.*/||') + rpm-ostree rebase $"ostree-image-signed:docker://($base_image_name)-jack:latest" + } + } else if "$OPTION" == "Disable" { + if "$CURRENT_STATE" == "enabled" { + echo "Rebasing to a pipewire image" + rpm-ostree rebase ($CURRENT_IMAGE | str replace --all "-jack" "") + } else { + echo "You are currently not on a pipewire image" + } + } +} + +# Do not use the users jackd script instead of the predefined system script +export def "main jackd disable-user" [] { + let USER_JACKD_ENABLED = $"($env.HOME)/.config/atomic-studio/jack/user_custom_jackd" + if not ($USER_JACKD_ENABLED | path exists) { + echo "Custom JackD script for the user not enabled" + exit 0 + } + + rm $USER_JACKD_ENABLED + echo "Sucessfully disabled custom user jack script" +} + +# Use the users jackd script instead of the predefined system script +export def "main jackd enable-user" [] { + let DEFAULT_CUSTOM_SCRIPT_PATH = $"($env.HOME)/.config/atomic-studio/jack/custom-jackd.nu" + let USER_JACKD_ENABLED = $"($env.HOME)/.config/atomic-studio/jack/user_custom_jackd" + if ($USER_JACKD_ENABLED | path exists) { + echo "Custom JackD script for the user already is enabled" + exit 0 + } + + mkdir ($DEFAULT_CUSTOM_SCRIPT_PATH | path dirname) + touch $USER_JACKD_ENABLED + $DEFAULT_SCRIPT | save -f $DEFAULT_CUSTOM_SCRIPT_PATH + echo "Sucessfully enabled custom user jack script" +} + +# Run jackd with a specific script +export def "main jackd" [ + --entrypoint (-e): string # Entrypoint script for running jackd (default: ~/.config/atomic-studio/jack/custom-jackd.nu) + ...args # Arguments that will be passed to the script +] { + let DEFAULT_CUSTOM_SCRIPT_PATH = $"($env.HOME)/.config/atomic-studio/jack/custom-jackd.nu" + let USER_JACKD_ENABLED = $"($env.HOME)/.config/atomic-studio/jack/user_custom_jackd" + + mut entrypoint_path = "" + if $entrypoint == null { + # There is something very... wrong with this but it seems to work? + if ($USER_JACKD_ENABLED | path exists) { + $entrypoint_path = $SYSTEM_JACKD_SCRIPT_PATH + } else { + $entrypoint_path = $DEFAULT_CUSTOM_SCRIPT_PATH + } + } + + if not ($entrypoint_path | path exists) { + mkdir ($entrypoint_path | path dirname) + $DEFAULT_SCRIPT | save -f $entrypoint_path + chmod +x $entrypoint_path + } + + run-external $entrypoint_path ...$args +} diff --git a/config/files/shared/libexec/atomic-studio-cli/mod.nu b/config/files/shared/libexec/atomic-studio-cli/mod.nu new file mode 100644 index 0000000..cf8eab5 --- /dev/null +++ b/config/files/shared/libexec/atomic-studio-cli/mod.nu @@ -0,0 +1,8 @@ +export use add.nu * +export use jackd.nu * +export use davinci.nu * +export use motd.nu * +export use reporter.nu * +export use speaker-test.nu * +export use update.nu * +export use pwjack.nu * diff --git a/config/files/shared/bin/studio-motd b/config/files/shared/libexec/atomic-studio-cli/motd.nu similarity index 64% rename from config/files/shared/bin/studio-motd rename to config/files/shared/libexec/atomic-studio-cli/motd.nu index f7ed8c4..a325e4f 100755 --- a/config/files/shared/bin/studio-motd +++ b/config/files/shared/libexec/atomic-studio-cli/motd.nu @@ -1,38 +1,37 @@ #!/usr/bin/env -S nu -let STUDIO_TEMPLATE_PATH = "/usr/share/ublue-os/atomic-studio/templates/main.md" - -let escape_patterns = [ +const STUDIO_TEMPLATE_PATH = "/usr/share/ublue-os/atomic-studio/templates/main.md" +const escape_patterns = [ [source, output]; - ["[", "\["], - ["]", "\]"], - ["/", "\/"], - ["&", "\&"] + ["[", '\['], + ["]", '\]'], + ["/", '\/'], + ["&", '\&'] ] -let MOTD_ENABLED_FILE = $"($env.HOME)/.config/atomic-studio/motd_enabled" def replace_format [ replacers: table # Sources and outputs for the templates values: list # The table where the values will be replaced -] - mut final_value = $value +] { + mut final_value = $values - let max_iter = ($patters | length) + let max_iter = ($replacers | length) mut iter = 0 loop { if $iter == $max_iter { break } - $values = ($value | str replace --all $replacers.$iter.$source $replacers.$iter.$replace) + $final_value = ($final_value | str replace --all $replacers.$iter.$source $replacers.$iter.$replace) iter += 1 } return final_value } -# Toggles MOTD -def "main toggle" [] { +# 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" @@ -42,7 +41,8 @@ def "main toggle" [] { } } -def "main" [ +# Display current MOTD text +export def "main motd" [ --motd_path (-m): string # Path where MOTDs are stored --image_info_path (-i): string # Path operating system information is stored (as json) --template_path (-t): string # Which template will be used for displaying the MOTD @@ -65,15 +65,15 @@ def "main" [ 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)" + mut TIP = "󰋼 (open ($CURRENT_TIP_FILE) | lines | shuffle | get 0)" let IMAGE_DATE = (rpm-ostree status --booted | sed -n 's/.*Timestamp: \(.*\)/\1/p') - let IMAGE_DATE_SECONDS = (date -d "$IMAGE_DATE" +%s) + let IMAGE_DATE_SECONDS = (/usr/bin/date -d "$IMAGE_DATE" +%s) - let CURRENT_SECONDS = (date +%s) + let CURRENT_SECONDS = (/usr/bin/date +%s) let DIFFERENCE = ($CURRENT_SECONDS - $IMAGE_DATE_SECONDS) let MONTH = (30 * 24 * 60 * 60) - if "$DIFFERENCE" >= "$MONTH" { + if $DIFFERENCE >= $MONTH { $TIP = '#  Your current image is over 1 month old, run `studio-update`' } @@ -81,11 +81,11 @@ def "main" [ $TIP = "" } - (replace_format (open $TEMPLATE_PATH | lines -s) [ + (replace_format [ ["source", "output"]; - ["%IMAGE_NAME%" (replace_format escape_patterns $IMAGE_NAME)] - ["%IMAGE_TAG%" (replace_format escape_patterns $IMAGE_TAG)] - ["%TIP%" (replace_format escape_patterns $TIP)] - ]) | str join "\n" | glow -s auto - + ["%IMAGE_NAME%" (replace_format $escape_patterns $IMAGE_NAME)] + ["%IMAGE_TAG%" (replace_format $escape_patterns $IMAGE_TAG)] + ["%TIP%" (replace_format $escape_patterns ($TIP | lines))] + ] (open $TEMPLATE_PATH | lines -s)) | str join "\n" | glow -s auto - } diff --git a/config/files/shared/libexec/atomic-studio-cli/pwjack.nu b/config/files/shared/libexec/atomic-studio-cli/pwjack.nu new file mode 100755 index 0000000..aa6a7ef --- /dev/null +++ b/config/files/shared/libexec/atomic-studio-cli/pwjack.nu @@ -0,0 +1,46 @@ +#!/usr/bin/env -S nu + +const TARGET_CONFIG_PATH = "/etc/profile.d/atomic-pwjack.sh" +const VALID_BFSIZES = [8,16,32,64,128,256,512,1024,2048,4096] + +export def "main pw-jack set" [--buffersize (-b): int] { + mut is_valid_thing: bool = false + mut iter = 0 + let max_iter = ($VALID_BFSIZES | length) + loop { + if $iter == $max_iter { + break + } + if VALID_BFSIZES.$iter == $buffersize { + $is_valid_thing = true + } + } + + if not is_valid_thing { + echo "Invalid Value" + exit 2 + } + + $"export PIPEWIRE_QUANTUM=\"($buffersize)/48000\"" | save -f /etc/profile.d/atomic-pwjack.sh + + echo "Log out and in for changes to take effect." + exit 0 +} + +export def "main pw-jack enable" [] { + ln -fs /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*-linux-gnu.conf \ + /etc/ld.so.conf.d/pipewire-jack.conf + ldconfig + systemctl mask pulseaudio-enable-autospawn.service + echo "Reboot for changes to take effect." + exit 0 +} + +export def "main pw-jack disable" [] { + rm -f /etc/ld.so.conf.d/pipewire-jack.conf + ldconfig + systemctl unmask pulseaudio-enable-autospawn.service + echo "Reboot for changes to take effect." + exit 0 +} + diff --git a/config/files/shared/bin/studio-reporter b/config/files/shared/libexec/atomic-studio-cli/reporter.nu similarity index 85% rename from config/files/shared/bin/studio-reporter rename to config/files/shared/libexec/atomic-studio-cli/reporter.nu index 8d3a61e..358c9ba 100755 --- a/config/files/shared/bin/studio-reporter +++ b/config/files/shared/libexec/atomic-studio-cli/reporter.nu @@ -1,6 +1,6 @@ #!/usr/bin/env -S nu -let fetch_info = ["hw", "audio", "packages", "podman", "systemd", "env"] +const fetch_info = ["hw", "audio", "packages", "podman", "systemd", "env"] def table_commands [...commands: string] { return ($commands | par-each { @@ -13,16 +13,12 @@ def table_commands [...commands: string] { } # List all available modules to export -def "main list" [] { +export def "main reporter list" [] { echo $"($fetch_info | table)" } # Report system information to facilitate Atomic Studio development -# Usage example: -# -# studio-reporter --method fpaste hw env podman (returns a fpaste URL) -# lshw | studio-reported --method termbin -def "main" [ +export def "main reporter" [ --method (-m): string # Method used for reporting, allowed values: ["fpaste", "termbin", "loopback"] --fetch_only # Only fetch, do not post anything anywhere ...fetch # Data that will be fetched (default: none) diff --git a/config/files/shared/bin/studio-speaker-test b/config/files/shared/libexec/atomic-studio-cli/speaker-test.nu similarity index 91% rename from config/files/shared/bin/studio-speaker-test rename to config/files/shared/libexec/atomic-studio-cli/speaker-test.nu index 2a1484c..111c4fd 100755 --- a/config/files/shared/bin/studio-speaker-test +++ b/config/files/shared/libexec/atomic-studio-cli/speaker-test.nu @@ -1,6 +1,7 @@ #!/usr/bin/env -S nu -def "main" [ +# Test your speakers with espeak +export def "main speaker-test" [ --wait (-w): duration # Amount of time to wait between tests --voice (-v): string # Espeak voice that will be used --exit (-e): int # Exit after "X" tests diff --git a/config/files/shared/bin/studio-update b/config/files/shared/libexec/atomic-studio-cli/update.nu similarity index 90% rename from config/files/shared/bin/studio-update rename to config/files/shared/libexec/atomic-studio-cli/update.nu index 7081535..824481c 100755 --- a/config/files/shared/bin/studio-update +++ b/config/files/shared/libexec/atomic-studio-cli/update.nu @@ -1,7 +1,7 @@ #!/usr/bin/env -S nu # Show changelogs for the current system -def "main changelog" [] { +export def "main update changelog" [] { rpm-ostree db diff --changelogs } @@ -9,7 +9,7 @@ def "main changelog" [] { # # Use 'enable' to Enable automatic updates. # Use 'disable' to Disable automatic updates. -def "main toggle" [option?: string] { +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" @@ -33,7 +33,7 @@ def "main toggle" [option?: string] { } # Run topgrade transaction for general upgrades -def "main" [ +export def "main update" [ --config (-c) # Configuration file for Topgrade ] { mut config_file = $config @@ -43,4 +43,3 @@ def "main" [ topgrade --config $config_file --keep } -