Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jas-SinghFSU authored Dec 27, 2024
2 parents 110d11a + 5163095 commit fe2746f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
31 changes: 18 additions & 13 deletions src/lib/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ensureDirectory } from './session';
import Variable from 'astal/variable';
import { monitorFile, readFile, writeFile } from 'astal/file';
import GLib from 'gi://GLib?version=2.0';
import { errorHandler } from './utils';

type OptProps = {
persistent?: boolean;
Expand Down Expand Up @@ -88,8 +89,8 @@ export class Opt<T = unknown> extends Variable<T> {
if (rawData && rawData.trim() !== '') {
try {
cacheData = JSON.parse(rawData) as Record<string, unknown>;
} catch {
// do nuffin
} catch (error) {
errorHandler(error);
}
}

Expand Down Expand Up @@ -178,19 +179,23 @@ export function opt<T>(initial: T, props?: OptProps): Opt<T> {
* @returns An array of all found `Opt` instances.
*/
function getOptions(object: Record<string, unknown>, path = '', arr: Opt[] = []): Opt[] {
for (const key in object) {
const value = object[key];
const id = path ? `${path}.${key}` : key;

if (value instanceof Variable) {
const optValue = value as Opt;
optValue.id = id;
arr.push(optValue);
} else if (typeof value === 'object' && value !== null) {
getOptions(value as Record<string, unknown>, id, arr);
try {
for (const key in object) {
const value = object[key];
const id = path ? `${path}.${key}` : key;

if (value instanceof Variable) {
const optValue = value as Opt;
optValue.id = id;
arr.push(optValue);
} else if (typeof value === 'object' && value !== null) {
getOptions(value as Record<string, unknown>, id, arr);
}
}
return arr;
} catch (error) {
errorHandler(error);
}
return arr;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/lib/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ declare global {
}

export function ensureDirectory(path: string): void {
if (!GLib.file_test(path, GLib.FileTest.EXISTS)) Gio.File.new_for_path(path).make_directory_with_parents(null);
if (!GLib.file_test(path, GLib.FileTest.EXISTS)) {
Gio.File.new_for_path(path).make_directory_with_parents(null);
}
}

export function ensureFile(path: string): void {
Expand Down
10 changes: 5 additions & 5 deletions src/scss/style/menus/audiomenu.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.menu-items.audio {
border-color: if($bar-menus-monochrome, $bar-menus-border-color, $bar-menus-menu-volume-border-color);
opacity: $bar-menus-opacity * 0.01;
}

.menu-items-container.audio {
min-width: 18em * $bar-menus-menu-volume-scaling * 0.01;

Expand All @@ -9,11 +14,6 @@

background: if($bar-menus-monochrome, $bar-menus-background, $bar-menus-menu-volume-background-color);

.menu-items {
border-color: if($bar-menus-monochrome, $bar-menus-border-color, $bar-menus-menu-volume-border-color);
opacity: $bar-menus-opacity * 0.01;
}

.menu-dropdown-label.audio {
color: if($bar-menus-monochrome, $bar-menus-label, $bar-menus-menu-volume-label-color);
}
Expand Down

0 comments on commit fe2746f

Please sign in to comment.