info-taskspooler: add script
parent
a65cbbcee6
commit
309b154233
|
@ -0,0 +1,39 @@
|
|||
# Script: info-taskspooler
|
||||
|
||||
Show queued/running count for one or more task spooler servers.
|
||||
|
||||
![info-taskspooler](screenshots/1.png)
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
- `task-spooler`
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
No arguments required, by default the script will output the count of the default task-spooler server.
|
||||
|
||||
If desired, arguments can be passed to show custom task-spooler servers by using the TS_SOCKET variable. These custom servers will need to use a socket filename format like /tmp/ts-socket.SOCK_NAME or the script will be unable to find the server. Arguments are passed as name,sock_name with sock_name being optional, e.g. `default yt,youtube p,podcast`.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/{ name }]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-task-spooler/info-task-spooler.sh
|
||||
format-prefix = "tsp "
|
||||
interval = 5
|
||||
...
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```ini
|
||||
[module/{ name }]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-task-spooler/info-task-spooler.sh default yt,youtube p,podcast
|
||||
interval = 5
|
||||
...
|
||||
```
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env 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
|
Loading…
Reference in New Issue