-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdictee-audio-sources
More file actions
executable file
·55 lines (53 loc) · 1.8 KB
/
Copy pathdictee-audio-sources
File metadata and controls
executable file
·55 lines (53 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# dictee-audio-sources — Liste les sources audio disponibles pour le plasmoid
# Format: value|icon|label (une ligne par source)
echo "|audio-input-microphone|System default"
pw-dump 2>/dev/null | python3 -c "
import json, sys
nodes = json.loads(sys.stdin.read())
# Map app names to system icon names
APP_ICONS = {
'firefox': 'firefox',
'chromium': 'chromium',
'chrome': 'google-chrome',
'brave': 'brave',
'vlc': 'vlc',
'mpv': 'mpv',
'spotify': 'spotify',
'audacious': 'audacious',
'rhythmbox': 'rhythmbox',
'elisa': 'elisa',
'kaffeine': 'kaffeine',
'totem': 'totem',
'obs': 'obs',
'discord': 'discord',
'telegram': 'telegram',
'steam': 'steam',
}
for n in nodes:
if n.get('type') != 'PipeWire:Interface:Node':
continue
p = n.get('info', {}).get('props', {})
mc = p.get('media.class', '')
nn = p.get('node.name', '')
if mc == 'Audio/Source' and not nn.endswith('.monitor'):
print(nn + '|audio-input-microphone|' + p.get('node.description', nn))
elif mc == 'Audio/Source' and nn.endswith('.monitor'):
print(nn + '|audio-speakers|Monitor: ' + p.get('node.description', nn))
elif mc == 'Stream/Output/Audio':
a = p.get('application.name', '?')
m = p.get('media.name', '')
# Find matching icon
icon = 'applications-multimedia'
for key, val in APP_ICONS.items():
if key in a.lower():
icon = val
break
label = a
if m and m != a:
label += ' — ' + m[:50]
# Sauvegarder app:nom au lieu de l'ID numérique — les IDs changent
# après sleep/hibernation ou redémarrage de l'app
app_key = 'app:' + a.lower().split()[0]
print(app_key + '|' + icon + '|' + label)
" 2>/dev/null