Compare commits
No commits in common. "5cc5009bb0467591863481d924ac8338db150c42" and "e74cff9c81bc65174ce028fb8fabd3b2e58e88fe" have entirely different histories.
5cc5009bb0
...
e74cff9c81
|
|
@ -1,5 +1 @@
|
||||||
this repo has some misc scripts i wrote
|
this repo has some misc bash scripts i wrote
|
||||||
|
|
||||||
they all worked on my machine at the point of upload, but don't expect me to fix it for anyone else
|
|
||||||
|
|
||||||
all scripts are to be run on a full Linux systems, but they *might* work on WSL / UNIX / BSD / whatevs
|
|
||||||
|
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
#/bin/bash
|
|
||||||
|
|
||||||
#
|
|
||||||
# author: arian
|
|
||||||
# date: 2024-05-06
|
|
||||||
#
|
|
||||||
# purpose:
|
|
||||||
# use this script on a keyboard shortcut to automatically
|
|
||||||
# change your output device to the next one using 'pactl'
|
|
||||||
#
|
|
||||||
# usage:
|
|
||||||
# ./pactl-next-output-dev.sh /path/to/log
|
|
||||||
#
|
|
||||||
|
|
||||||
#region run in debug if $DEBUG
|
|
||||||
[ "$DEBUG" = 'true' ] && set -x
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region globals
|
|
||||||
CYAN='\e[0;36m'
|
|
||||||
PURPLE='\e[0;35m'
|
|
||||||
NORMAL='\e[0m'
|
|
||||||
LOGFILE=${1:-'/var/log/arian/pactl-next-output-dev.sh.log'}
|
|
||||||
LOGDIR="$(dirname "${LOGFILE}")"
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region functions
|
|
||||||
function log() {
|
|
||||||
# logs strings to both the terminal and a file
|
|
||||||
# usage: log [1-3] 'String'
|
|
||||||
# 1 => INFORMATION
|
|
||||||
# 2 => ERROR
|
|
||||||
# 3 => DEBUG
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
1)
|
|
||||||
msg_type="INFORMATION"
|
|
||||||
;;
|
|
||||||
|
|
||||||
2)
|
|
||||||
msg_type="ERROR"
|
|
||||||
;;
|
|
||||||
|
|
||||||
3)
|
|
||||||
msg_type="DEBUG"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "Wrong input; exiting"
|
|
||||||
exit 1
|
|
||||||
esac
|
|
||||||
|
|
||||||
msg="[${PURPLE}$(date -Ins)${NORMAL}] [${CYAN}${msg_type}${NORMAL}]: $2"
|
|
||||||
# tee command from https://unix.stackexchange.com/questions/694671/leave-color-in-stdout-but-remove-from-tee
|
|
||||||
# (omits coloring in logfile)
|
|
||||||
echo -e "${msg}" | tee >(sed $'s/\033[[][^A-Za-z]*[A-Za-z]//g' >> ${LOGFILE})
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region main
|
|
||||||
[ -d "${LOGDIR}" ] || mkdir -p "${LOGDIR}"
|
|
||||||
|
|
||||||
ALL_SINKS=($(pactl list short sinks | awk '{ print $2 }'))
|
|
||||||
CURR_SINK=$(pactl get-default-sink)
|
|
||||||
CURR_INDEX=-1
|
|
||||||
|
|
||||||
log 1 "Using current sink [${CURR_SINK}]"
|
|
||||||
|
|
||||||
for i in "${!ALL_SINKS[@]}"; do
|
|
||||||
if [[ "${ALL_SINKS[$i]}" = "${CURR_SINK}" ]]; then
|
|
||||||
CURR_INDEX="$i"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
NEXT_INDEX=$(($((CURR_INDEX + 1))%(${#ALL_SINKS[@]})))
|
|
||||||
|
|
||||||
NEXT_SINK="${ALL_SINKS[$NEXT_INDEX]}"
|
|
||||||
log 1 "Switching to sink [${NEXT_SINK}]"
|
|
||||||
pactl set-default-sink "${ALL_SINKS[$NEXT_INDEX]}"
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
Loading…
Reference in New Issue