91 lines
1.8 KiB
Bash
Executable file
91 lines
1.8 KiB
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
actions="quick
|
|
move
|
|
fetch-client
|
|
fetch-channel
|
|
away
|
|
not away
|
|
back
|
|
message
|
|
message-user"
|
|
|
|
action="$1"
|
|
if [ -n "$1" ]; then
|
|
shift
|
|
else
|
|
action=$(echo "$actions" | $DMENU)
|
|
fi
|
|
|
|
_ts_control_get_entity() {
|
|
entity=$(teamspeak-query-lib "$1s" | $DMENU)
|
|
if [ -z "$entity" ]; then
|
|
exit 1
|
|
fi
|
|
echo "$entity"
|
|
}
|
|
|
|
_ts_control_get_message() {
|
|
message=$(printf "\n" | $DMENU -p "message")
|
|
if [ -z "$message" ]; then
|
|
exit 1
|
|
fi
|
|
echo "$message"
|
|
}
|
|
|
|
_ts_control_move_self() {
|
|
channel=$(_ts_control_get_entity channel)
|
|
teamspeak-query-lib move --strict-channel "$channel"
|
|
}
|
|
|
|
_ts_control_fetch() {
|
|
target=$(_ts_control_get_entity "$1")
|
|
teamspeak-query-lib fetch "--strict-$1" "--$1" "$target"
|
|
}
|
|
|
|
case $action in
|
|
"quick")
|
|
action=$($DMENU < "$XDG_CONFIG_HOME/ts-control-quick")
|
|
if [ -z "$action" ]; then
|
|
exit 1
|
|
fi
|
|
eval "teamspeak-query-lib $action"
|
|
;;
|
|
"move")
|
|
_ts_control_move_self
|
|
;;
|
|
"fetch-client")
|
|
_ts_control_fetch client
|
|
;;
|
|
"fetch-channel")
|
|
_ts_control_fetch channel
|
|
;;
|
|
"not away")
|
|
teamspeak-query-lib move "Not Away From Keyboard"
|
|
teamspeak-query-lib update --microphone=false --speakers=false
|
|
;;
|
|
"away")
|
|
message=$(_ts_control_get_message)
|
|
teamspeak-query-lib move "Away From Keyboard"
|
|
teamspeak-query-lib update --away "$message"
|
|
teamspeak-query-lib update --microphone=false --speakers=false --away "$message"
|
|
;;
|
|
"back")
|
|
teamspeak-query-lib update --back
|
|
if [ -n "$1" ]; then
|
|
teamspeak-query-lib move "$1"
|
|
else
|
|
_ts_control_move_self "$1"
|
|
fi
|
|
teamspeak-query-lib update --microphone=true --speakers=true
|
|
;;
|
|
"message")
|
|
message=$(_ts_control_get_message)
|
|
teamspeak-query-lib message "$message"
|
|
;;
|
|
"message-user")
|
|
message=$(_ts_control_get_message)
|
|
user=$(_ts_control_get_entity client)
|
|
teamspeak-query-lib message --strict-client --client "$user" "$message"
|
|
;;
|
|
esac
|