vivien / i3blocks-contrib

Official repository for community contributed blocklets
https://github.com/vivien/i3blocks
Other
1.32k stars 485 forks source link

[Request] A stopwatch and timer #208

Open parthsharma1996 opened 5 years ago

parthsharma1996 commented 5 years ago

Hi, I wanted to have a stopwatch and a countdown timer in my i3bar so that I can track time for various things. After a lot of googling I couldn't really find an i3blocks script that could do that.

The functionality I am looking for is something similar to the stopwatch/timer applet that appears when you google "stopwatch" (which I currently use for my purposes)

  1. Does any such script already exist of which I am not aware?
  2. If not, I would like to request for such a script. I can also try and write my own in python if someone could give me a broad strokes idea on how to do it.

Thanks!

Aster89 commented 5 years ago

I've been thinking about the very same blocklet, with very same hint (Google). The hard part, I think, is that the script should access the blocklet state when you click on it. E.g. when the timer is paused and you click on it to resume/start it, the script should first retrieve the current blocklet state (=text shown), and then start running. And... Oh, I'm just reasoning about it. Take what I've written so far for what it is 🤣

Aster89 commented 5 years ago

Another thought: you want the blocklet to be updated with a high frequency (at least once per second, like the clock, or quicker if you want the decimals), and you don't want it to refresh (at all) when it's paused. But the command is scheduled through the interval property; how would you change that dynamically?

kb100 commented 5 years ago

This is definitely possible if one of you would like to try your hand at it. You will need to use format=json and interval=persist and loop over a read -t statement. Persistent blocks get click info through stdin so that's why you will need to be using read.

Aster89 commented 5 years ago

You will need? Is json a necessary condition to give shape to this idea? I ask this because the only json I can write something sensible about has one more letter in it and comes out of Crystal lake... Oh, BTW, @kb100, could you please give a look at the upgrade to rofi calendar? 😇

kb100 commented 5 years ago

Well, for the block to be fully functional I think you would need json, since normal and pango formatted blocks only receive the block button to stdin and no other information (click location, click modifiers, etc.). I guess a stopwatch could be fully functional with just the button, but I would imagine a timer block or combined timer/stopwatch to need more. If you come up with something nice that doesn't use json that's fine by me!

Aster89 commented 5 years ago

@kb100 , I think I'm finding a way :smiley: