x11

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindWindowByTitleStandalone

func FindWindowByTitleStandalone(substring string) (uint32, error)

FindWindowByTitleStandalone searches for a window by title substring using a new temporary X11 connection.

func FocusWindowStandalone

func FocusWindowStandalone(windowID uint32) error

FocusWindowStandalone activates and raises a window using a new temporary X11 connection.

func GetCurrentDesktopStandalone

func GetCurrentDesktopStandalone() (int, error)

GetCurrentDesktopStandalone returns the current virtual desktop number using a new X11 connection. This is useful when you don't have an existing connection available.

func SetWindowDesktopStandalone

func SetWindowDesktopStandalone(windowID uint32, desktop int) error

SetWindowDesktopStandalone moves a window to the specified virtual desktop using a new temporary X11 connection.

Types

type Connection

type Connection struct {
	XUtil *xgbutil.XUtil
	Root  xproto.Window
}

Connection manages the X11 connection and core X resources

func NewConnection

func NewConnection() (*Connection, error)

NewConnection establishes a connection to the X11 server and initializes required extensions

func (*Connection) Close

func (c *Connection) Close()

Close cleanly disconnects from the X11 server

func (*Connection) EventLoop

func (c *Connection) EventLoop()

EventLoop starts the main X11 event loop (blocking)

func (*Connection) FindWindowByTitle

func (c *Connection) FindWindowByTitle(substring string) (uint32, error)

FindWindowByTitle searches the EWMH client list for a window whose _NET_WM_NAME contains the given substring. Returns the first match.

func (*Connection) FocusWindow

func (c *Connection) FocusWindow(windowID uint32) error

FocusWindow activates and raises a window using _NET_ACTIVE_WINDOW. Sends a client message to the root window per EWMH spec. We build the message manually (same as SetWindowDesktop) because the xgbutil ewmh helpers panic on this library version.

func (*Connection) GetActiveMonitor

func (c *Connection) GetActiveMonitor() (*Monitor, error)

GetActiveMonitor returns the monitor containing the currently focused window The returned monitor geometry is adjusted to respect the work area (excluding panels/docks)

func (*Connection) GetActiveWindow

func (c *Connection) GetActiveWindow() (xproto.Window, error)

func (*Connection) GetCurrentDesktop

func (c *Connection) GetCurrentDesktop() (int, error)

GetCurrentDesktop returns the current virtual desktop number (0-indexed). Uses _NET_CURRENT_DESKTOP atom. Returns 0 with an error if detection fails.

func (*Connection) GetDesktopCount

func (c *Connection) GetDesktopCount() (int, error)

GetDesktopCount returns the number of virtual desktops.

func (*Connection) GetFrameExtents

func (c *Connection) GetFrameExtents(windowID xproto.Window) (left, right, top, bottom int, err error)

GetFrameExtents returns the window decoration sizes (if available)

func (*Connection) GetMonitors

func (c *Connection) GetMonitors() ([]Monitor, error)

GetMonitors retrieves all active monitors using XRandR

func (*Connection) GetWindowDesktop

func (c *Connection) GetWindowDesktop(windowID uint32) (int, error)

GetWindowDesktop returns the desktop number a window is on. Uses _NET_WM_DESKTOP atom. Returns -1 for "sticky" windows (visible on all desktops). Returns 0 with an error if detection fails.

func (*Connection) IsNormalWindow

func (c *Connection) IsNormalWindow(windowID xproto.Window) bool

IsNormalWindow checks if a window is a normal application window

func (*Connection) MoveResizeWindow

func (c *Connection) MoveResizeWindow(windowID xproto.Window, x, y, width, height int) error

MoveResizeWindow moves and resizes a window to the specified geometry

func (*Connection) SetWindowDesktop

func (c *Connection) SetWindowDesktop(windowID uint32, desktop int) error

SetWindowDesktop moves a window to the specified virtual desktop. Sends a _NET_WM_DESKTOP client message to the root window per EWMH spec. We build the message manually because the xgbutil ewmh.WmDesktopReq helper panics on this library version (uint vs int type assertion).

type Monitor

type Monitor struct {
	ID     int
	Name   string
	X      int
	Y      int
	Width  int
	Height int
}

Monitor represents a physical display

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL