Skip to content
This repository has been archived by the owner on Dec 25, 2024. It is now read-only.

Commit

Permalink
feat: realtime configs for pipewire in studio command + pipx studio-a…
Browse files Browse the repository at this point in the history
…dd and rtcqs
  • Loading branch information
tulilirockz committed Mar 8, 2024
1 parent 4a0bde0 commit a5b37ad
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 6 deletions.
1 change: 1 addition & 0 deletions config/common/shared/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ install:
- realtime-setup
- realtime-tests
- pulseaudio-utils
- pipx
9 changes: 8 additions & 1 deletion config/files/shared/libexec/atomic-studio-cli/add.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use lib/distrobox.nu [gen_export_string, DISTROBOX_DOWNLOAD_URL]
use lib/std.nu [fancy_prompt_message, user_prompt]

const valid_package_managers = ["apt", "brew", "nix", "dnf", "yum", "paru", "pacman"]
const valid_package_managers = ["apt", "brew", "nix", "dnf", "yum", "paru", "pacman", "pipx"]
const distroboxes = [
["aliases","name", "image", "description"];
["ubuntu", "ubuntubox", "ghcr.io/ublue-os/ubuntu-toolbox:latest", "Ubuntu based distrobox"]
Expand Down Expand Up @@ -69,6 +69,7 @@ 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" },
Expand Down Expand Up @@ -110,6 +111,12 @@ def distrobox_installer_wrapper [
distrobox enter $box_name -- sh -c $"($manager.installer_command) ($package_data.packages | str join ' ') && ($packages_export) 2> /dev/null" err> /dev/null
}

def pipx_install [yes: bool, packages: list<string>] {
for $package in $packages {
run-external pipx install $package
}
}

def brew_install [yes: bool, packages: list<string>] {
let brew_path = "/home/linuxbrew/.linuxbrew/bin/brew"
if (which brew | length) == 0) or (not ($brew_path | path exists)) {
Expand Down
2 changes: 1 addition & 1 deletion config/files/shared/libexec/atomic-studio-cli/lib/std.nu
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export def user_prompt [yes: bool] {
if $yes {
return true
}
let user_response = input "[Y/n]> "
let user_response = input "[y/n]> "
return (($user_response =~ "(?i)yes") or ($user_response =~ "(?i)y"))
}

Expand Down
50 changes: 50 additions & 0 deletions config/files/shared/libexec/atomic-studio-cli/pw.nu
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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"]

# Set specific buffersize for PIPEWIRE_QUANTUM variable (fixes ardour and carla crashes)
export def "main pw set quantum-buffersize" [--buffersize (-b): int] {
Expand Down Expand Up @@ -29,14 +30,63 @@ export def "main pw set quantum-buffersize" [--buffersize (-b): int] {
exit 0
}

# Edit your own custom configuration for pipewire
export def "main pw edit" [
--system (-s) # Select system configurations to override
--user (-u) # Select user configs
] {
let pipewire_config_path = $"($env.HOME)/.config/pipewire"
const pipewire_sys_path = "/usr/share/pipewire"

mkdir $pipewire_config_path

mut target_fpath = ""
if $system != null {
$target_fpath = $pipewire_sys_path
}
if $user != null {
$target_fpath = $pipewire_config_path
}

let selected_config_file = (gum file $target_fpath)

if $system != null {
cp $selected_config_file $pipewire_config_path
}
mut editor = "nano"
if $env.EDITOR != null {
$editor = $env.EDITOR
}
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"
rpm-ostree kargs --append-if-missing="threadirqs"

for $group in $REALTIME_GROUPS {
usermod -a -G $group $env.USER
}
echo "Reboot for changes to take effect."
}

# Disables realtime from linux kernel arguments
export def "main pw disable realtime" [] {
rpm-ostree kargs --delete-if-present="preempt=full"
rpm-ostree kargs --delete-if-present="threadirqs"

for $group in $REALTIME_GROUPS {
usermod -R $group $env.USER
}
echo "Reboot for changes to take effect."
}

# Manage pipewire configurations
Expand Down
7 changes: 3 additions & 4 deletions config/files/shared/share/ublue-os/firstboot/yafti.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@ screens:
default: false
packages:
- Change to Nushell: pkexec usermod $USER --shell /usr/bin/nu
- Add Nushell to Shells: pkexec sh -c "[ grep '/usr/bin/nu' /etc/shells ] || echo /usr/bin/nu /etc/shells"
Fish Shell:
description: Change your user shell to the Fish shell
default: true
packages:
- Change to Fish shell: pkexec usermod $USER --shell /usr/bin/fish
Realtime User Groups:
description: Add certain user groups for your user in order to use realtime applications properly
Realtime:
description: Add certain user groups and kernel arguments for your user in order to use realtime applications properly
default: false
packages:
- Add realtime group: pkexec sh -c "for GROUP in realtime pipewire ; do usermod -a -G $GROUP $USER ; done"
- Add realtime group: pkexec studio pw enable realtime
Davinci Box:
description: Reproducible and descartable environment for installing Davinci Resolve - Make sure to install Davinci Resolve inside of davincibox.
default: false
Expand Down

0 comments on commit a5b37ad

Please sign in to comment.