introduced i3 command for changing the hidden state and the mode of i3bar

The hidden_state and mode of each i3bar instance can now be controlled from within i3.
Therefore, two new i3 command were introduced:
    _
    bar hidden_state show|hide|toggle [<bar_id>]

    show: always show the bar
    hide: normal hide mode
    toggle: toggle between show and hide (individually for each bar)
    _
    bar mode dock|hide|invisible|toggle [<bar_id>]

    hide,dock: like before
    invisible: always keep the bar hidden
    toggle: toggle between dock and hide (individually for each bar)

This patch introduces a hidden_state ("hidden_state hide|show") in the
barconfig, which indicates the current hidden_state of each i3bar
instance. It only affects the bar when in hide mode. Additionally, a new
invisible mode was introduced. In order to change the hidden_state or
mode of the bar from i3, a barconfig-update event was introduced, for
which a bar can subscribe and the bar then gets notified about the
currently set hidden_state and mode in its barconfig.

For convenience, an id field ("id <bar_id>") was added to the barconfig, where one can
set the desired id for the corresponding bar. If the id is not specified, i3 will
deterministically choose an id; otherwise, with the previous random approach for finding
a new id, which is actually not shared with i3bar, as it would determine its id on
startup, the event-subscription would be destroyed on reload. Still, this issue remains
when manually changing the bar_id in the config and then reloading.

fixes #833, #651
This commit is contained in:
haptix@web.de
2013-05-25 14:30:00 +02:00
committed by Michael Stapelberg
parent f0eba6d15c
commit e3913093b6
18 changed files with 470 additions and 58 deletions

View File

@ -626,6 +626,9 @@ mode (2)::
window (3)::
Sent when a client's window is successfully reparented (that is when i3
has finished fitting it into a container).
barconfig_update (4)::
Sent when the hidden_state or mode field in the barconfig of any bar
instance was updated.
*Example:*
--------------------------------------------------------------------
@ -723,6 +726,24 @@ window title as "urxvt").
}
---------------------------
=== barconfig_update event
This event consists of a single serialized map reporting on options from the
barconfig of the specified bar_id that were updated in i3. The map always
consists of a property +id (string)+, which specifies to which bar instance the
sent config update belongs, a property +hidden_state (string)+, which indicates
the hidden_state of an i3bar instance, and a property +mode (string)+, which
corresponds to the current mode.
*Example:*
---------------------------
{
"id": "bar-0",
"hidden_state": "hide"
"mode": "hide"
}
---------------------------
== See also (existing libraries)
[[libraries]]

View File

@ -996,20 +996,39 @@ bar {
=== Display mode
You can have i3bar either be visible permanently at one edge of the screen
(+dock+ mode) or make it show up when you press your modifier key (+hide+
You can either have i3bar be visible permanently at one edge of the screen
(+dock+ mode) or make it show up when you press your modifier key (+hide+ mode).
It is also possible to force i3bar to always stay hidden (+invisible+
mode). The modifier key can be configured using the +modifier+ option.
The mode option can be changed during runtime through the +bar mode+ command.
On reload the mode will be reverted to its configured value.
The hide mode maximizes screen space that can be used for actual windows. Also,
i3bar sends the +SIGSTOP+ and +SIGCONT+ signals to the statusline process to
save battery power.
The default is dock mode; in hide mode, the default modifier is Mod4 (usually
the windows key).
Invisible mode allows to permanently maximize screen space, as the bar is never
shown. Thus, you can configure i3bar to not disturb you by popping up because
of an urgency hint or because the modifier key is pressed.
In order to control whether i3bar is hidden or shown in hide mode, there exists
the hidden_state option, which has no effect in dock mode or invisible mode. It
indicates the current hidden_state of the bar: (1) The bar acts like in normal
hide mode, it is hidden and is only unhidden in case of urgency hints or by
pressing the modifier key (+hide+ state), or (2) it is drawn on top of the
currently visible workspace (+show+ state).
Like the mode, the hidden_state can also be controlled through i3, this can be
done by using the +bar hidden_state+ command.
The default mode is dock mode; in hide mode, the default modifier is Mod4 (usually
the windows key). The default value for the hidden_state is hide.
*Syntax*:
----------------
mode <dock|hide>
mode <dock|hide|invisible>
hidden_state <hide|show>
modifier <Modifier>
----------------
@ -1017,12 +1036,31 @@ modifier <Modifier>
----------------
bar {
mode hide
hidden_state hide
modifier Mod1
}
----------------
Available modifiers are Mod1-Mod5, Shift, Control (see +xmodmap(1)+).
=== Bar ID
Specifies the bar ID for the configured bar instance. If this option is missing,
the ID is set to 'bar-x', where x corresponds to the position of the embedding
bar block in the config file ('bar-0', 'bar-1', ...).
*Syntax*:
---------------------
id <bar_id>
---------------------
*Example*:
---------------------
bar {
id bar-1
}
---------------------
[[i3bar_position]]
=== Position
@ -1775,6 +1813,38 @@ bindsym $mod+minus scratchpad show
bindsym mod4+s [title="^Sup ::"] scratchpad show
------------------------------------------------
=== i3bar control
There are two options in the configuration of each i3bar instance that can be
changed during runtime by invoking a command through i3. The commands +bar
hidden_state+ and +bar mode+ allow setting the current hidden_state
respectively mode option of each bar. It is also possible to toggle between
hide state and show state as well as between dock mode and hide mode. Each
i3bar instance can be controlled individually by specifying a bar_id, if none
is given, the command is executed for all bar instances.
*Syntax*:
---------------
bar hidden_state hide|show|toggle [<bar_id>]
bar mode dock|hide|invisible|toggle [<bar_id>]
---------------
*Examples*:
------------------------------------------------
# Toggle between hide state and show state
bindsym $mod+m bar hidden_state toggle
# Toggle between dock mode and hide mode
bindsym $mod+n bar mode toggle
# Set the bar instance with id 'bar-1' to switch to hide mode
bindsym $mod+b bar mode hide bar-1
# Set the bar instance with id 'bar-1' to always stay hidden
bindsym $mod+Shift+b bar mode invisible bar-1
------------------------------------------------
[[multi_monitor]]
== Multiple monitors