💥 ags: fix startup issues (and with that, errors with focusedClient bar widget)

This commit is contained in:
retrozinndev
2025-02-04 21:45:18 -03:00
parent 11f919ab1d
commit 80969071c4
21 changed files with 363 additions and 200 deletions
-10
View File
@@ -1,10 +0,0 @@
import { readFile } from "astal";
import { getUserDirs } from "./user";
export class Wal {
public static getColors(): JSON {
return JSON.parse(
readFile(`${getUserDirs().cache}/wal/colors.json`)!
);
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ import { getUserDirs } from "./user";
const monitoringPaths = [ "./scripts", "./window", "./app.ts", "env.d.ts" ];
interface InstanceProps {
export interface InstanceProps {
instanceName?: string;
log?: boolean;
}
+68 -10
View File
@@ -36,33 +36,91 @@ export class Wireplumber {
return this.getDefaultSource().get_volume() * 100;
}
public setSinkVolume(newSinkVolume: number) {
public setSinkVolume(newSinkVolume: number): void {
this.defaultSink.set_volume(
(newSinkVolume > this.maxSinkVolume ? this.maxSinkVolume : newSinkVolume) / 100
);
}
public setSourceVolume(newSourceVolume: number) {
public setSourceVolume(newSourceVolume: number): void {
this.defaultSource.set_volume(
newSourceVolume > this.maxSourceVolume ? this.maxSourceVolume : newSourceVolume / 100
);
}
public increaseSinkVolume(volumeIncrease: number) {
if(volumeIncrease > this.maxSinkVolume
|| (this.maxSinkVolume + volumeIncrease) > this.maxSinkVolume) {
public increaseSinkVolume(volumeIncrease: number): void {
if((this.getSinkVolume() + volumeIncrease) > this.maxSinkVolume) {
this.setSinkVolume(this.maxSinkVolume);
return;
}
this.setSinkVolume(this.getSinkVolume() + volumeIncrease);
}
public increaseSourceVolume(volumeIncrease: number) {
if(volumeIncrease > this.maxSourceVolume //TODO
|| (this.maxSinkVolume + volumeIncrease) > this.maxSinkVolume) {
this.setSinkVolume(this.maxSinkVolume);
public increaseSourceVolume(volumeIncrease: number): void {
if((this.getSourceVolume() + volumeIncrease) > this.maxSourceVolume) {
this.setSourceVolume(this.maxSourceVolume);
return;
}
this.setSinkVolume(this.getSinkVolume() + volumeIncrease);
this.setSourceVolume(this.getSourceVolume() + volumeIncrease);
}
public decreaseSinkVolume(volumeDecrease: number): void {
const absDecrease = Math.abs(volumeDecrease);
if((this.getSinkVolume() - absDecrease) < 0) {
this.setSinkVolume(0);
return;
}
this.setSinkVolume(this.getSinkVolume() - absDecrease);
}
public decreaseSourceVolume(volumeDecrease: number): void {
const absDecrease = Math.abs(volumeDecrease);
if((this.getSourceVolume() - absDecrease) < 0)
return this.setSourceVolume(0);
this.setSourceVolume(this.getSourceVolume() - absDecrease);
}
public muteSink(): void {
this.getDefaultSink().set_mute(true);
}
public muteSource(): void {
this.getDefaultSource().set_mute(true);
}
public unmuteSink(): void {
this.getDefaultSink().set_mute(false);
}
public unmuteSource(): void {
this.getDefaultSource().set_mute(false);
}
public isMutedSink(): boolean {
return this.getDefaultSink().get_mute();
}
public isMutedSource(): boolean {
return this.getDefaultSource().get_mute();
}
public toggleMuteSink(): void {
if(this.isMutedSink())
return this.unmuteSink();
return this.muteSink();
}
public toggleMuteSource(): void {
if(this.isMutedSource())
return this.unmuteSource();
return this.muteSource();
}
}
+2 -12
View File
@@ -1,22 +1,12 @@
// get open windows / interact with windows(e.g.: close, open or toggle)
import { Widget } from "astal/gtk3";
import { Bar } from "../window/Bar";
import { OSD } from "../window/OSD";
import { ControlCenter } from "../window/ControlCenter";
//import { FloatingNotifications } from "../window/FloatingNotifications";
import { getWindowsMap } from "../app";
export class Windows {
private static inst: Windows = new Windows();
/* Windows List(js object):
* add all windows here */
private readonly windows = {
"bar": Bar,
"osd": OSD,
"control-center": ControlCenter
//"floating-notifications": FloatingNotifications
};
private readonly windows = getWindowsMap();
public static getDefault(): Windows {
return Windows.inst;