Documentation
¶
Overview ¶
Contains enums for niri models.
These are not really structs, nor are they actions or events either, but can be used in models.
Package models contains all the necessary models for different niri objects.
Most of these models are defined in https://docs.rs/niri-ipc/latest/niri_ipc/index.html#structs
Index ¶
- type ActionConfig
- type Config
- type ConfiguredMode
- type ConfiguredPosition
- type KeyboardLayouts
- type Layer
- type LayerSurface
- type LayerSurfaceKeyboardInteractivity
- type LogicalOutput
- type Match
- type Mode
- type ModeToSet
- type NiriRequest
- type Output
- type OutputAction
- type OutputConfigChanged
- type OutputSlice
- type Overview
- type PickedColor
- type PositionToSet
- type PossibleKeys
- type ReferenceKeys
- type Response
- type Rule
- type ScaleToSet
- type SpawnOrFocus
- type Transform
- type VrrToSet
- type Window
- type WindowLayout
- type WindowSlice
- type Workspace
- type WorkspaceSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionConfig ¶ added in v0.6.0
type ActionConfig struct {
// When contains the expression we want to evaluate.
//
// "when": "model.ID == 3" for a WorkspaceActivated event, evaluates to true if
// the workspace that was activated has an ID: 3.
When string `json:"when,omitempty"`
// Params contains the rest of the parameters to be defined for the action.
//
// NOTE: You don't need to set "params" in your config, but just the fields, i.e. "ID": 6 instead
// of "Params": {"ID": 6}.
Params json.RawMessage `json:"-"`
}
ActionConfig adds support for conditionally run the action.
The "when" field uses the expr module to evaluate the expression, and returns a boolean for the condition. An example configuration could be:
{
"events": {
"WorkspaceActivated": {
"FocusWindow": {
"when": "model.ID == 3",
"ID": 6
}
}
}
}
This means that when an event "WorkspaceActivated" happens, we only run the action "FocusWindow" if the workspace that was activated has an ID == 3.
func (*ActionConfig) UnmarshalJSON ¶ added in v0.6.0
func (a *ActionConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON overrides the unmarshaling of an ActionConfig.
We don't want to have the "When" field present in the rawMessage.
type Config ¶
type Config struct {
// LogLevel is the log level to use. One of "DEBUG", "INFO", "WARN", "ERROR" should be used. Defaults to "INFO".
LogLevel string `json:"logLevel"`
// Rules contains the rules to match windows, and the actions to perform on them.
Rules []Rule `json:"rules,omitempty"`
// ScratchpadWorkspace is the name of the scratchpad workspace. Defaults to "scratchpad".
//
// NOTE: The named workspace must be defined in niri config.
ScratchpadWorkspace string `json:"scratchpadWorkspace,omitempty"`
// Launcher is the full path to the preferred launcher to use.
Launcher string `json:"launcher,omitempty"`
// LauncherOptions are the options to pass to the launcher.
LauncherOptions string `json:"launcherOptions"`
// SpawnOrFocus defines the configuration for the spawn-or-focus command.
SpawnOrFocus SpawnOrFocus `json:"spawnOrFocus"`
// ShowScratchpadActions lists actions that should be performed on the shown scratchpad window.
//
// The `scratch show` command will always run MoveWindowToWorkspace and FocusWindow, but in addition can perform the following actions,
// e.g. if you want to center the window or resize it or something.
ShowScratchpadActions map[string]json.RawMessage `json:"showScratchpadActions,omitempty"`
// Events contains the event types to listen to, and the actions to run on the specified event.
Events map[string]map[string]ActionConfig `json:"events,omitempty"`
}
Config contains the configuration for nirimgr.
type ConfiguredMode ¶
type ConfiguredMode struct {
// Width is the width in physical pixels.
Width uint16 `json:"width"`
// Height is the height in physical pixels.
Height uint16 `json:"height"`
// Refresh is the refresh rate.
Refresh float64 `json:"refresh,omitempty"`
}
ConfiguredMode is the output mode as set in the config file.
type ConfiguredPosition ¶
type ConfiguredPosition struct {
// X is the logical x position.
X int32 `json:"x"`
// Y is the logical y position.
Y int32 `json:"y"`
}
ConfiguredPosition is the output position as set in the config file.
type KeyboardLayouts ¶
type KeyboardLayouts struct {
// Names is the XKB names of the configured layouts.
Names []string `json:"names"`
// CurrentIdx is the index of the currently active layout in Names.
CurrentIdx uint8 `json:"current_idx"`
}
KeyboardLayouts is the configured keyboard layouts.
type Layer ¶
type Layer struct {
// Background is the background layer.
Background string `json:"Background,omitempty"`
// Bottom is the bottom layer.
Bottom string `json:"Bottom,omitempty"`
// Top is the top layer.
Top string `json:"Top,omitempty"`
// Overlay is the overlay layer.
Overlay string `json:"Overlay,omitempty"`
}
Layer is the layer-shell layer.
type LayerSurface ¶
type LayerSurface struct {
// Namespace is the namespace provided by the layer-shell client.
Namespace string `json:"namespace"`
// Output is the name of the output the surface is on.
Output string `json:"output"`
// Layer is the layer that the surface is on.
Layer Layer `json:"layer"`
// KeyboardInteractivity is the surface's keyboard interactivity mode.
KeyboardInteractivity LayerSurfaceKeyboardInteractivity `json:"keyboard_interactivity"`
}
LayerSurface is the layer-shell surface.
type LayerSurfaceKeyboardInteractivity ¶
type LayerSurfaceKeyboardInteractivity struct {
// None tells that the surface cannot receive keyboard focus.
None string `json:"None,omitempty"`
// Exclusive tells that the surface receives keyboard focus whenever possible.
Exclusive string `json:"Exclusive,omitempty"`
// OnDemand tells that the surface receives keyboard focus on demand, e.g. when clicked.
OnDemand string `json:"OnDemand,omitempty"`
}
LayerSurfaceKeyboardInteractivity is the keyboard interactivity modes for a layer-shell surface.
type LogicalOutput ¶
type LogicalOutput struct {
// X is the logical x position.
X int `json:"x"`
// Y is the logical y position.
Y int `json:"y"`
// Width is the width in logical pixels.
Width int `json:"width"`
// Height is the height in logical pixels.
Height int `json:"height"`
// Scale is the scale factor.
Scale float64 `json:"scale"`
// Transform sets the transformation of the output.
Transform string `json:"transform"`
}
LogicalOutput is the logical output in the compositor's coordinate space.
type Match ¶
type Match struct {
// Title matches the title of the window. Used only for rules with type "window".
Title string `json:"title,omitempty"`
// AppID matches the app-id of the window. Used only for rules with type "window".
AppID string `json:"appId,omitempty"`
// Name is used for rule types "workspace" to match on the workspace name.
Name string `json:"name,omitempty"`
// Output is used for rule types "workspace" to match on the workspace output name.
Output string `json:"output,omitempty"`
}
Match is used to match a window.
func (Match) WindowMatches ¶ added in v0.2.0
WindowMatches checks if the window matches the specified rule match.
func (Match) WorkspaceMatches ¶ added in v0.2.0
WorkspaceMatches checks if the workspace matches the specified rule match.
type Mode ¶
type Mode struct {
// Width is the width in physical pixels.
Width int `json:"width"`
// Height is the height in physical pixels.
Height int `json:"height"`
// RefreshRate is the refresh rate in millihertz.
RefreshRate int `json:"refresh_rate"`
// IsPreferred tells whether this mode is preferred by the monitor.
IsPreferred bool `json:"is_preferred"`
}
Mode is the output mode.
type ModeToSet ¶
type ModeToSet struct {
// Automatic tells that niri will pick the mode automatically.
Automatic string `json:"Automatic,omitempty"`
// Specific tells that niri should pick a specific mode.
Specific ConfiguredMode `json:"Specific,omitempty"`
}
ModeToSet is the output mode to set.
type NiriRequest ¶
type NiriRequest string
NiriRequest is the representation of a simple niri request.
The request is sent to the socket as a string, e.g. "Windows" returns all the current windows.
const ( // Outputs lists connected outputs Outputs NiriRequest = "Outputs" // Workspaces lists workspaces Workspaces NiriRequest = "Workspaces" // Windows lists open windows Windows NiriRequest = "Windows" // Layers lists open layer-shell surfaces Layers NiriRequest = "Layers" // ListKeyboardLayouts lists the configured keyboard layouts ListKeyboardLayouts NiriRequest = "KeyboardLayouts" // FocusedOutput prints information about the focused output FocusedOutput NiriRequest = "FocusedOutput" // FocusedWindow prints information about the focused window FocusedWindow NiriRequest = "FocusedWindow" // PickWindow to pick a window with the mouse and print information about it. Not applicable to nirimgr. PickWindow NiriRequest = "PickWindow" // PickColor to pick a color from the screen with the mouse. Not applicable to nirimgr. PickColor NiriRequest = "PickColor" // RunAction performs an action RunAction NiriRequest = "Action" // ChangeOutput changes output configuration temporarily ChangeOutput NiriRequest = "Output" // EventStream starts continuously receiving events from the compositor EventStream NiriRequest = "EventStream" // Version prints the version of the running niri instance Version NiriRequest = "Version" // RequestError requests an error from the running niri instance RequestError NiriRequest = "RequestError" // OverviewState prints the overview state OverviewState NiriRequest = "OverviewState" )
type Output ¶
type Output struct {
// Name is the name of the output.
Name string `json:"name"`
// Make is the textual description of the manufacturer.
Make string `json:"make"`
// Model is the textual description of the model.
Model string `json:"model"`
// Serial is the serial of the output, if known.
Serial string `json:"serial"`
// PhysicalSize is the physical width and height of the output in mm, if known.
PhysicalSize []int `json:"physical_size"`
// Modes is the available modes for the output.
Modes []Mode `json:"modes"`
// CurrentMode is the current mode. None if the output is disabled.
CurrentMode int `json:"current_mode"`
// VrrSupported tells whether the output supports variable refresh rate.
VrrSupported bool `json:"vrr_supported"`
// VrrEnabled tells whether the variable refresh rate is enabled on the output.
VrrEnabled bool `json:"vrr_enabled"`
// Logical is the logical output information. None if the output is not mapped to any logical output (e.g. if it's disabled).
Logical LogicalOutput `json:"logical"`
}
Output is the connected output.
type OutputAction ¶
type OutputAction struct {
// Off tells niri to turn off the output.
Off string `json:"Off,omitempty"`
// On tells niri to turn on the output.
On string `json:"On,omitempty"`
// Mode tells niri which output mode to set.
Mode struct {
// Mode is the mode to set, or "auto" for automatic selection.
//
// Run niri msg outputs to see the available modes.
Mode ModeToSet `json:"mode"`
} `json:"Mode"`
// Scale tells niri which output scale to set.
Scale struct {
// Scale is the scale factor to set, or "auto" for automatic selection.
Scale ScaleToSet `json:"scale"`
} `json:"Scale"`
// Transform tells niri which output transform to set.
Transform struct {
// Transform is the transform to set, counter-clockwise.
Transform Transform `json:"transform"`
} `json:"Transform"`
// Position tells niri which output position to set.
Position struct {
// Position is the position to set, or "auto" for automatic selection.
Position PositionToSet `json:"position"`
} `json:"Position"`
// Vrr tells niri which variable refresh rate to set.
Vrr struct {
// Vrr is the variable refresh rate mode to set.
Vrr VrrToSet `json:"vrr"`
} `json:"Vrr"`
}
OutputAction is the output actions that niri can perform.
type OutputConfigChanged ¶
type OutputConfigChanged struct {
// Applied tells if the target output was connected and the change was applied.
Applied string `json:"Applied"`
// OutputWasMissing tells if the target output was not found, the change will be applied when it's connected.
OutputWasMissing string `json:"OutputWasMissing"`
}
OutputConfigChanged is the output configuration change result.
type OutputSlice ¶ added in v0.7.0
type OutputSlice struct {
Outputs []*Output
}
OutputSlice is a wrapper for outputs.
func (OutputSlice) First ¶ added in v0.7.0
func (o OutputSlice) First() (*Output, error)
First returns the first output in the output slice.
type Overview ¶
type Overview struct {
// IsOpen tells whether the overview is currently open or not.
IsOpen bool `json:"is_open"`
}
Overview is the overview information.
type PickedColor ¶
type PickedColor struct {
// RGB is the color values as red, green, blue, each ranging from 0.0 to 1.0.
RGB float64 `json:"rgb"`
}
PickedColor is the color picked from the screen.
type PositionToSet ¶
type PositionToSet struct {
// Automatic tells niri to position the output automatically.
Automatic string `json:"Automatic,omitempty"`
// Specific tells niri to use a specific position.
Specific ConfiguredPosition `json:"Specific,omitempty"`
}
PositionToSet is the output position to set.
type PossibleKeys ¶ added in v0.2.0
type PossibleKeys struct {
ID uint64
WindowID uint64
ActiveWindowID uint64
WorkspaceID uint64
Index uint8
Reference ReferenceKeys
}
PossibleKeys contains the possible keys an action could have.
This is used when setting the action IDs dynamically during matching of windows.
type ReferenceKeys ¶ added in v0.2.0
ReferenceKeys contains the possible keys a WorkspaceReferenceArg can have.
This is used when setting the reference dynamically on matching workspaces.
type Response ¶
type Response struct {
Ok map[string]json.RawMessage `json:"Ok"`
}
Response contains the response from the Niri Socket.
type Rule ¶
type Rule struct {
// Type is the type of object we want to match, e.g. window or workspace. Defaults to window.
Type string `json:"type"`
// Match list of matches to target a window.
Match []Match `json:"match,omitempty"`
// Exclude list of matches to target a window, to be excluded from the match.
Exclude []Match `json:"exclude,omitempty"`
// Actions defines the action to do on the matching window.
//
// This is a json.RawMessage on purpose, since we need to
// dynamically create the action struct.
Actions map[string]ActionConfig `json:"actions,omitempty"`
}
Rule contains the matches, excludes and actions for a window.
func (Rule) WindowMatches ¶ added in v0.2.0
WindowMatches checks if the window matches the given rule.
func (*Rule) WorkspaceMatches ¶ added in v0.2.0
WorkspaceMatches checks if the workspace matches the given rule.
type ScaleToSet ¶
type ScaleToSet struct {
// Automatic tells niri to pick the scale automatically.
Automatic string `json:"Automatic,omitempty"`
// Specific tells niri to set a specific scale.
Specific float64 `json:"Specific,omitempty"`
}
ScaleToSet is the output scale to set.
type SpawnOrFocus ¶ added in v0.3.0
type SpawnOrFocus struct {
Rules []Rule `json:"rules,omitempty"`
// Command is the command to spawn for the spawnOrFocus command.
Commands map[string][]string `json:"commands,omitempty"`
}
SpawnOrFocus defines the rules and commands to run for the spawn-or-focus command.
type Transform ¶
type Transform struct {
// Normal is untransformed.
Normal string `json:"Normal,omitempty"`
// Rotate90 is rotated by 90 deg.
Rotate90 string `json:"_90,omitempty"`
// Rotate180 is rotated by 180 deg.
Rotate180 string `json:"_180,omitempty"`
// Rotate270 is rotated by 270 deg.
Rotate270 string `json:"_270,omitempty"`
// Flipped is flipped horizontally.
Flipped string `json:"Flipped,omitempty"`
// Flipped90 is rotated by 90 deg and flipped horizontally.
Flipped90 string `json:"Flipped90,omitempty"`
// Flipped180 is flipped vertically.
Flipped180 string `json:"Flipped180,omitempty"`
// Flipped270 is rotated by 270 deg and flipped horizontally.
Flipped270 string `json:"Flipped270,omitempty"`
}
Transform is the output transformation, which goes counter-clockwise.
type VrrToSet ¶
type VrrToSet struct {
// Vrr tells whether to enable variable refresh rate or not.
Vrr bool `json:"vrr"`
// OnDemand tells to only enable when the output shows a window matching the variable-refresh-rate window rule.
OnDemand bool `json:"on_demand"`
}
VrrToSet is the output variable refresh rate to set.
type Window ¶
type Window struct {
// ID is the unique ID of this window.
//
// This ID remains constant while this window is open.
//
// Do not assume that window IDs will always increase without wrapping, or start at 1.
// That is an implementation detail subject to change. For example, IDs may change to be
// randomly generated for each new window.
ID uint64 `json:"id"`
// Title is the window title, if set.
Title string `json:"title"`
// AppID is the application ID, if set.
AppID string `json:"app_id"`
// Pid is the process ID that created the Wayland connection for this window, if known.
//
// Currently, windows created by xdg-desktop-portal-gnome will have a None PID, but this
// may change in the future.
Pid int `json:"pid"`
// WorkspaceID is the ID of the workspace this window is on, if any.
WorkspaceID uint64 `json:"workspace_id"`
// IsFocused tell whether this window is currently focused.
//
// There can either be one focused window, or zero (e.g. when a layer-shell surface has focus).
IsFocused bool `json:"is_focused"`
// IsFloating tells whether this window is currently floating.
//
// If the window isn't floating, then it's in the tiling layout.
IsFloating bool `json:"is_floating"`
// IsUrgent tells whether this window requests your attention.
IsUrgent bool `json:"is_urgent"`
// Layout shows position- and size-related properties of the window.
Layout WindowLayout `json:"layout"`
// Matched tells if the window matches a rule defined by nirimgr rules.
//
// This is not a part of the Niri Window model.
Matched bool
}
Window contains the details of a window.
type WindowLayout ¶ added in v0.7.0
type WindowLayout struct {
// PosInScrollingLayout is the location of a tiled window within a workspace:
// (column index, tile index in column).
//
// The indices are 1-based, i.e. the leftmost column is at index 1 and the topmost tile in a column is at index 1.
// This is consistent with Action::FocusColumn and Action::FocusWindowInColumn.
PosInScrollingLayout []uint `json:"pos_in_scrolling_layout,omitempty"`
// TileSize is the size of the tile this window is in, including decorations like borders.
TileSize []float64 `json:"tile_size"`
// WindowSize is the size of the window's visual geometry itself.
//
// Does not include niri decorations like borders.
// Currently, Wayland top-level windows can only be integer-sized in logical pixels,
// even though it doesn't necessarily align to physical pixels.
WindowSize []int32 `json:"window_size"`
// TilePosInWorkspaceView is the tile position within the current view of the workspace.
//
// This is the same "workspace view" as in gradients' relative-to in the niri config.
TilePosInWorkspaceView []float64 `json:"tile_pos_in_workspace_view,omitempty"`
// WindowOffsetInTile is the location of the window's visual geometry within its tile.
//
// This includes things like border sizes. For full-screened fixed-size windows this includes
// the distance from the corner of the black backdrop to the corner of the (centered) window contents.
WindowOffsetInTile []float64 `json:"window_offset_in_tile"`
}
WindowLayout shows the position- and size-related properties of a Window.
type WindowSlice ¶ added in v0.7.0
type WindowSlice struct {
Windows []*Window
}
WindowSlice is a wrapper for windows.
func (WindowSlice) First ¶ added in v0.7.0
func (ws WindowSlice) First() (*Window, error)
First returns the first window in the window slice.
type Workspace ¶
type Workspace struct {
// ID is the unique ID of this workspace.
//
// This id remains constant regardless of the workspace moving around and across monitors.
// Do not assume that workspace IDs will always increase without wrapping, or start at 1.
// That is an implementation detail subject to change.
// For example, IDs may change to be randomly generated for each new workspace.
ID uint64 `json:"id"`
// Idx is the index of the workspace on this monitor.
//
// This is the same index you can use for requests like niri msg action focus-workspace.
// This index will change as you move and re-order workspace. It is merely the workspace's
// current position on its monitor. Workspaces on different monitors can have the same index.
// If you need a unique workspace id that doesn’t change, see Id.
Idx uint8 `json:"idx"`
// Name is the optional name of the workspace.
Name string `json:"name"`
// Output is the name of the output that the workspace is on.
//
// Can be None if no outputs are currently connected.
Output string `json:"output"`
// IsUrgent tells whether the workspace currently has an urgent window in its output.
IsUrgent bool `json:"is_urgent"`
// IsActive tells whether the workspace is currently active on its output.
//
// Every output has one active workspace, the one that is currently visible on that output.
IsActive bool `json:"is_active"`
// IsFocused tells whether the workspace is currently focused.
//
// There's only one focused workspace across all outputs.
IsFocused bool `json:"is_focused"`
// ActiveWindowID is the ID of the active window on this workspace, if any.
ActiveWindowID uint64 `json:"active_window_id"`
// Matched tells if the workspace matches a rule defined by nirimgr rules.
//
// This is not a part of the Niri Workspace model.
Matched bool
}
Workspace is the workspace.
type WorkspaceSlice ¶ added in v0.7.0
type WorkspaceSlice struct {
Workspaces []*Workspace
}
WorkspaceSlice is a wrapper for workspaces.
func (WorkspaceSlice) First ¶ added in v0.7.0
func (ws WorkspaceSlice) First() (*Workspace, error)
First returns the first workspace in the workspace slice.