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

@ -35,6 +35,7 @@ state INITIAL:
'nop' -> NOP
'scratchpad' -> SCRATCHPAD
'mode' -> MODE
'bar' -> BAR
state CRITERIA:
ctype = 'class' -> CRITERION
@ -319,3 +320,24 @@ state NOP:
state SCRATCHPAD:
'show'
-> call cmd_scratchpad_show()
# bar (hidden_state hide|show|toggle)|(mode dock|hide|invisible|toggle) [<bar_id>]
state BAR:
bar_type = 'hidden_state'
-> BAR_HIDDEN_STATE
bar_type = 'mode'
-> BAR_MODE
state BAR_HIDDEN_STATE:
bar_value = 'hide', 'show', 'toggle'
-> BAR_W_ID
state BAR_MODE:
bar_value = 'dock', 'hide', 'invisible', 'toggle'
-> BAR_W_ID
state BAR_W_ID:
bar_id = word
->
end
-> call cmd_bar($bar_type, $bar_value, $bar_id)

View File

@ -349,6 +349,8 @@ state BAR:
'status_command' -> BAR_STATUS_COMMAND
'socket_path' -> BAR_SOCKET_PATH
'mode' -> BAR_MODE
'hidden_state' -> BAR_HIDDEN_STATE
'id' -> BAR_ID
'modifier' -> BAR_MODIFIER
'position' -> BAR_POSITION
'output' -> BAR_OUTPUT
@ -378,9 +380,17 @@ state BAR_SOCKET_PATH:
-> call cfg_bar_socket_path($path); BAR
state BAR_MODE:
mode = 'dock', 'hide'
mode = 'dock', 'hide', 'invisible'
-> call cfg_bar_mode($mode); BAR
state BAR_HIDDEN_STATE:
hidden_state = 'hide', 'show'
-> call cfg_bar_hidden_state($hidden_state); BAR
state BAR_ID:
bar_id = word
-> call cfg_bar_id($bar_id); BAR
state BAR_MODIFIER:
modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift'
-> call cfg_bar_modifier($modifier); BAR