executable_voxtype-polybar.sh

 1#!/bin/bash
 2# Wrapper for voxtype status to output polybar-friendly format
 3#
 4# Usage:
 5#   voxtype-polybar.sh         - output status for polybar
 6#   voxtype-polybar.sh toggle  - launch if stopped, toggle recording if running
 7#
 8# Environment variables (set in polybar module):
 9#   color_foreground - default text color
10#   color_primary    - accent/alert color (used for recording)
11#   color_secondary  - secondary accent (used for transcribing)
12
13output=$(voxtype status --format json 2>/dev/null)
14
15if [[ -z "$output" ]]; then
16	echo ""
17	exit 0
18fi
19
20alt=$(echo "$output" | jq -r '.alt // "idle"')
21
22# Handle toggle action
23if [[ "$1" == "toggle" ]]; then
24	if [[ "$alt" == "stopped" ]]; then
25		setsid fish -c "opx voxtype" >/dev/null 2>&1 &
26	else
27		voxtype record toggle
28	fi
29	exit 0
30fi
31
32# Use env vars if set, otherwise fall back to reasonable defaults
33fg="${color_foreground:-#cdd6f4}"
34recording="${color_primary:-#f38ba8}"
35transcribing="${color_secondary:-#f9e2af}"
36
37case "$alt" in
38stopped)
39	echo ""
40	;;
41idle)
42	echo "󰍬"
43	;;
44recording)
45	echo "%{F${recording}}󰍬%{F-}"
46	;;
47transcribing)
48	echo "%{F${transcribing}}󰮍%{F-}"
49	;;
50error)
51	echo "%{F${recording}}%{F-}"
52	;;
53*)
54	echo "󰍬"
55	;;
56esac