I3status-rust: Feature request: Enhanced on_click, on_right_click, on_scroll etc commands for every block

Created on 18 May 2020  路  12Comments  路  Source: greshake/i3status-rust

It would be very helpful to be able to add custom shell commands to every block. I'm thinking in particular of the music block. I'd love to be able to open the music player on_click, and adjust its volume with scrolling commands.

enhancement

Most helpful comment

Happy to help! I just searched through the docs so hopefully I got everything:

| block | left click | middle click | right click | scroll |
|----------- |------------ |-------------- |------------- |-------- |
| Backlight | X | X | X | brightness |
| Battery | X | X | X | X |
| Bluetooth | X | X | connect | X |
| CPU Utilization | X | X | X | X |
| Custom | command | X | X | X |
| Custom DBus | X | X | X | X |
| Disk Space | X | X | X | X |
| Docker | X | X | X | X |
| Focused Window | X | X | X | X |
| IBus | X | X | X | X |
| Keyboard Layout | X | X | X | X |
| Load | X | X | X | X |
| Maildir | X | X | X | X |
| Memory | switch swap/mem | X | X | X |
| Music | collapsed cmd | X | X | X |
| Net | X | X | X | X |
| NetworkManager | command | X | X | X |
| Notmuch | X | X | X | X |
| Nvidia Gpu | change output | X | X | fan speed |
| Pacman | X | X | X | X |
| Pomodoro | X | X | X | X |
| Sound | X | X | mute | volume |
| Speed Test | X | X | X | X |
| Taskwarrior | update number | X | toggle filter| X |
| Temperature | X | X | X | X |
| Time | command | X | X | X |
| Toggle | command | X | X | X |
| Uptime | X | X | X | X |
| Watson | toggle show_time | X | X | X |
| Weather | X | X | X | X |
| Xrandr |toggle screens | X | X | brightness |

All 12 comments

If you have the time could you please go through our current blocks list and make a table like the one below? So we can get an overview of the current situation with mapped click actions.

| block | left click | middle click | right click | scroll
| --- | --- | --- | --- | ---
| foo | in use (action: xxx) | free | free | in use (action: xxx) | free

Happy to help! I just searched through the docs so hopefully I got everything:

| block | left click | middle click | right click | scroll |
|----------- |------------ |-------------- |------------- |-------- |
| Backlight | X | X | X | brightness |
| Battery | X | X | X | X |
| Bluetooth | X | X | connect | X |
| CPU Utilization | X | X | X | X |
| Custom | command | X | X | X |
| Custom DBus | X | X | X | X |
| Disk Space | X | X | X | X |
| Docker | X | X | X | X |
| Focused Window | X | X | X | X |
| IBus | X | X | X | X |
| Keyboard Layout | X | X | X | X |
| Load | X | X | X | X |
| Maildir | X | X | X | X |
| Memory | switch swap/mem | X | X | X |
| Music | collapsed cmd | X | X | X |
| Net | X | X | X | X |
| NetworkManager | command | X | X | X |
| Notmuch | X | X | X | X |
| Nvidia Gpu | change output | X | X | fan speed |
| Pacman | X | X | X | X |
| Pomodoro | X | X | X | X |
| Sound | X | X | mute | volume |
| Speed Test | X | X | X | X |
| Taskwarrior | update number | X | toggle filter| X |
| Temperature | X | X | X | X |
| Time | command | X | X | X |
| Toggle | command | X | X | X |
| Uptime | X | X | X | X |
| Watson | toggle show_time | X | X | X |
| Weather | X | X | X | X |
| Xrandr |toggle screens | X | X | brightness |

Cheers!

@eater Do you plan to work on this?

@ammgws No, I hope the table I pulled together was helpful but I am not a coder, just a user.

I've implemented custom actions for the battery block, if the change goes through and I find some more time, I'll start adding them to the other blocks as well.

Without questioning all the work done. it is design problem. Blocks should share properties and have replacable behaviour.

I鈥檒l give this a try if no-one else is already working on it.

Do you have an idea of how you will go about it?

The basic idea will be :

  1. Add default behaviors in Block trait .
trait Block {
   fn on_left_click(&self)  { // do nothing on default }
}
  1. Add a BaseBlock struct in block.rs to provide common share properties such that :
struct BaseBlock<T: Block> { 
   fn on_left_click(&self) {
       if (!self.on_lelf_click.is_none()) {
              self.inner.on_lelf_click() 
              return;
        }
        ...
   }
}

impl Block for BaseBlock {}

  1. Change block macro to create BaseBlock instead.

Do you think it is okay ?

And Seem like we already have an click event , so we don't need to add the default behavior.

And for the serialization part, we could use #[serde(flatten)] to flatten it down.

Sure, please give it a go!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

svenstaro picture svenstaro  路  4Comments

lovesegfault picture lovesegfault  路  7Comments

ammgws picture ammgws  路  6Comments

YodaEmbedding picture YodaEmbedding  路  4Comments

Rikorose picture Rikorose  路  5Comments