Refactor ts-control with bashly

This commit is contained in:
Tobias Reisinger 2025-07-08 13:05:36 +02:00
parent 93ebbbd5d2
commit 7694bf365c
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
21 changed files with 217 additions and 175 deletions

0
control_src/lib/ntfy.sh Normal file
View file

46
control_src/lib/simple.sh Normal file
View file

@ -0,0 +1,46 @@
_ts_control_get_entity() {
entity=$(_ts_control_single_or_dmenu "$(teamspeak-query-lib "$1s")" "$2")
if [ -z "$entity" ]; then
exit 1
fi
echo "$entity"
}
_ts_control_get_message() {
if [ -n "$1" ];
then
message="$1"
else
message=$(printf "\n" | $DMENU -p "message")
fi
if [ -z "$message" ]; then
exit 1
fi
echo "$message"
}
_ts_control_move_self() {
channel=$(_ts_control_get_entity channel "$1" "$2")
teamspeak-query-lib move --strict-channel "$channel"
}
_ts_control_fetch() {
target=$(_ts_control_get_entity "$1" "$2")
teamspeak-query-lib fetch "--strict-$1" "--$1" "$target"
}
_ts_control_single_or_dmenu() {
filter="$2"
if [ "$filter" == "^$" ]; then
filter=""
fi
options=$(echo "$1" | grep "$filter")
count=$(echo "$options" | wc -l)
if [ "$count" -eq 1 ]; then
echo "$options"
else
echo "$1" | $DMENU
fi
}