i3status-rust icon indicating copy to clipboard operation
i3status-rust copied to clipboard

Assign an action/cmd to a named part of the format with [[block.click]]'s widget key

Open tkapias opened this issue 2 years ago • 2 comments

Since PR #1686, overriding a default action is easy, you just need to write a block.click for the same button.

There were many elements that made me think that you could also override the default action for a specific part or write a new action or cmd for a specific part:

  • Presence of the widget key for [[block.click]] in the blocks doc.
  • @MaxVerevkin explaining his idea for widget_key+named_arguments in 2 merged PR conversations here and here.
  • The fact that default blocks can already specify click actions to some parts.

But, apparently the widget key in [[block.click]] is not implemented or need more documentation, when I use it, the action or cmd are not applied, even on existing parts like prev, play...

I tried with names arguments too (.str(name:'player')) but it makes the configuration fail.

  • Following @MaxVerevkin, this is what i'd like to do for the music block:
[[block]]
block = "music"
format = " $icon{ $combo.str(max_w:25)  󰥠 $player.str(max_w:7, widget:'player') { $volume_icon $volume |} $prev $play.str(widget:'play') $next |} "
volume_step = 3
[[block.click]]
button = "right"
action = "next_player"
widget = "player"
[[block.click]]
button = "left"
cmd = "urxvtc -e sh -c 'vimpc'"
widget = "player"
[[block.click]]
button = "right"
action = "mpc stop"
widget = "play"
[[block.click]]
button = "left"
action = "play_pause"
widget = "play"
[[block.click]]
button = "up"
action = "volume_up"
[[block.click]]
button = "down"
action = "volume_down"
[block.theme_overrides]
idle_bg = "#303549"

tkapias avatar Apr 20 '23 13:04 tkapias

But, apparently the widget key in [[block.click]] is not implemented or need more documentation, when I use it, the action or cmd are not applied, even on existing parts like prev, play...

I tried with names arguments too (.str(name:'player')) but it makes the configuration fail.

Yeah, the name: ... was just an idea and nothing more. It would be convenient to use the placeholder name in widget field of click handler, but I didn't implement it because it would produce even more JSON blocks.

Technically prev, play and other "buttons" do have names, but they are undocumented and should not be relied on.

So yes, the widget key is sort of useless right now.

MaxVerevkin avatar Apr 20 '23 14:04 MaxVerevkin

Minor note: there is issue #1962 for documenting "button" names.

softmoth avatar Dec 19 '23 15:12 softmoth