1
0
Fork 0
mirror of https://github.com/Horhik/dotfiles.git synced 2024-11-09 10:23:11 +00:00
Dotfiles/.config/polybar/themes/spacefull-dracula/polybar-scripts/info-taskspooler/info-taskspooler.sh
2020-09-05 14:43:37 +03:00

28 lines
737 B
Bash
Executable file

#!/bin/sh
# USAGE:
# No arguments: prints the job running/queued job count of the default tsp server
# Arguments: name,sock_name - one or more arguments, e.g. tsp yt,youtube p,podcasts
# sock_name is optional, will default to default tsp socket
# custom socket names will be generated as /tmp/ts-socket.SOCK_NAME, your TS_SOCKET will need to match
get_tsp_count() {
sock=/tmp/socket-ts.${1:-$(id -u)}
tsp_count=$(TS_SOCKET=$sock tsp|grep -E -c 'running|queued')
echo "${tsp_count:-0}"
}
# without argument, just show count of default socket
if [ $# -lt 1 ]; then
get_tsp_count
else
for t in "$@"; do
IFS=, read -r name sock_name <<- EOF
${t}
EOF
echo "${name} $(get_tsp_count "${sock_name}")"
done|sed 'N;s/\n/ /'
fi