Skip to content

Never Forget to Hydrate Again: A Minimalist Shell Script with Rofi + systemd

Barinderpreet Singh

Let’s cut the crap and get straight to what really matters: reminding yourself to drink water without annoying pop-ups or battery-killing apps.

Why?

Because if you’re like me, juggling code and caffeine, it’s way too easy to forget the simplest but most important habit: hydration. So here’s a tiny shell script that uses Rofi - yes, the ultimate app launcher turned popup wizard - as a front-end prompt to remind you to hydrate.

The Super Simple Script: hydrate.sh

Drop this bad boy anywhere you like. I stash mine in ~/.config/rofi/applets/bin because I roll with Aditya Shakya’s fabulous Rofi templates.


#!/bin/bash

if [ -z "$DISPLAY" ]; then
    echo "No DISPLAY found. Exiting."
    exit 0
fi

yes='Done'
no='Later'
# You can also use nerd fonts to make these prettier:  

selected=$(
    echo -e "$no\n$yes" | rofi -theme-str 'window {location: center; anchor: center; fullscreen: false; width: 350px;}' \
        -theme-str 'mainbox {orientation: vertical; children: [ "message", "listview" ];}' \
        -theme-str 'listview {columns: 2; lines: 1;}' \
        -theme-str 'element-text {horizontal-align: 0.5;}' \
        -theme-str 'textbox {horizontal-align: 0.5;}' \
        -dmenu \
        -p 'Confirmation' \
        -mesg 'Time to drink some water' \
        -theme $HOME/.config/rofi/applets/type-1/style-2.rasi
)

if [[ $selected == $yes ]]; then
    echo "Done"
else
    echo "Later"
    sleep 300
    exec $0
fihydrate.sh

Make it executable with chmod +x hydrate.sh and you’re golden.

Making It Automatic: systemd To The Rescue


[Unit]
Description=Remind the user to drink water

[Service]
Type=oneshot
ExecStart=/home/barinr/.config/rofi/applets/bin/hydrate.sh~/.config/systemd/user/hydrate.service

[Unit]
Description=Hourly reminder to drink water

[Timer]
OnCalendar=hourly
Persistent=true

[Install]
WantedBy=timers.target~/.config/systemd/user/hydrate.timer

Put both in ~/.config/systemd/user/, then:

A Couple of Pro-Tips

What’s the takeaway?

Just a few lines of bash, a bit of Rofi magic, and systemd’s timer power make keeping hydrated way more fun and less annoying. If you’re tired of dry mouths and forgetful days, give this a shot. Your body (and your code) will thank you.

Cheers! 💧

Next Post
Stop Playing Git Repository Hide-and-Seek: A 5-Minute Script That'll Save Your Sanity