mirror of
https://github.com/AquaMorph/dotfiles.git
synced 2025-07-01 01:32:02 +00:00
Stow scripts
This commit is contained in:
11
scripts/bin/audio/aax-convert.sh
Executable file
11
scripts/bin/audio/aax-convert.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Load user settings from config file.
|
||||
. ~/.config/settings.conf
|
||||
|
||||
for file in *.aax; do
|
||||
convertedFile="./${file%%.*}.m4b"
|
||||
if [ ! -f "$convertedFile" ]; then
|
||||
ffmpeg -y -activation_bytes ${activation_bytes} -i ./${file} -codec copy $convertedFile
|
||||
fi
|
||||
done
|
159
scripts/bin/audio/aquamix.sh
Executable file
159
scripts/bin/audio/aquamix.sh
Executable file
@ -0,0 +1,159 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to manuage audio mixing the the main audio interface.
|
||||
|
||||
# Import library
|
||||
source $(dirname ${BASH_SOURCE[0]})/audio-lib.sh
|
||||
|
||||
INTERFACE_NAME='Clarett+ 8Pre'
|
||||
INTERFACE_NUM=$(getCardNumber $INTERFACE_NAME)
|
||||
checkCard "$INTERFACE_NAME" "$INTERFACE_NUM"
|
||||
|
||||
# Sets the volume levels of the first mono instrument.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setMonoOne() {
|
||||
setMono $INTERFACE_NUM 1 $1 $2 $3
|
||||
}
|
||||
|
||||
# Sets the volume levels of the second mono instrument.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setMonoTwo() {
|
||||
setMono $INTERFACE_NUM 2 $1 $2 $3
|
||||
}
|
||||
|
||||
# Sets the volume levels of the third mono instrument.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setMonoThree() {
|
||||
setMono $INTERFACE_NUM 3 $1 $2 $3
|
||||
}
|
||||
|
||||
# Sets the volume levels of the first stereo instrument.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setStereoOne() {
|
||||
setStereo $INTERFACE_NUM 5 $1 $2 $3
|
||||
}
|
||||
|
||||
# Sets the volume levels of the second stereo instrument.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setStereoTwo() {
|
||||
setStereo $INTERFACE_NUM 7 $1 $2 $3
|
||||
}
|
||||
|
||||
# Sets the volume levels of the third stereo instrument.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setStereoThree() {
|
||||
setStereo $INTERFACE_NUM 9 $1 $2 $3
|
||||
}
|
||||
|
||||
# Sets the volume levels of the fourth stereo instrument.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setStereoFour() {
|
||||
setStereo $INTERFACE_NUM 11 $1 $2 $3
|
||||
}
|
||||
|
||||
# Sets the volume levels of the fifth stereo instrument.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setStereoFive() {
|
||||
setStereo $INTERFACE_NUM 13 $1 $2 $3
|
||||
}
|
||||
|
||||
# Sets the volume levels of the sixth stereo instrument.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setStereoSix() {
|
||||
setStereo $INTERFACE_NUM 15 $1 $2 $3
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Sets the volume levels of the studio microphone.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setMic() {
|
||||
setMono $INTERFACE_NUM 4 $1 $2 $3
|
||||
}
|
||||
|
||||
# Sets the volume levels of the computer.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setComputerAudio() {
|
||||
setStereo $INTERFACE_NUM 17 $1 $2 $3
|
||||
}
|
||||
|
||||
# Sets the volume levels of all instrument.
|
||||
#
|
||||
# $1 monitor volume
|
||||
# $2 first headphone volume
|
||||
# $3 second headphone volume
|
||||
function setInstruments() {
|
||||
setMonoOne $1 $2 $3
|
||||
setMonoTwo $1 $2 $3
|
||||
setMonoThree $1 $2 $3
|
||||
setStereoOne $1 $2 $3
|
||||
setStereoTwo $1 $2 $3
|
||||
setStereoThree $1 $2 $3
|
||||
setStereoFour $1 $2 $3
|
||||
setStereoFive $1 $2 $3
|
||||
setStereoSix $1 $2 $3
|
||||
}
|
||||
|
||||
function DAWMode() {
|
||||
setInstruments $MUTE
|
||||
setMic $MUTE
|
||||
setComputerAudio $ZERO_DB
|
||||
}
|
||||
|
||||
function NormalMode() {
|
||||
setInstruments $ZERO_DB
|
||||
setMic $MUTE
|
||||
setComputerAudio $ZERO_DB
|
||||
}
|
||||
|
||||
function PrintHelp() {
|
||||
echo AquaMixer
|
||||
echo '-h --help print out help options'
|
||||
echo '-d --daw set interface to DAW mode'
|
||||
echo '-n --normal set interface to normal mode'
|
||||
exit 0
|
||||
}
|
||||
|
||||
for var in "$@"; do
|
||||
if [ $var == '-h' ] || [ $var == '--help' ]; then
|
||||
PrintHelp
|
||||
elif [ $var == '-d' ] || [ $var == '--daw' ]; then
|
||||
DAWMode
|
||||
elif [ $var == '-n' ] || [ $var == '--normal' ]; then
|
||||
NormalMode
|
||||
fi
|
||||
done
|
||||
|
121
scripts/bin/audio/audio-lib.sh
Normal file
121
scripts/bin/audio/audio-lib.sh
Normal file
@ -0,0 +1,121 @@
|
||||
# Mix names
|
||||
MONITOR_LEFT='A'
|
||||
MONITOR_RIGHT='B'
|
||||
HEADPHONE_01_LEFT='C'
|
||||
HEADPHONE_01_RIGHT='D'
|
||||
HEADPHONE_02_LEFT='E'
|
||||
HEADPHONE_02_RIGHT='F'
|
||||
BLANK_LEFT="G"
|
||||
BLANK_RIGHT='H'
|
||||
|
||||
# Level constants
|
||||
MUTE='0'
|
||||
ZERO_DB='0db'
|
||||
|
||||
# Formats a number to match the matrix numbering.
|
||||
function formatMatrixNum() {
|
||||
printf "%02d" $1
|
||||
}
|
||||
|
||||
# Returns audio card number with matching card name.
|
||||
function getCardNumber() {
|
||||
echo $(cat /proc/asound/cards | grep -m 1 $1 | grep -Po '\d{1,2}' | head -1)
|
||||
}
|
||||
|
||||
# Checks if the card exists and if not exits.
|
||||
#
|
||||
# $1 card name
|
||||
# $2 card number
|
||||
function checkCard() {
|
||||
if [ -z "$2" ]; then
|
||||
echo $1 not connected
|
||||
exit 1
|
||||
else
|
||||
echo $1 found at hw:$2
|
||||
fi
|
||||
}
|
||||
|
||||
# Prints a list of all controls for the given sound card.
|
||||
function printControls() {
|
||||
amixer -c $1 controls
|
||||
}
|
||||
|
||||
# Sets a mix to a level.
|
||||
#
|
||||
# $1 card number
|
||||
# $2 matrix number
|
||||
# $3 mix channel
|
||||
function setMix() {
|
||||
amixer -c $1 set "Mix $3 Input $(formatMatrixNum $2)" $4
|
||||
}
|
||||
|
||||
|
||||
# Sets the volume levels for a mono mix.
|
||||
#
|
||||
# $1 card number
|
||||
# $2 matrix number
|
||||
# $3 mix left channel
|
||||
# $4 mix right channel
|
||||
# $5 volume
|
||||
function setMonoMix() {
|
||||
setMix $1 $2 $3 $5
|
||||
setMix $1 $2 $4 $5
|
||||
}
|
||||
|
||||
# Sets the volume levels for a stereo mix.
|
||||
#
|
||||
# $1 card number
|
||||
# $2 matrix number
|
||||
# $3 mix left channel
|
||||
# $4 mix right channel
|
||||
# $5 volume
|
||||
function setStereoMix() {
|
||||
matrix=$2
|
||||
setMix $1 $matrix $3 $5
|
||||
setMix $1 $matrix $4 $MUTE
|
||||
setMix $1 $((matrix+1)) $3 $MUTE
|
||||
setMix $1 $((matrix+1)) $4 $5
|
||||
}
|
||||
|
||||
|
||||
# Sets the volume levels for a mono mix for several outputs.
|
||||
#
|
||||
# $1 card number
|
||||
# $2 matrix number
|
||||
# $3 mix left channel
|
||||
# $4 mix right channel
|
||||
# $5 monitor volume
|
||||
# $6 first headphone volume
|
||||
# $7 second headphone volume
|
||||
function setMono() {
|
||||
monitor=$3
|
||||
headphone1=$4
|
||||
headphone2=$5
|
||||
if [ -n $headphone1 ]; then headphone1=$monitor; fi
|
||||
if [ -n $headphone2 ]; then headphone2=$monitor; fi
|
||||
setMonoMix $1 $2 $MONITOR_LEFT $MONITOR_RIGHT $monitor
|
||||
setMonoMix $1 $2 $HEADPHONE_01_LEFT $HEADPHONE_01_RIGHT $headphone1
|
||||
setMonoMix $1 $2 $HEADPHONE_02_LEFT $HEADPHONE_02_RIGHT $headphone2
|
||||
setMonoMix $1 $2 $BLANK_LEFT $BLANK_RIGHT $MUTE
|
||||
}
|
||||
|
||||
# Sets the volume levels for a stereo mix for several outputs.
|
||||
#
|
||||
# $1 card number
|
||||
# $2 matrix number
|
||||
# $3 mix left channel
|
||||
# $4 mix right channel
|
||||
# $5 monitor volume
|
||||
# $6 first headphone volume
|
||||
# $7 second headphone volume
|
||||
function setStereo() {
|
||||
monitor=$3
|
||||
headphone1=$4
|
||||
headphone2=$5
|
||||
if [ -n $headphone1 ]; then headphone1=$monitor; fi
|
||||
if [ -n $headphone2 ]; then headphone2=$monitor; fi
|
||||
setStereoMix $1 $2 $MONITOR_LEFT $MONITOR_RIGHT $monitor
|
||||
setStereoMix $1 $2 $HEADPHONE_01_LEFT $HEADPHONE_01_RIGHT $headphone1
|
||||
setStereoMix $1 $2 $HEADPHONE_02_LEFT $HEADPHONE_02_RIGHT $headphone2
|
||||
setStereoMix $1 $2 $BLANK_LEFT $BLANK_RIGHT $MUTE
|
||||
}
|
11
scripts/bin/audio/es8start.sh
Executable file
11
scripts/bin/audio/es8start.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to add another audio interface if available.
|
||||
|
||||
DEVICE_NAME='ES-8'
|
||||
DEVICE_NUM=$(getCardNumber $DEVICE_NAME)
|
||||
checkCard $DEVICE_NAME $DEVICE_NUM
|
||||
|
||||
# Start up audio interface
|
||||
alsa_in -d hw:$DEVICENUM -j "$DEVICENAME In" -q 1 &
|
||||
alsa_out -d hw:$DEVICENUM -j "$DEVICENAME Out" -q 1 &
|
17
scripts/bin/audio/es9start.sh
Executable file
17
scripts/bin/audio/es9start.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to add another audio interface if available.
|
||||
|
||||
# Import library
|
||||
source $(dirname $(realpath ${BASH_SOURCE[0]}))/audio-lib.sh
|
||||
|
||||
DEVICE_NAME='ES-9'
|
||||
DEVICE_NUM=$(getCardNumber $DEVICE_NAME)
|
||||
checkCard $DEVICE_NAME $DEVICE_NUM
|
||||
|
||||
# Start up ES-5
|
||||
pkill es-5-pipewire || true
|
||||
/opt/es-5-pipewire/es-5-pipewire >/dev/null 2>/dev/null &
|
||||
sleep 0.1
|
||||
jack_connect ES-5:output "$DEVICE_NAME:playback_SL" || true
|
||||
jack_connect ES-5:output "$DEVICE_NAME:playback_AUX6" || true
|
7
scripts/bin/audio/es9stop.sh
Executable file
7
scripts/bin/audio/es9stop.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to stop ES-9 audio interface
|
||||
|
||||
pkill alsa_in
|
||||
pkill alsa_out
|
||||
pkill es-5-pipewire
|
15
scripts/bin/audio/synth-power-prompt.sh
Executable file
15
scripts/bin/audio/synth-power-prompt.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Script to bring up a prompt to set synth power state.
|
||||
|
||||
current='Keep current state'
|
||||
off='Power synths off'
|
||||
on='Power synths on'
|
||||
selected=$(echo -e "${current}\n${off}\n${on}" | rofi -dmenu -p \
|
||||
'Change synth power' -theme ~/.config/rofi/themes/aqua)
|
||||
|
||||
if [ "$selected" == "$off" ]; then
|
||||
python ~/.config/scripts/audio/synth-power.py -o
|
||||
elif [ "$selected" == "$on" ]; then
|
||||
python ~/.config/scripts/audio/synth-power.py -d
|
||||
fi
|
63
scripts/bin/audio/synth-power.py
Normal file
63
scripts/bin/audio/synth-power.py
Normal file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Program to control synthesizers power state.
|
||||
|
||||
import argparse
|
||||
import configparser
|
||||
import os,sys,inspect
|
||||
currentDir = os.path.dirname(os.path.abspath(
|
||||
inspect.getfile(inspect.currentframe())))
|
||||
parentDir = os.path.dirname(currentDir)
|
||||
sys.path.insert(0, parentDir)
|
||||
from homeassistant import HomeAssistant
|
||||
|
||||
# Parse settings config
|
||||
SCRIPT_DIR = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
configString = '[Settings]\n' + open(SCRIPT_DIR + '/../../settings.conf').read()
|
||||
configParser = configparser.RawConfigParser()
|
||||
configParser.read_string(configString)
|
||||
|
||||
# Load needed credentials
|
||||
HA_IP = configParser.get('Settings', 'HA_IP')
|
||||
HA_TOKEN = configParser.get('Settings', 'HA_TOKEN')
|
||||
|
||||
# Set power state of the Eurorack.
|
||||
def setEurorackPower(state):
|
||||
ha.setOnOff('switch.eurorack_lower', state)
|
||||
ha.setOnOff('switch.eurorack_top', state)
|
||||
|
||||
# Set power state of the Behringer DeepMind 12.
|
||||
def setDeepMind12Power(state):
|
||||
ha.setOnOff('switch.deepmind_12', state)
|
||||
|
||||
# Set power state of the ASM Hydrasynth.
|
||||
def setHydrasynthPower(state):
|
||||
ha.setOnOff('switch.hydrasynth', state)
|
||||
|
||||
# Set power state of the Arturia MatrixBrute.
|
||||
def setMatrixBrutePower(state):
|
||||
ha.setOnOff('switch.matrixbrute', state)
|
||||
|
||||
# Set power state of all synthesizers.
|
||||
def setSynthsPower(state):
|
||||
setEurorackPower(state)
|
||||
setDeepMind12Power(state)
|
||||
setHydrasynthPower(state)
|
||||
setMatrixBrutePower(state)
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Control power state of synthesizers.')
|
||||
parser.add_argument('-d', '--daw', action='store_true',
|
||||
help='enable DAW mode',
|
||||
dest='daw', default=False, required=False)
|
||||
parser.add_argument('-o', '--off', action='store_true',
|
||||
help='turn all synths off',
|
||||
dest='off', default=False, required=False)
|
||||
args = parser.parse_args()
|
||||
|
||||
ha = HomeAssistant(HA_IP, HA_TOKEN)
|
||||
|
||||
if args.daw:
|
||||
setSynthsPower(True)
|
||||
elif args.off:
|
||||
setSynthsPower(False)
|
89
scripts/bin/audio/system-start-audio.sh
Executable file
89
scripts/bin/audio/system-start-audio.sh
Executable file
@ -0,0 +1,89 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Kill Pulse.
|
||||
function killPulse() {
|
||||
systemctl --user stop pulseaudio.socket
|
||||
systemctl --user stop pulseaudio.service
|
||||
pulseaudio -k
|
||||
killall pulseaudio
|
||||
}
|
||||
|
||||
# Start Pulseaudio properly.
|
||||
function fixPulse() {
|
||||
PULSE="$(alsamixer 2>&1 | killall alsamixer)"
|
||||
if [[ $PULSE == *'Connection refused'* ]]; then
|
||||
echo 'Fixing Pulseaudio'
|
||||
killPulse
|
||||
sleep 0.1
|
||||
pulseaudio -D
|
||||
fixPulse
|
||||
else
|
||||
echo 'Pulseaudio is working correctly'
|
||||
fi
|
||||
}
|
||||
|
||||
# Start up programs that use audio.
|
||||
function launchi3() {
|
||||
if [ -z "$skipi3" ]; then
|
||||
echo Opening i3wm sound workspaces
|
||||
sleep .1 && i3-msg 'workspace 5; exec firefox'
|
||||
sleep 5.1 && python ~/.config/scripts/start-firefox.py
|
||||
fi
|
||||
}
|
||||
|
||||
# Set up sinks.
|
||||
function setupSinks() {
|
||||
pactl set-default-sink speakers
|
||||
pactl set-default-source sm7b
|
||||
}
|
||||
|
||||
# Connect sinks to audio interface
|
||||
function connectSinks() {
|
||||
pw-link speakers:monitor_FL alsa_output.usb-Focusrite_Clarett__8Pre_00002325-00.pro-output-0:playback_AUX0
|
||||
pw-link speakers:monitor_FR alsa_output.usb-Focusrite_Clarett__8Pre_00002325-00.pro-output-0:playback_AUX1
|
||||
|
||||
pw-link alsa_input.usb-Focusrite_Clarett__8Pre_00002325-00.pro-input-0:capture_AUX3 sm7b:input_FL
|
||||
pw-link alsa_input.usb-Focusrite_Clarett__8Pre_00002325-00.pro-input-0:capture_AUX3 sm7b:input_FR
|
||||
return $?
|
||||
}
|
||||
|
||||
function renameInterface() {
|
||||
for n in `seq 0 17` ; do
|
||||
jack_property -p -s "alsa:pcm:2:hw:2,0:capture:capture_${n}" http://jackaudio.org/metadata/pretty-name "capture_$((n+1))"
|
||||
done
|
||||
for n in `seq 0 19` ; do
|
||||
jack_property -p -s "alsa:pcm:2:hw:2,0:playback:playback_${n}" http://jackaudio.org/metadata/pretty-name "playback_$((n+1))"
|
||||
done
|
||||
for n in `seq 0 19` ; do
|
||||
jack_property -p -s "alsa:pcm:2:hw:2,0:playback:monitor_${n}" http://jackaudio.org/metadata/pretty-name "monitor_$((n+1))"
|
||||
done
|
||||
}
|
||||
|
||||
# arg parser
|
||||
for arg in "$@"
|
||||
do
|
||||
# Skip commands for i3wm
|
||||
if [[ $arg == *"-s"* ]]; then
|
||||
skipi3=true
|
||||
fi
|
||||
done
|
||||
|
||||
# Wire sinks
|
||||
setupSinks
|
||||
connectSinks
|
||||
status=$?
|
||||
while [[ $status -eq 0 ]]; do
|
||||
echo "Connecting Sinks"
|
||||
connectSinks
|
||||
status=$?
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Rename Audio Devices
|
||||
#renameInterface
|
||||
|
||||
# Eurorack audio interface
|
||||
sh ~/.config/scripts/audio/es9start.sh
|
||||
|
||||
launchi3
|
||||
systemctl --user restart polybar
|
Reference in New Issue
Block a user