Compare commits

..

No commits in common. "fa4084ae07ef762921eb15d303e8d98cff014db7" and "9cff918c2e70f19b8bc730e6c39693f7faaa6cc9" have entirely different histories.

3 changed files with 18 additions and 101 deletions

View file

@ -1,7 +0,0 @@
{
"workbench.colorCustomizations": {
"activityBar.background": "#0C2E56",
"titleBar.activeBackground": "#104078",
"titleBar.activeForeground": "#F7FAFE"
}
}

View file

@ -21,8 +21,6 @@
const GETTEXT_DOMAIN = 'my-indicator-extension';
const { GObject, St } = imports.gi;
const GLib = imports.gi.GLib;
const ByteArray = imports.byteArray;
const ExtensionUtils = imports.misc.extensionUtils;
const Main = imports.ui.main;
@ -41,22 +39,11 @@ const Indicator = GObject.registerClass(
style_class: 'system-status-icon',
}));
let sampleRate = getCurrentSampleRate();
let currentSampleRate = new PopupMenu.PopupMenuItem(_("Sample Rate: " + sampleRate));
this.menu.addMenuItem(currentSampleRate);
let allowedRates = getAllowedSampleRates();
for (let i = 0; i < allowedRates.length; i++) {
let allowedRate = new PopupMenu.PopupMenuItem(_("Allowed Rates: " + allowedRates[i]));
allowedRate.connect('activate', () => {
console.log("set sample rate " + allowedRates[i]);
setSampleRate(allowedRates[i]);
currentSampleRate.label.text = "Sample Rate: " + getCurrentSampleRate();
let item = new PopupMenu.PopupMenuItem(_('Show Notification'));
item.connect('activate', () => {
Main.notify(_('Whatʼs up, folks?'));
});
this.menu.addMenuItem(allowedRate);
}
this.menu.addMenuItem(item);
}
});
@ -81,66 +68,3 @@ class Extension {
function init(meta) {
return new Extension(meta.uuid);
}
function setSampleRate(sampleRate) {
spawnCommandLine("pw-metadata -n settings 0 clock.rate " + sampleRate);
}
function getCurrentSampleRate() {
let res = spawnCommandLine("pw-metadata -n settings");
let lines = res.split(/\r?\n/);
for (let i = 0; i < lines.length; i++) {
if (lines[i].includes('clock.rate')) {
let phrases = lines[i].split(" ");
for (let j = 0; j < phrases.length; j++) {
if (phrases[j].includes("value")) {
return phrases[j].slice(7, -1);
}
}
}
}
return "not found";
}
function getAllowedSampleRates() {
let res = spawnCommandLine("pw-metadata -n settings");
let lines = res.split(/\r?\n/);
for (let i = 0; i < lines.length; i++) {
if (lines[i].includes('clock.allowed-rates')) {
let valueIndex = lines[i].indexOf("value");
if (valueIndex !== -1) {
return lines[i].slice(valueIndex + 9, -11).replaceAll(",", "").split(" ");
}
}
}
return "not found";
}
// Runs @command_line in the background, handling any errors that
// occur when trying to parse or start the program.
function spawnCommandLine(command_line) {
try {
let [, stdout, stderr, status] = GLib.spawn_command_line_sync(command_line);
if (status !== 0) {
if (stderr instanceof Uint8Array)
stderr = ByteArray.toString(stderr);
throw new Error(stderr);
}
if (stdout instanceof Uint8Array)
stdout = ByteArray.toString(stdout);
// Now were done blocking the main loop, phewf!
return stdout;
} catch (e) {
throw new Error(e);
}
}

View file

@ -1,7 +1,7 @@
{
"name": "PipewireSettings",
"description": "Change pipewire settings for the current session",
"uuid": "pipewiresettings@gavania.de",
"description": "Change pipewire settings for this session",
"uuid": "michaelh.95@t-online.de",
"shell-version": [
"43"
]