feat: show running PulseAudio apps in a dropdown for easier knob targeting

- Add GET /api/apps endpoint that queries pulsectl for active sink inputs
  and returns deduplicated app names (application.name + process.binary)
- Add fetchRunningApps() API helper (returns [] on any failure, non-fatal)
- Fetch running apps on page load; expose a Refresh button in the Knobs
  section header to re-query without a full page reload
- KnobCard app_volume: wire target input to an HTML5 <datalist> so the
  browser shows a native autocomplete dropdown of running apps
- KnobCard group_volume: add a select + Add button beneath the textarea so
  users can pick a running app and append it without typing
- CSS: style the app-picker row and the compact refresh button in h2
This commit is contained in:
Sean Doran committed 2026-02-28 17:29:52 -05:00
1 parent 8963b494c3
commit 88216187d4
5 files changed
+147 -13

No files matched your search

+31 -8
View File
@@ -14,12 +14,14 @@ const BTN_INDICES = ['0', '1', '2', '3', '4'] as const;
let toastSeq = 0;
export default function App() {
const [config, setConfig] = useState<Config | null>(null);
const [saved, setSaved] = useState<Config | null>(null);
const [presets, setPresets] = useState<string[]>([]);
const [toasts, setToasts] = useState<ToastItem[]>([]);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [config, setConfig] = useState<Config | null>(null);
const [saved, setSaved] = useState<Config | null>(null);
const [presets, setPresets] = useState<string[]>([]);
const [toasts, setToasts] = useState<ToastItem[]>([]);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [runningApps, setRunningApps] = useState<string[]>([]);
const [appsLoading, setAppsLoading] = useState(false);
const addToast = useCallback((message: string, type: ToastItem['type'] = 'success') => {
const id = ++toastSeq;
@@ -39,6 +41,15 @@ export default function App() {
}
}, []);
const loadApps = useCallback(async () => {
setAppsLoading(true);
try {
setRunningApps(await api.fetchRunningApps());
} finally {
setAppsLoading(false);
}
}, []);
// Initial load
useEffect(() => {
void (async () => {
@@ -52,8 +63,9 @@ export default function App() {
setLoading(false);
}
await loadPresets();
await loadApps();
})();
}, [addToast, loadPresets]);
}, [addToast, loadPresets, loadApps]);
const isDirty = config !== null && JSON.stringify(config) !== JSON.stringify(saved);
@@ -128,13 +140,24 @@ export default function App() {
/>
<section className="card" id="knobs">
<h2>Knobs</h2>
<h2>
Knobs
<button
className="btn-secondary btn-refresh-apps"
onClick={() => void loadApps()}
disabled={appsLoading}
title="Refresh list of running apps"
>
{appsLoading ? '…' : '↻'} Running apps
</button>
</h2>
<div className="cards-grid">
{KNOB_INDICES.map((i) => (
<KnobCard
key={i}
index={Number(i)}
knob={config.knobs[i] ?? { action: 'sink_volume', target: 'default' }}
runningApps={runningApps}
onChange={(knob) =>
patchConfig('knobs', { ...config.knobs, [i]: knob })
}