https://github.com/madprops/blog/blob/main/docs/timers.md Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} madprops / blog Public * Notifications * Fork 3 * Star 62 * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights Permalink main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create blog/docs/timers.md Go to file * Go to file T * Go to line L * * Copy path * Copy permalink This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. @madprops madprops Mods Latest commit fc74a1c May 17, 2023 History 1 contributor Users who have contributed to this file [ ] Timers Actions Time to Think Mouse Wheel Middle Click Multiple Timers Counters Code Other Uses Starting Timers Fixed Width Repo 152 lines (82 sloc) 3.59 KB Raw Blame Edit this file E Open in GitHub Desktop * Open with Desktop * View raw * * View blame Timers Lately I've been using timers daily. By that I mean timeouts, for example 20 minutes: * Start at 20 minutes * Slowly goes down to 0 But it mostly makes sense if I add a visual widget for it. So I built one baked into my wm: [6874747073] This appears on the panel once I start a timer. It will update every second. Eventually it goes into seconds: [6874747073] Then it reaches 0 and disappears. Actions I can map a function as an action for when the timer is done. It can be a simple "Timer Ended" message, or an action like "suspend the computer". Now I don't suspend the computer immediately, I activate a 60 or 90 minute timer. Which gives me time to go back and check something without having to turn the computer on. [6874747073] Time to Think I've been using timers before releasing new versions of software. Before, I would publish pretty much immediately thinking there's nothing more to do. But now I start a timer depending on how confident I am about the changes. The bigger the change the higher the timer. And I won't consider releasing the version until the timer ends. This gives me time to test the application and find flaws or missing things. And it actually happens very often, that I find things to add or polish. Mouse Wheel An interesting feature I added to the timer widget, that I actually use a lot. I can use the mousewheel when hovering the widget to increase or decrease the timer. It increases or decreases by 5 minutes. And it will round to the nearest 5 minute step. For instance: 3 minutes -> 5 minutes -> 10 minutes -> 15 minutes. It allows me to adjust how much I'm willing to wait for something. Depends on my judgment if a timer should increase or decrease. The minimum is 1 minute, it won't go below it with the mousewheel. [6874747073] Middle Click Middle clicking the widget cancels the timer. Multiple Timers Any number of timers can be started. As long as they have a different name: [6874747073] Counters The timer widget/library also supports "counters". These are the opposite. They start at 0 and go upwards. They don't end or run a function, they just keep going until stopped. [6874747073] Code Some code of how I start the timers with my wm: function auto_suspend(minutes) autotimer.start_timer("Suspend", minutes, function() suspend() end) end function timer(minutes) autotimer.start_timer("Timer", minutes, function() msg("Timer ended") end) end function counter() autotimer.start_counter("Counter") end Other Uses It's also useful for measuring non-computer activities. Like waiting for food or drinks to be ready. Starting Timers Since my wm can be called through a special program, I can make a ruby script to start timers. I made a script that makes it easy to detect if I want hours, minutes, or seconds. So I can easily start a 20 minute timer, or a 5 second timer. And I can do it directly from my launcher: [6874747073] Fixed Width Like I usually do with my widgets, I try to keep a non-dynamic width on them. 1.5 hrs, 30 mins, 05 secs, they all occupy the same width. So when changing units there's no movement in the panel. I do this by using the same number of characters with a monospace font. Repo The code for autotimer is here. The ruby script is here. [ ] Go Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. 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.