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

Commit

Permalink
fix: use BASH for studio-jackd-default script + just copy it to the c…
Browse files Browse the repository at this point in the history
…ustom script paths whenever enabled
  • Loading branch information
tulilirockz committed Mar 7, 2024
1 parent e37553b commit c966962
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
22 changes: 4 additions & 18 deletions config/files/shared/libexec/atomic-studio-cli/jackd.nu
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@

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"))
Expand Down Expand Up @@ -78,7 +65,7 @@ export def "main jackd disable-user" [] {

# 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 DEFAULT_CUSTOM_SCRIPT_PATH = $"($env.HOME)/.config/atomic-studio/jack/custom-jackd"
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"
Expand All @@ -87,7 +74,7 @@ export def "main jackd enable-user" [] {

mkdir ($DEFAULT_CUSTOM_SCRIPT_PATH | path dirname)
touch $USER_JACKD_ENABLED
$DEFAULT_SCRIPT | save -f $DEFAULT_CUSTOM_SCRIPT_PATH
cp $SYSTEM_JACKD_SCRIPT_PATH $DEFAULT_CUSTOM_SCRIPT_PATH
echo "Sucessfully enabled custom user JackD script"
}

Expand All @@ -96,12 +83,11 @@ 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 DEFAULT_CUSTOM_SCRIPT_PATH = $"($env.HOME)/.config/atomic-studio/jack/custom-jackd"
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 not ($USER_JACKD_ENABLED | path exists) {
$entrypoint_path = $SYSTEM_JACKD_SCRIPT_PATH
} else {
Expand All @@ -111,7 +97,7 @@ export def "main jackd" [

if not ($entrypoint_path | path exists) {
mkdir ($entrypoint_path | path dirname)
$DEFAULT_SCRIPT | save -f $entrypoint_path
cp $SYSTEM_JACKD_SCRIPT_PATH $entrypoint_path
run-external chmod +x $entrypoint_path
}

Expand Down
3 changes: 3 additions & 0 deletions config/files/shared/libexec/atomic-studio-cli/pwjack.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const TARGET_CONFIG_PATH = "/etc/profile.d/atomic-pwjack.sh"
const VALID_BFSIZES = [8,16,32,64,128,256,512,1024,2048,4096]

# Set specific buffersize for PIPEWIRE_QUANTUM variable
export def "main pw-jack set" [--buffersize (-b): int] {
mut is_valid_thing: bool = false
mut iter = 0
Expand All @@ -27,6 +28,7 @@ export def "main pw-jack set" [--buffersize (-b): int] {
exit 0
}

# Enable custom pipewire-jack configuration
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
Expand All @@ -36,6 +38,7 @@ export def "main pw-jack enable" [] {
exit 0
}

# Disables custom pipewire-jack configuration
export def "main pw-jack disable" [] {
rm -f /etc/ld.so.conf.d/pipewire-jack.conf
ldconfig
Expand Down
2 changes: 1 addition & 1 deletion config/files/shared/libexec/studio-jackd-default
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S nu
#!/usr/bin/env bash
pulseaudio -k
pactl load-module module-jack-source
jack_control start
Expand Down

0 comments on commit c966962

Please sign in to comment.