404 lines
7.6 KiB
TypeScript
404 lines
7.6 KiB
TypeScript
import Gio from "gi://Gio";
|
|
|
|
/**
|
|
* Sway IPC message types
|
|
*
|
|
* @see man:sway-ipc(7)
|
|
*/
|
|
export enum SwayMessage {
|
|
/**
|
|
* Runs the payload as sway commands
|
|
*/
|
|
RUN_COMMAND = 0,
|
|
/**
|
|
* Get the list of current workspaces
|
|
*/
|
|
GET_WORKSPACES = 1,
|
|
SUBSCRIBE = 2,
|
|
GET_OUTPUTS = 3,
|
|
GET_TREE = 4,
|
|
GET_MARKS = 5,
|
|
GET_BAR_CONFIG = 6,
|
|
GET_VERSION = 7,
|
|
GET_BINDING_MODES = 8,
|
|
GET_CONFIG = 9,
|
|
SEND_TICK = 10,
|
|
SYNC = 11,
|
|
GET_BINDING_STATE = 12,
|
|
GET_INPUTS = 100,
|
|
GET_SEATS = 101,
|
|
}
|
|
|
|
export enum SwayEvent {
|
|
WORKSPACE = 0x80000000,
|
|
OUTPUT = 0x80000001,
|
|
MODE = 0x80000002,
|
|
WINDOW = 0x80000003,
|
|
BARCONFIG_UPDATE = 0x80000004,
|
|
BINDING = 0x80000005,
|
|
SHUTDOWN = 0x80000006,
|
|
TICK = 0x80000007,
|
|
BAR_STATE_UPDATE = 0x80000014,
|
|
INPUT = 0x80000015,
|
|
}
|
|
|
|
export enum SubpixelHinting {
|
|
NONE = "none",
|
|
RGB = "rgb",
|
|
BGR = "bgr",
|
|
VRGB = "vrgb",
|
|
VBGR = "vbgr",
|
|
}
|
|
|
|
export type OutputTransform =
|
|
| "normal"
|
|
| "90"
|
|
| "180"
|
|
| "270"
|
|
| "flipped"
|
|
| "flipped-90"
|
|
| "flipped-180"
|
|
| "flipped-270";
|
|
|
|
/**
|
|
* A rectangle with a top-left corner at (x, y) and a width and height. Defines
|
|
* a region of the screen.
|
|
*/
|
|
export interface Rect {
|
|
x: number;
|
|
y: number;
|
|
width: number;
|
|
height: number;
|
|
}
|
|
|
|
/**
|
|
* The response to a command.
|
|
*/
|
|
export interface CommandResponse {
|
|
/**
|
|
* Whether the command was successful
|
|
*/
|
|
success: boolean;
|
|
/**
|
|
* The error message if the command was not successful.
|
|
* Undefined if the command was successful.
|
|
*/
|
|
error?: string;
|
|
/**
|
|
* Whether the command was not successful due to a parse error.
|
|
* Undefined if the command was successful.
|
|
*/
|
|
parse_error?: boolean;
|
|
}
|
|
|
|
/**
|
|
* A workspace as returned by GET_WORKSPACES
|
|
*/
|
|
export interface WorkspaceResponse {
|
|
/**
|
|
* The name of the workspace
|
|
*/
|
|
name: string;
|
|
/**
|
|
* The number of the workspace
|
|
*/
|
|
num: number;
|
|
/**
|
|
* Whether the workspace is focused
|
|
*/
|
|
focused: boolean;
|
|
/**
|
|
* Whether the workspace is visible
|
|
*/
|
|
visible: boolean;
|
|
/**
|
|
* Whether the workspace is urgent
|
|
*/
|
|
urgent: boolean;
|
|
/**
|
|
* The output the workspace is on
|
|
*/
|
|
output: string;
|
|
/**
|
|
* The rect of the workspace
|
|
*/
|
|
rect: Rect;
|
|
}
|
|
|
|
/**
|
|
* A sway output's modes as returned by GET_OUTPUTS
|
|
*/
|
|
export interface OutputMode {
|
|
/**
|
|
* The width of the mode in pixels
|
|
*/
|
|
width: number;
|
|
/**
|
|
* The height of the mode in pixels
|
|
*/
|
|
height: number;
|
|
/**
|
|
* The refresh rate of the mode in millihertz
|
|
*/
|
|
refresh: number;
|
|
}
|
|
|
|
/**
|
|
* A sway output as returned by GET_OUTPUTS
|
|
*/
|
|
export interface OutputResponse {
|
|
/**
|
|
* The name of the output.
|
|
*
|
|
* This is based on the hardware location of the output, e.g. "HDMI-A-1".
|
|
*/
|
|
name: string;
|
|
/**
|
|
* The make of the output, e.g. "Dell".
|
|
*/
|
|
make: string;
|
|
/**
|
|
* The model of the output, e.g. "U2412M".
|
|
*/
|
|
model: string;
|
|
/**
|
|
* The serial number of the output.
|
|
*/
|
|
serial: string;
|
|
/**
|
|
* Whether this output is active/enabled.
|
|
*/
|
|
active: boolean;
|
|
/**
|
|
* Whether this output is on/off.
|
|
*/
|
|
power: boolean;
|
|
/**
|
|
* The scale of the output. Will be -1 if the output is disabled.
|
|
*/
|
|
scale: number;
|
|
/**
|
|
* The subpixel hinting of the output.
|
|
*/
|
|
subpixel_hinting: SubpixelHinting;
|
|
/**
|
|
* The current transform of the output.
|
|
*/
|
|
transform: OutputTransform;
|
|
/**
|
|
* The name of the workspace currently visible on the output.
|
|
*/
|
|
current_workspace: string;
|
|
/**
|
|
* The bounds of the output.
|
|
*/
|
|
rect: Rect;
|
|
/**
|
|
* The modes supported by the output.
|
|
*/
|
|
modes: OutputMode[];
|
|
/**
|
|
* The current mode of the output.
|
|
*/
|
|
current_mode: OutputMode;
|
|
}
|
|
|
|
export enum NodeType {
|
|
ROOT = "root",
|
|
OUTPUT = "output",
|
|
WORKSPACE = "workspace",
|
|
CONTAINER = "con",
|
|
FLOATING_CONTAINER = "floating_con",
|
|
}
|
|
|
|
export enum NodeBorder {
|
|
NONE = "none",
|
|
PIXEL = "pixel",
|
|
NORMAL = "normal",
|
|
CSD = "csd",
|
|
}
|
|
|
|
export enum NodeLayout {
|
|
SPLITH = "splith",
|
|
SPLITV = "splitv",
|
|
STACKED = "stacked",
|
|
TABBED = "tabbed",
|
|
OUTPUT = "output",
|
|
}
|
|
|
|
export enum NodeOrientation {
|
|
HORIZONTAL = "horizontal",
|
|
VERTICAL = "vertical",
|
|
NONE = "none",
|
|
}
|
|
|
|
export enum NodeFullscreenMode {
|
|
NONE = 0,
|
|
WORKSPACE = 1,
|
|
GLOBAL = 2,
|
|
}
|
|
|
|
export interface XWaylandWindowProperties {
|
|
class: string;
|
|
instance: string;
|
|
title: string;
|
|
window_role: string;
|
|
window_type: string;
|
|
transient_for: number;
|
|
}
|
|
|
|
/**
|
|
* A sway node as returned by GET_TREE
|
|
*/
|
|
export interface TreeNode {
|
|
id: number;
|
|
name: string;
|
|
type: NodeType;
|
|
border: NodeBorder;
|
|
current_border_width: number;
|
|
layout: NodeLayout;
|
|
orientation: NodeOrientation;
|
|
percent: number | null;
|
|
rect: Rect;
|
|
window_rect: Rect;
|
|
deco_rect: Rect;
|
|
geometry: Rect;
|
|
urgent?: boolean;
|
|
sticky: boolean;
|
|
marks: string[];
|
|
focused: boolean;
|
|
focus: number[];
|
|
nodes: TreeNode[];
|
|
representation?: string;
|
|
fullscreen_mode?: NodeFullscreenMode;
|
|
app_id?: string | null;
|
|
pid?: number;
|
|
visible?: boolean;
|
|
shell?: "xdg_shell" | "xwayland";
|
|
inhibit_idle?: boolean;
|
|
window?: number;
|
|
window_properties?: XWaylandWindowProperties;
|
|
output?: string;
|
|
}
|
|
|
|
export enum InputType {
|
|
KEYBOARD = "keyboard",
|
|
POINTER = "pointer",
|
|
TOUCH = "touch",
|
|
TABLET_TOOL = "tablet_tool",
|
|
TABLET_PAD = "tablet_pad",
|
|
SWITCH = "switch",
|
|
}
|
|
|
|
export enum LibInputAccelProfile {
|
|
NONE = "none",
|
|
FLAT = "flat",
|
|
ADAPTIVE = "adaptive",
|
|
}
|
|
|
|
export enum LibInputBool {
|
|
TRUE = "enabled",
|
|
FALSE = "disabled",
|
|
}
|
|
|
|
/**
|
|
* The configuration of a libinput device as returned by GET_INPUTS
|
|
*/
|
|
export interface LibInputDevice {
|
|
send_events: "enabled" | "disabled" | "disabled_on_external_mouse";
|
|
tap: LibInputBool;
|
|
tap_button_map: "lmr" | "lrm";
|
|
tap_drag: LibInputBool;
|
|
tap_drag_lock: LibInputBool;
|
|
accel_speed: number;
|
|
accel_profile: LibInputAccelProfile;
|
|
natural_scroll: LibInputBool;
|
|
left_handed: LibInputBool;
|
|
click_method: "none" | "button_areas" | "clickfinger";
|
|
middle_emulation: LibInputBool;
|
|
scroll_method: "none" | "two_finger" | "edge" | "on_button_down";
|
|
scroll_button: number;
|
|
scroll_button_lock: LibInputBool;
|
|
dwt: LibInputBool;
|
|
dwtp: LibInputBool;
|
|
calibration_matrix: [number, number, number, number, number, number];
|
|
}
|
|
|
|
/**
|
|
* A sway input device as returned by GET_INPUTS
|
|
*/
|
|
export interface InputResponse {
|
|
identifier: string;
|
|
name: string;
|
|
vendor: number;
|
|
product: number;
|
|
type: InputType;
|
|
xkb_active_layout_name?: string;
|
|
xkb_layout_names?: string[];
|
|
xkb_active_layout_index?: number;
|
|
scroll_factor?: number;
|
|
libinput?: LibInputDevice;
|
|
}
|
|
|
|
export enum WorkspaceEventChange {
|
|
INIT = "init",
|
|
EMPTY = "empty",
|
|
FOCUS = "focus",
|
|
MOVE = "move",
|
|
RENAME = "rename",
|
|
URGENT = "urgent",
|
|
RELOAD = "reload",
|
|
}
|
|
|
|
export interface WorkspaceEvent {
|
|
change: WorkspaceEventChange;
|
|
current: TreeNode;
|
|
old: TreeNode | null;
|
|
}
|
|
|
|
export interface OutputEvent {
|
|
/**
|
|
* The change that triggered the event. Currently, this is always "unspecified".
|
|
* @todo: Update with new values when sway adds them
|
|
*/
|
|
change: "unspecified";
|
|
}
|
|
|
|
export interface ModeEvent {
|
|
/**
|
|
* The new binding mode.
|
|
*/
|
|
change: string;
|
|
pango_markup: boolean;
|
|
}
|
|
|
|
export enum WindowEventChange {
|
|
NEW = "new",
|
|
CLOSE = "close",
|
|
FOCUS = "focus",
|
|
TITLE = "title",
|
|
FULLSCREEN_MODE = "fullscreen_mode",
|
|
MOVE = "move",
|
|
FLOATING = "floating",
|
|
URGENT = "urgent",
|
|
MARK = "mark",
|
|
}
|
|
|
|
export interface WindowEvent {
|
|
change: WindowEventChange;
|
|
container: TreeNode;
|
|
}
|
|
|
|
export enum InputEventChange {
|
|
ADDED = "added",
|
|
REMOVED = "removed",
|
|
XKB_KEYMAP = "xkb_keymap",
|
|
XKB_LAYOUT = "xkb_layout",
|
|
LIBINPUT_CONFIG = "libinput_config",
|
|
}
|
|
|
|
export interface InputEvent {
|
|
change: InputEventChange;
|
|
input: InputResponse;
|
|
}
|