feat(displays): add display detection and management (sway) with daemon APIs and UI controls
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { ProcessManager } from './process-manager.ts';
|
||||
import { SystemInfo } from './system-info.ts';
|
||||
import { SystemInfo, type DisplayInfo } from './system-info.ts';
|
||||
import { Updater } from './updater.ts';
|
||||
import { UIServer } from '../ui/server.ts';
|
||||
import { runCommand } from '../utils/command.ts';
|
||||
@@ -147,6 +147,47 @@ export class EcoDaemon {
|
||||
return this.updater.upgradeToVersion(version);
|
||||
}
|
||||
|
||||
async getDisplays(): Promise<DisplayInfo[]> {
|
||||
if (this.swayStatus.state !== 'running') {
|
||||
return [];
|
||||
}
|
||||
const uid = await this.getUserUid();
|
||||
return this.processManager.getDisplays({
|
||||
runtimeDir: `/run/user/${uid}`,
|
||||
waylandDisplay: this.config.waylandDisplay,
|
||||
});
|
||||
}
|
||||
|
||||
async setDisplayEnabled(name: string, enabled: boolean): Promise<{ success: boolean; message: string }> {
|
||||
if (this.swayStatus.state !== 'running') {
|
||||
return { success: false, message: 'Sway is not running' };
|
||||
}
|
||||
this.log(`${enabled ? 'Enabling' : 'Disabling'} display ${name}`);
|
||||
const uid = await this.getUserUid();
|
||||
const result = await this.processManager.setDisplayEnabled(
|
||||
{ runtimeDir: `/run/user/${uid}`, waylandDisplay: this.config.waylandDisplay },
|
||||
name,
|
||||
enabled
|
||||
);
|
||||
return { success: result, message: result ? `Display ${name} ${enabled ? 'enabled' : 'disabled'}` : 'Failed' };
|
||||
}
|
||||
|
||||
async setKioskDisplay(name: string): Promise<{ success: boolean; message: string }> {
|
||||
if (this.swayStatus.state !== 'running') {
|
||||
return { success: false, message: 'Sway is not running' };
|
||||
}
|
||||
if (this.chromiumStatus.state !== 'running') {
|
||||
return { success: false, message: 'Chromium is not running' };
|
||||
}
|
||||
this.log(`Moving kiosk to display ${name}`);
|
||||
const uid = await this.getUserUid();
|
||||
const result = await this.processManager.setKioskDisplay(
|
||||
{ runtimeDir: `/run/user/${uid}`, waylandDisplay: this.config.waylandDisplay },
|
||||
name
|
||||
);
|
||||
return { success: result, message: result ? `Kiosk moved to ${name}` : 'Failed' };
|
||||
}
|
||||
|
||||
async start(): Promise<void> {
|
||||
this.log('EcoOS Daemon starting...');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user