Home

Awesome

polybar-timer

This script implements a simple and customizable timer for your bar.

screenshot set timer (set a timer)

screenshot cancel timer (cancel a timer)

screenshot set predefined timer (start predefined timer)

screenshot set predefined timer 2 and increase it (start other predefined timer and increase it)

screenshot see expiry time (watch expiry time when you change a timer)

Even though the repo is named polybar-timer, it is a general script and you can use it for every bar. In particular, if you use waybar, then you can find a waybar-specific implementation of this timer here. You can customize behaviour and appearance in a simple way.

Use cases: pomodoro timer, self-reminder when next meeting begins, tea/pasta timer, ...

Dependencies

This script works perfectly without any dependencies.

Installation

  1. Download polybar-timer.sh from this repo.
  2. Make it executable. (chmod +x polybar-timer.sh)
  3. Copy-paste the example configuration from below into your polybar config.
  4. Customize. (see Customization section)

Example Configuration

[module/timer]

type = custom/script

exec = /path/to/polybar-timer.sh tail 'TIMER' 5
tail = true

click-left = /path/to/polybar-timer.sh new 25 'Pomo session' 'Paused' 'notify-send "Session finished"' ; /path/to/polybar-timer.sh update %pid%
click-middle = /path/to/polybar-timer.sh cancel ; /path/to/polybar-timer.sh update %pid%
click-right = /path/to/polybar-timer.sh togglepause ; /path/to/polybar-timer.sh update %pid%
scroll-up = /path/to/polybar-timer.sh increase 60 || /path/to/polybar-timer.sh new 1 'TIMER' 'PAUSED' 'notify-send -u critical "Timer expired."' ; /path/to/polybar-timer.sh update %pid%
scroll-down = /path/to/polybar-timer.sh increase -60 ; /path/to/polybar-timer.sh update %pid%

Customization

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.

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.

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.

Documentation

Notation: <...> are necessary arguments. [...=DEFAULTVALUE] are optional arguments, and if you do not specify them their DEFAULTVALUE is used.

If want to understand or edit the script, I highly recommend to run a tail process (see below) in a terminal window without any bar. This way you will see what the bar sees and you will understand how the updates work.

You can call the script with the following arguments:

These were the basic commands to handle the technical side. Now with the following commands you can control the timer. If you want the bar to to update immediately after a change, you should call update right after, for example polybar-timer.sh increase 60 ; polybar-timer.sh update <pid of tail process>'.

Tips & Tricks

Note, when there is no timer active, then increase does nothing. So you might want to use the following command as a replacement for increase.

polybar-timer.sh increase 60 || polybar-timer.sh new 1 'mytimer' 'paused' 'notify-send "Timer expired."'

It increases the existing timer if it's active, and creates a timer with label "mytimer" of lengths 1 minute if there is no timer currently running. So now e.g. scrolling up also does something when there is no timer active - it starts a new timer!

Known Issues

If you don't (want to) use dunstify please see the dependencies section.