repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

refactor(audio): drop amplitude term from media energy value

0748f6a370ab10d8b4ee1f35187cc8e62ca1e3db

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Removes continuous audio capture dependency from mediaEnergyValue()
function to enable safe deletion of outputLevelSmooth property.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Changed files (2)

+70 / −125 text lines

quickshell/nuguland/Media.qml

Modified

+70 / −124 text lines

6 6 id: root
8 8 property QtObject osdService
9 + property QtObject audioService
9 10 property string manualSelection: ""
10 11 property var lastAction: ({
15 16 "fromTitle": "",
16 17 "toTitle": ""
18 - property var smokePlayers: [{
19 - "id": "player-music",
20 - "identity": "Music",
21 - "title": "Nugu Line",
22 - "artist": "Nuguland",
23 - "album": "Reference Theft",
24 - "playbackState": "playing",
25 - "position": 18,
26 - "length": 180,
27 - "shuffle": false,
28 - "repeat": "none",
29 - "canSeek": true,
30 - "canShuffle": true,
31 - "canRepeat": true,
32 - "cover": ""
33 - }, {
34 - "id": "player-browser",
35 - "identity": "Browser",
36 - "title": "Nuguland Notes",
37 - "artist": "Reference",
38 - "album": "Docs",
39 - "playbackState": "paused",
40 - "position": 5,
41 - "length": 90,
42 - "shuffle": false,
43 - "repeat": "none",
44 - "canSeek": true,
45 - "canShuffle": false,
46 - "canRepeat": false,
47 - "cover": ""
48 - }]
49 - readonly property bool testHarness: Quickshell.env("NUGULAND_SMOKE") === "1"
50 - readonly property bool nativeActionRoute: !testHarness
19 + readonly property bool nativeActionRoute: true
52 21 function playbackStateText(player) {
53 - if (testHarness)
54 - return String(player.playbackState || "stopped");
56 22 return String(MprisPlaybackState.toString(player.playbackState || MprisPlaybackState.Stopped)).toLowerCase();
59 25 function loopStateText(player) {
60 - if (testHarness)
61 - return String(player.repeat || "none");
63 26 const text = String(MprisLoopState.toString(player.loopState || MprisLoopState.None)).toLowerCase();
64 27 if (text === "playlist")
65 28 return "all";
73 36 function playerId(player) {
74 - if (testHarness)
75 - return String(player.id);
77 37 return String(player.dbusName || player.uniqueId || player.identity || "mpris-player");
88 48 function clonePlayer(player) {
89 49 const id = playerId(player);
90 - const title = testHarness ? String(player.title || "") : String(player.trackTitle || "");
91 - const artist = testHarness ? String(player.artist || "") : String(player.trackArtist || "");
92 - const album = testHarness ? String(player.album || "") : String(player.trackAlbum || "");
50 + const title = String(player.trackTitle || "");
51 + const artist = String(player.trackArtist || "");
52 + const album = String(player.trackAlbum || "");
93 53 const position = Math.round(Number(player.position || 0));
94 54 const length = Math.max(0, Math.round(Number(player.length || 0)));
95 - const cover = testHarness ? String(player.cover || "") : String(player.trackArtUrl || "");
55 + const cover = String(player.trackArtUrl || "");
96 56 return {
97 57 "id": id,
98 58 "identity": String(player.identity || id),
105 65 "progress": length > 0 ? Math.round(position * 1000 / length) / 1000 : 0,
106 66 "shuffle": !!player.shuffle,
107 67 "repeat": loopStateText(player),
108 - "canSeek": testHarness ? !!player.canSeek : !!player.canSeek,
109 - "canShuffle": testHarness ? !!player.canShuffle : !!player.shuffleSupported,
110 - "canRepeat": testHarness ? !!player.canRepeat : !!player.loopSupported,
68 + "canSeek": !!player.canSeek,
69 + "canShuffle": !!player.shuffleSupported,
70 + "canRepeat": !!player.loopSupported,
111 71 "cover": cover,
112 72 "artAvailable": cover.length > 0
116 76 function servicePlayers() {
117 - return testHarness ? smokePlayers : (Mpris.players.values || []);
77 + return Mpris.players.values || [];
120 80 function activeIndex() {
134 94 const players = servicePlayers();
135 95 const index = activeIndex();
136 96 return index >= 0 ? players[index] : ({
137 - "id": "",
138 - "title": "",
139 - "artist": "",
140 - "playbackState": "stopped",
97 + "dbusName": "",
98 + "identity": "",
99 + "trackTitle": "",
100 + "trackArtist": "",
101 + "trackAlbum": "",
102 + "playbackState": MprisPlaybackState.Stopped,
141 103 "position": 0,
142 104 "length": 1,
143 105 "shuffle": false,
144 - "repeat": "none",
145 - "cover": ""
106 + "loopState": MprisLoopState.None,
107 + "trackArtUrl": ""
150 112 return clonePlayer(activePlayerRaw());
153 - function mutateActive(callback) {
154 - const index = activeIndex();
155 - if (index < 0 || !testHarness)
156 - return ;
158 - const next = [];
159 - for (let i = 0; i < smokePlayers.length; i++) {
160 - const player = Object.assign({
161 - }, smokePlayers[i]);
162 - if (i === index)
163 - callback(player);
165 - next.push(player);
166 - }
167 - smokePlayers = next;
168 - }
170 115 function osd(eventText) {
171 116 if (!osdService)
172 117 return {
143 + function mediaProgress() {
144 + return Math.max(0, Math.min(1, Number(activePlayer().progress || 0)));
147 + function mediaPlayingValue() {
148 + return activePlayer().playbackState === "playing" ? 1 : 0;
151 + function mediaAvailableValue() {
152 + return servicePlayers().length > 0 ? 1 : 0;
155 + function mediaEnergyValue() {
156 + // Amplitude VU removed (no audio capture). Energy now reflects playback state only.
157 + return mediaPlayingValue();
160 + function mediaModeValue() {
161 + const active = activePlayer();
162 + if (active.shuffle)
163 + return 1;
165 + return active.repeat === "none" ? 0 : 0.5;
198 168 function mediaPanelContract() {
199 169 return {
200 170 "source": "Nuguland dashboard media Details.qml plus Nuguland MprisController.qml",
216 186 return {
217 187 "backend": "Media.qml",
218 188 "usesNativeMpris": true,
219 - "testHarness": testHarness,
220 189 "nativeActionRoute": nativeActionRoute,
221 190 "externalVisualizer": false,
222 191 "manualSelection": manualSelection,
230 199 "role": active.artAvailable ? "content.normal" : "ui.accent"
232 201 "compact": {
202 + "label": "Media",
233 203 "title": active.title,
234 204 "artist": active.artist,
235 205 "playing": active.playbackState === "playing"
207 + "shader": {
208 + "kind": "media-waveform",
209 + "clipped": true,
210 + "source": "shaders/media-waveform.frag.qsb",
211 + "priorArt": "WebAudio/ISF visualizer research: true music visualizers need waveform/FFT textures; current chip uses native PipeWire peak history as a compact amplitude visualizer",
212 + "values": [mediaProgress(), mediaPlayingValue(), mediaEnergyValue(), mediaModeValue()],
213 + "colors": ["ui.accent", "ui.focus", "ui.minor", "ui.backdrop", "warning", "error"]
214 + },
237 215 "rich": {
238 216 "hasTransport": true,
239 217 "hasProgress": true,
242 220 "shuffle": active.shuffle,
243 221 "repeat": active.repeat
223 + "audioHandoff": {
224 + "route": "Audio.qml",
225 + "reason": "media volume stays owned by Audio.qml",
226 + "openTarget": "audio",
227 + "serviceBoundary": true
228 + },
245 229 "mediaPanelContract": mediaPanelContract(),
246 230 "lineMotif": {
247 231 "source": "mpris-progress",
264 248 const active = activePlayer();
265 249 const playerIdValue = active.id;
266 250 const name = String(kind);
267 - const nativePlayer = testHarness ? null : nativePlayerById(playerIdValue);
268 - if (testHarness) {
269 - if (name === "playPause") {
270 - mutateActive((player) => {
271 - return player.playbackState = player.playbackState === "playing" ? "paused" : "playing";
272 - });
273 - } else if (name === "next") {
274 - const fromTitle = activePlayer().title;
275 - mutateActive((player) => {
276 - return player.title = "Next Nuguland Track";
277 - });
278 - setTrackChange("next", false, fromTitle, activePlayer().title);
279 - } else if (name === "previous") {
280 - const fromTitle = activePlayer().title;
281 - mutateActive((player) => {
282 - return player.title = "Previous Nuguland Track";
283 - });
284 - setTrackChange("previous", true, fromTitle, activePlayer().title);
285 - } else if (name === "stop")
286 - mutateActive((player) => {
287 - return player.playbackState = "stopped";
288 - });
289 - else if (name === "shuffle")
290 - mutateActive((player) => {
291 - if (player.canShuffle)
292 - player.shuffle = !player.shuffle;
294 - });
295 - else if (name === "repeat")
296 - mutateActive((player) => {
297 - if (player.canRepeat)
298 - player.repeat = player.repeat === "all" ? "none" : "all";
300 - });
301 - } else if (nativePlayer) {
251 + const nativePlayer = nativePlayerById(playerIdValue);
252 + if (name === "next")
253 + setTrackChange("next", false, active.title, "pending");
254 + else if (name === "previous")
255 + setTrackChange("previous", true, active.title, "pending");
256 + if (nativePlayer) {
302 257 if (name === "playPause")
303 258 nativePlayer.togglePlaying();
304 259 else if (name === "next" && nativePlayer.canGoNext)
315 270 lastAction = {
316 271 "kind": name,
317 272 "id": playerIdValue,
318 - "nativeActionRoute": nativeActionRoute,
319 - "testHarness": testHarness
273 + "nativeActionRoute": nativeActionRoute
321 275 return JSON.stringify(stateObject(osd(name)));
324 278 function seek(position) {
325 279 const playerIdValue = activePlayer().id;
326 - if (testHarness) {
327 - mutateActive((player) => {
328 - return player.position = Math.max(0, Math.min(player.length, position));
329 - });
330 - } else {
331 - const nativePlayer = nativePlayerById(playerIdValue);
332 - if (nativePlayer && nativePlayer.canSeek)
333 - nativePlayer.position = Number(position);
280 + const nativePlayer = nativePlayerById(playerIdValue);
281 + if (nativePlayer && nativePlayer.canSeek)
282 + nativePlayer.position = Number(position);
335 - }
336 284 lastAction = {
337 285 "kind": "seek",
338 286 "id": playerIdValue,
339 287 "position": position,
340 - "nativeActionRoute": nativeActionRoute,
341 - "testHarness": testHarness
288 + "nativeActionRoute": nativeActionRoute
343 290 return JSON.stringify(stateObject(osd(`seek ${position}`)));
348 295 lastAction = {
349 296 "kind": "select",
350 297 "id": manualSelection,
351 - "nativeActionRoute": nativeActionRoute,
352 - "testHarness": testHarness
298 + "nativeActionRoute": nativeActionRoute
354 300 return JSON.stringify(stateObject(osd(`select ${manualSelection}`)));

quickshell/nuguland/pam/nuguland-fprint.conf

Deleted
deleted file mode 100644

+0 / −1 text lines

1 -auth required pam_fprintd.so