The Problem
Many desktop widgets display time, but few give a visually rich, split‑zone clock that shows both a primary time zone with seconds and a secondary zone for quick reference. Users who need an always‑on‑screen IST clock with a compact Pacific‑time inset lack a lightweight, open‑source option that runs on Linux without a heavyweight UI framework.
What This Does
The repository builds a single binary flipclock that renders a flip‑style clock using raylib. The main display shows Indian Standard Time (IST) with seconds and the date; a smaller inset shows Pacific Time (PT).
main.ccontains the application logic, including time fetching (localtime_r), texture generation for digit faces, and the flip animation.Makefiledrives compilation, locating raylib viapkg-config, a vendored copy in./vendor, or a system header. It also defines theFLIP_SECONDScompile‑time knob controlling animation speed.README.mddocuments the build/run workflow and the rendering approach, whileLICENSEandscreenshot.pngare ancillary.
How It Is Wired
Entry point – execution starts in main.c at int main(void).
- Initialization – Calls
InitWindow,SetTargetFPS, andSetExitKey(overridden to disable Escape). It then loads fonts viaLoadFontfrom a hard‑coded priority list (DejaVu,Liberation,Noto,Inter). - Time preparation – Each frame,
clock_gettime(CLOCK_MONOTONIC, …)supplies a high‑resolution timestamp. The code computes the anchor second usinglocaltime_rafter temporarily adjustingTZto the target zone (IST or PT). This isolates DST handling to the OS. - Texture baking –
RenderTexture2Dobjects are created for each digit at 2× resolution, filtered down to the display size. The bake occurs on window resize and is debounced to avoid thrashing. - Flip animation –
UpdateFlipcalculates the current animation phase as a fraction ofFLIP_SECONDS. The quad representing the flipping card is rotated about its hinge edge; the visible height is scaled bycos(angle)to simulate foreshortening. No easing is applied, keeping the motion linear. - Render loop –
BeginDrawing→ draw background → draw pre‑baked digit textures → draw active flip quads →EndDrawing. The loop runs until the window is closed. - Shutdown –
CloseWindowreleases all raylib resources.
All I/O is confined to the local display; there are no network, filesystem, or database interactions. The sole external dependency is the raylib library, resolved at build time via the Makefile logic.
How To Use It
# Clone the repo
git clone https://github.com/moses-y/flip-clock
cd flip-clock
# Build (uses system raylib if available, otherwise vendor)
make
# Optional: build with vendored raylib (stand‑alone binary)
make vendor
# Run the clock
./flipclock
Toggle fullscreen with F11 or F. To restore the default Escape‑to‑quit behavior, edit main.c and set SetExitKey(KEY_ESCAPE). Adjust animation speed, e.g.:
make CFLAGS="-O2 -DFLIP_SECONDS=0.6f"
No configuration files or environment variables are required beyond an installed raylib runtime.
Real‑World Use
A network operations center could launch ./flipclock on a dedicated monitor to show IST (the primary shift for many Asian teams) while keeping PT visible for West‑coast collaborators. The binary’s small footprint (≈ 5 MB) and lack of window manager dependencies make it suitable for lightweight X11 or Wayland sessions.
Code Health & Issues
- Medium – Untested code paths – repository root – No test suite (
*_test.cor similar) is present, so functional regressions are not automatically caught. - Medium – Missing CI/CD – repository root – No
.github/workflows,Makefiletargets, or other CI configuration; builds are manual. - Low – License file present but unspecified –
LICENSE– The file exists but the SPDX identifier is not shown in the repository metadata; verify compatibility with downstream use.
Static analysis did not reveal compilation warnings with the default make command on a recent GCC/Clang toolchain.
The Bottom Line
flip-clock delivers a tidy, self‑contained flip‑style clock with dual‑zone display and a clear build process. It is well‑structured for a single‑binary C project but lacks automated testing and CI, which raises maintenance risk for any future extensions. Suitable for developers needing a quick visual time widget on Linux; less appropriate for production environments that require verified stability pipelines.