You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This script implements a **simple** and **customizable** timer for your bar.
4
-
5
-
- specify a command to execute when the timer expires (e.g. notify-send, shell script, ...)
6
-
- interactive:
7
-
* e.g. scroll to increase / decrease timer
8
-
* click to start predefined timers
9
-
* while changing a timer a notification displays when the timer will expire
10
-
* pause timer
3
+
> [!NOTE]
4
+
> This used to be a shell script. Now it is a binary.
5
+
> The CLI arguments have changed only slightly but the underlying architecture is completely different.
6
+
> Therefore, if you switch from the shell script version to the binary, please make sure to **fully adapt the new default config**.
7
+
> In particular you need to remove `interval`, set `exec-on-event` to false, change the actions of your timers to just names (no more actions), and change `increase -60` to `decrease 60`.
8
+
9
+
This script implements a **simple** and **interactive** timer for your bar:
10
+
- e.g. scroll to increase / decrease timer
11
+
- click to start predefined timers
12
+
- while changing a timer a notification displays when the timer will expire
13
+
- pause timer
11
14
12
15
 (set a timer)
13
16
@@ -25,37 +28,30 @@ You can **customize behaviour and appearance in a simple way**.
25
28
26
29
Use cases: pomodoro timer, self-reminder when next meeting begins, tea/pasta timer, ...
27
30
28
-
## Dependencies
29
-
30
-
This script works perfectly **without any dependencies**.
31
-
32
31
## Installation
33
32
34
-
1. Download [waybar-timer.sh](https://raw.githubusercontent.com/jbirnick/waybar-timer/master/waybar-timer.sh) from this repo.
35
-
2. Make it executable. (`chmod +x waybar-timer.sh`)
36
-
3. Copy-paste the [example configuration](#example-configuration) from below into your waybar config and style it.
37
-
4. Customize. (see [Customization section](#customization))
33
+
1.[Download the binary](TODO) from the releases (or build it yourself with cargo) and put it in a directory of your choice (e.g. `~/.scripts/`).
34
+
2. Copy-paste the [example configuration](#example-configuration) from below into your waybar config and style it.
35
+
3. Customize. (see [Customization section](#customization))
The first modification you probably want to make is to replace the `format-icons` by some actually stylish icons.
@@ -72,53 +68,48 @@ Furthermore you can style the module using the `timer` class, for example:
72
68
73
69
## Customization
74
70
75
-
The example configuration implements a 25min "pomodoro session" timer with left click, pausing with right click, canceling with middle click, and a normal timer by just scrolling up from the standby mode.
71
+
The example configuration implements a 25min "pomodoro session" timer with left click, pausing with right click, canceling with middle click, and an unnamed timer by just scrolling up from the standby mode.
76
72
77
-
You can customize the different strings, numbers and actions to your own flavor and needs. To understand what the commands do and to implement some different behaviour see the [documentation](#documentation).
73
+
You can customize the different numbers and names to your own flavor and needs. To understand what the commands do and to implement some different behaviour see the [documentation](#documentation).
78
74
79
-
If you want to do some really specific stuff and add some functionality, just edit the script. It is really simple. Just take your 10 minutes to understand what it does and then customize it.
75
+
If you need a specific functionality feel free to open an issue and maybe we can make it happen.
80
76
81
77
## Documentation
82
78
83
-
Notation: `<...>` are necessary arguments. `[...=DEFAULTVALUE]` are optional arguments,
84
-
and if you do not specify them their `DEFAULTVALUE` is used.
79
+
Notation: `<...>` are necessary arguments and `[...]` are optional arguments.
85
80
86
81
The main command of the script is:
87
82
88
-
-#### `updateandprint`
89
-
This routine will return the current the output (i.e. what you see on the bar) and handle the `ACTION` if the timer expired.
90
-
Namely:
91
-
1. If there is a timer running and its expiry time is <= now, then it executes `ACTION` and kills the timer.
92
-
2. It prints the output info for waybar, in particular the number of remaining minutes.
83
+
-#### `tail`
84
+
This is the command which you want to put in your waybar `exec` field.
85
+
It keeps the state of the timer and regularly outputs it in JSON, so that waybar can render it.
86
+
We will call the process which runs this `tail` routine the *tail process*.
93
87
94
88
Now the following commands allow you to control the timer.
95
89
96
-
-#### `new <MINUTES> [ACTION=""]`
97
-
1. If there is a timer already running this timer gets killed.
98
-
2. Creates a timer of length `MINUTES` minutes and sets its action to `ACTION`. (`ACTION` will be executed once the timer expires.)
90
+
-#### `new <MINUTES> [NAME]`
91
+
Creates a new timer of length `MINUTES` minutes.
99
92
100
93
-#### `increase <SECONDS>`
101
-
If there is no timer set, nothing happens and it exits with 1.
102
-
If there is a timer set, it is extended by `SECONDS` seconds. `SECONDS` can also be negative, in which case it shortens the timer. Then it exits
103
-
with 0.
94
+
Extend the current timer by `SECONDS` seconds.
95
+
96
+
-#### `decrease <SECONDS>`
97
+
Shorten the current timer by `SECONDS` seconds.
104
98
105
99
-#### `togglepause`
106
-
If there is no timer set at all, it exits with 1. If there is a timer running, the timer gets paused and it exits with 0. If there is a timer set which is already paused, the timer gets resumed and it exits with 0.
100
+
Pause the current timer.
107
101
108
102
-#### `cancel`
109
-
If there is a timer running, the timer gets canceled. The `ACTION` will _not_ be
110
-
executed.
103
+
Cancel the current timer.
111
104
112
105
## Tips & Tricks
113
106
114
-
Note, when there is no timer active, then [`increase`](#increase-seconds) does nothing.
115
-
So you might want to use the following command as a replacement for [`increase`](#increase-seconds).
107
+
When there is no timer active, then [`increase`](#increase-seconds) does nothing, i.e. it doesn't change the state of the timer.
108
+
However, you might want it to _start a new timer_.
109
+
You can implement this because `increase` will exit with code 1 when there is no current timer, so you can do:
116
110
```
117
-
waybar-timer.sh increase 60 || waybar-timer.sh new 1 'notify-send "Timer expired."'
111
+
waybar-timer increase 60 || waybar-timer new 1'
118
112
```
119
-
It increases the existing timer if it's active, and creates a new one minute timer if there is no timer currently running.
120
-
So now e.g. scrolling up also does something when there is no timer active - it starts a new timer!
121
-
122
-
## Known Issues
123
-
124
-
If you don't (want to) use `dunstify` please see the [dependencies section](#dependencies).
113
+
Then if there is an existing timer it gets increased, otherwise a new one minute timer is created.
114
+
This is also implemented in the [example configuration](#example-configuration).
115
+
Just try to scroll up when there is no timer running!
0 commit comments