Inter-process-messaging ======================= Polybar supports controlling parts of the bar and its modules from the outside through inter-process-messaging (IPC). IPC is disabled by default and can be enabled by setting ``enable-ipc = true`` in the bar section. By default polybar ships with the ``polybar-msg`` tool that is needed to send messages to polybar. .. note:: Starting with version 3.6.0, the underlying IPC mechanism has been completely changed. Writing directly to the named pipe to send IPC messages has been deprecated, ``polybar-msg`` should be used exclusively Everything you could do by directly writing to the named pipe, you can also do using ``polybar-msg``. In addition, hook messages are also deprecated; they are replaced by actions on the :ref:`ipc module `. Unless noted otherwise, everything in this guide is still valid for older versions. Sending Messages ---------------- ``polybar-msg`` can be called on the commandline like this: .. code-block:: shell polybar-msg [-p ] If the ``-p`` argument is specified, the message is only sent to the running polybar instance with the given process ID. Otherwise, the message is sent to all running polybar processes that have IPC enabled. .. note:: IPC messages are only sent to polybar instances running under the same user as ``polybar-msg`` is running as. The ```` argument is either :ref:`action ` or :ref:`cmd `. The allowed values for ```` depend on the type. Message Types ------------- .. _ipc-commands: Commands ^^^^^^^^ Using ``cmd`` for ````, you can control certain aspects of the bar. Available values for ```` are: * ``quit``: Terminates the bar * ``restart``: Restarts the bar in-place * ``hide``: Hides the bar * ``show``: Makes the bar visible again, if it was hidden * ``toggle``: Toggles between the hidden and visible state. .. _ipc-actions: Module Actions ^^^^^^^^^^^^^^ For the ```` ``action``, ``polybar-msg`` can execute :doc:`module actions ` in the bar. An action consists of the name of the target module, the name of the action and an optional data string: :: #.[.] More information about action strings and available actions can be found in :doc:`actions` For example, if you have a date module named ``date``, you can toggle between the regular and alternative label with: .. code-block:: shell polybar-msg action "#date.toggle" As an example for an action with data, say you have a menu module named ``powermenu``, you can open the menu level 0 using: .. code-block:: shell polybar-msg action "#powermenu.open.0" .. note:: For convenience, ``polybar-msg`` also allows you to pass the module name, action name, and data as separate arguments: .. code-block:: shell polybar-msg action date toggle polybar-msg action powermenu open 0 .. versionadded:: 3.6.0