feat: add printer cups in bar
This commit is contained in:
24
waybar/.config/waybar/scripts/print-queue.sh
Executable file
24
waybar/.config/waybar/scripts/print-queue.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
jobs_output="$(lpstat -o 2>/dev/null)"
|
||||
status=$?
|
||||
|
||||
if [ "$status" -ne 0 ]; then
|
||||
printf '%s\n' '{"text":" n/a","class":"disabled","tooltip":"CUPS is unavailable"}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$jobs_output" ]; then
|
||||
printf '%s\n' '{"text":"","class":"idle","tooltip":"No print jobs queued"}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
job_count="$(printf '%s\n' "$jobs_output" | sed '/^[[:space:]]*$/d' | wc -l | tr -d ' ')"
|
||||
|
||||
if [ "$job_count" = "1" ]; then
|
||||
tooltip="1 print job queued"
|
||||
else
|
||||
tooltip="$job_count print jobs queued"
|
||||
fi
|
||||
|
||||
printf '{"text":" %s","class":"active","tooltip":"%s"}\n' "$job_count" "$tooltip"
|
||||
Reference in New Issue
Block a user