mirror of
https://github.com/trycua/computer.git
synced 2026-01-05 21:09:58 -06:00
Add get_desktop_environment, set_wallpaper
This commit is contained in:
@@ -314,6 +314,10 @@ export abstract class BaseComputerInterface {
|
||||
abstract getScreenSize(): Promise<ScreenSize>;
|
||||
abstract getCursorPosition(): Promise<CursorPosition>;
|
||||
|
||||
// Desktop Actions
|
||||
abstract getDesktopEnvironment(): Promise<string>;
|
||||
abstract setWallpaper(path: string): Promise<void>;
|
||||
|
||||
// Clipboard Actions
|
||||
abstract copyToClipboard(): Promise<string>;
|
||||
abstract setClipboard(text: string): Promise<void>;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
*/
|
||||
|
||||
import type { ScreenSize } from '../types';
|
||||
import { BaseComputerInterface } from './base';
|
||||
import type { AccessibilityNode, CursorPosition, MouseButton } from './base';
|
||||
import { BaseComputerInterface } from './base';
|
||||
|
||||
export class MacOSComputerInterface extends BaseComputerInterface {
|
||||
// Mouse Actions
|
||||
@@ -212,6 +212,29 @@ export class MacOSComputerInterface extends BaseComputerInterface {
|
||||
return response.position as CursorPosition;
|
||||
}
|
||||
|
||||
// Desktop Actions
|
||||
/**
|
||||
* Get the current desktop environment string (e.g., 'xfce4', 'gnome', 'kde', 'mac', 'windows').
|
||||
*/
|
||||
async getDesktopEnvironment(): Promise<string> {
|
||||
const response = await this.sendCommand('get_desktop_environment');
|
||||
if (!response.success) {
|
||||
throw new Error((response.error as string) || 'Failed to get desktop environment');
|
||||
}
|
||||
return (response.environment as string) || 'unknown';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the desktop wallpaper image.
|
||||
* @param path Absolute path to the image file on the VM
|
||||
*/
|
||||
async setWallpaper(path: string): Promise<void> {
|
||||
const response = await this.sendCommand('set_wallpaper', { path });
|
||||
if (!response.success) {
|
||||
throw new Error((response.error as string) || 'Failed to set wallpaper');
|
||||
}
|
||||
}
|
||||
|
||||
// Clipboard Actions
|
||||
/**
|
||||
* Copy current selection to clipboard and return the content.
|
||||
|
||||
Reference in New Issue
Block a user