Quickshell


IpcHandler: QtObject

import Quickshell.Io

Each IpcHandler is registered into a per-instance map by its unique Go to target. Functions defined on the IpcHandler can be called by qs msg.

Handler Functions

IPC handler functions can be called by qs msg as long as they have at most 10 arguments, and all argument types along with the return type are listed below.

Argument and return types must be explicitly specified or they will not be registered.

Arguments
  • string will be passed to the parameter as is.
  • int will only accept parameters that can be parsed as an integer.
  • bool will only accept parameters that are “true”, “false”, or an integer, where 0 will be converted to false, and anything else to true.
  • real will only accept parameters that can be parsed as a number with or without a decimal.
  • color will accept named colors or hex strings (RGB, RRGGBB, AARRGGBB) with an optional # prefix.
Return Type
  • void will return nothing.
  • string will be returned as is.
  • int will be converted to a string and returned.
  • bool will be converted to “true” or “false” and returned.
  • real will be converted to a string and returned.
  • color will be converted to a hex string in the form #AARRGGBB and returned.

Example

The following example creates ipc functions to control and retrieve the appearance of a Rectangle.

FloatingWindow {
  Rectangle {
    id: rect
    anchors.centerIn: parent
    width: 100
    height: 100
    color: "red"
  }

  IpcHandler {
    target: "rect"

    function setColor(color: color): void { rect.color = color; }
    function getColor(): color { return rect.color; }
    function setAngle(angle: real): void { rect.rotation = angle; }
    function getAngle(): real { return rect.rotation; }
    function setRadius(radius: int): void { rect.radius = radius; }
    function getRadius(): int { return rect.radius; }
  }
}

The list of registered targets can be inspected using qs msg -s.

$ qs msg -s
target rect
  function setColor(color: color): void
  function getColor(): color
  function setAngle(angle: real): void
  function getAngle(): real
  function setRadius(radius: int): void
  function getRadius(): int

and then invoked using qs msg.

$ qs msg rect setColor orange
$ qs msg rect setAngle 40.5
$ qs msg rect setRadius 30
$ qs msg rect getColor
#ffffa500
$ qs msg rect getAngle
40.5
$ qs msg rect getRadius
30
  • enabled bool

    If the handler should be able to receive calls. Defaults to true.

  • target string

    The target this handler should be accessible from. Required and must be unique. May be changed at runtime.