Creating Countdowns, Timers and Stopwatches In Linux

  Переглядів 23,407

DistroTube

DistroTube

Рік тому

There are many small timer or stopwatch programs available in Linux, but...why not make our own? I will show you many different ways to create your own custom timers using the standard Linux command line utilities. I'll use 'for' loops, 'while' loops, cat, read, time, timeout, and several other standard utilities.
WANT TO SUPPORT THE CHANNEL?
💰 Patreon: / distrotube
💳 Paypal: ukposts.info?even...
🛍️ Amazon: amzn.to/2RotFFi
👕 Teespring: teespring.com/stores/distrotube
DONATE CRYPTO:
💰 Bitcoin: 1Mp6ebz5bNcjNFW7XWHVht36SkiLoxPKoX
🐶 Dogecoin: D5fpRD1JRoBFPDXSBocRTp8W9uKzfwLFAu
📕 LBC: bMfA2c3zmcLxPCpyPcrykLvMhZ7A5mQuhJ
DT ON THE WEB:
🕸️ Website: distrotube.com/
📁 GitLab: gitlab.com/dwt1
🗨️ Mastodon: fosstodon.org/@distrotube
👫 Reddit: / distrotube
📽️ LBRY/Odysee: odysee.com/@DistroTube:2
FREE AND OPEN SOURCE SOFTWARE THAT I USE:
🌐 Brave Browser - brave.com/dis872
📽️ Open Broadcaster Software: obsproject.com/
🎬 Kdenlive: kdenlive.org
🎨 GIMP: www.gimp.org/
🎵 Tenacity: github.com/tenacityteam/tenacity
💻 VirtualBox: www.virtualbox.org/
🗒️ Doom Emacs: github.com/hlissner/doom-emacs
Your support is very much appreciated. Thanks, guys!

КОМЕНТАРІ: 51
@Shywizz
@Shywizz Рік тому
I have been watching your videos for a few days after switching to arch and i must say i love how you present things and keep bloopers in the videos. ~ From a new arch user, thank you very much !
@DistroTube
@DistroTube Рік тому
Awesome, thank you!
@tailsorange2872
@tailsorange2872 Рік тому
@@DistroTube Hey DT - could you do a retro-review of some of the milestone distros (say, Ubuntu 5.10, Debian 5, etc)? That's like turning back the clock
@dodopod
@dodopod Рік тому
At 12:07, I think the first echo should actually be: echo -en "\033[2J\033[;H" That will clear the screen, and then move the cursor back to the top-left.
@fred5459
@fred5459 Рік тому
You can use the "clear" command (in arch package ncurses).
@XexusNH
@XexusNH Рік тому
Love the "showing multiple ways to do something" idea. Had to rewind once or twice after my mind wandered off to think of how would I do the same thing in other environments.
@johnrussell6971
@johnrussell6971 Рік тому
Vim tip: In normal mode, type "ZZ" to achieve the same effect as ":wq". Same thing for "ZQ" and ":q!"
@nick-youtube
@nick-youtube Рік тому
Loved the combination of figlet + lolcat, inspiring simplicity and great result! Researched a bit on the line clearance and got a small function working for clearing the lines - on xterm at least, leaving it here ~~ clear_lines() { local N=$1 for i in {$N..1} do printf "\033[1A" printf "\033[K" done } can be used like: clear_lines "$(echo '1' | figlet -c | wc -l)" in the loop after the echo command
@WR250a
@WR250a Рік тому
clear;for i in $(seq 10); do echo -ne ' ' $i |figlet |lolcat;sleep 1;clear; done;
@nick-youtube
@nick-youtube Рік тому
@@WR250a yes, that works too! The approach above is without clearing (-> scrolling) but reprinting on the same lines
@bradleyeverson697
@bradleyeverson697 Рік тому
Hey DT. I definitely like these videos when you cover command line scripts. Going to try a few of these out.
@sebastianmeisel
@sebastianmeisel Рік тому
Great video. Thank you. Just one thought: Instead of 'time cat' I'd use 'time watch -n1 date' to time an event, as it gives me an output.
@muxtonungulate9423
@muxtonungulate9423 Рік тому
I like it when a timer is integrated into the shell prompt. So every time the prompt reappears, it says how long - e.g. "took 7s" - the previous command ran for.
@darioshub
@darioshub Рік тому
Your channel is highly educative. J like the way you explain things. Excellent content!
@vaisakhkm783
@vaisakhkm783 Рік тому
Hey DT,Can to you make a video on how to manage audio in linux... like how to make sound better, pulse audio or pipewire ?, how to transition to pipewire (in arch based/debian based), how to get advnced audio facilites like managing individual apps and devices like in KDE... but for twm or getting equaliser, etc
@gamewarrior010
@gamewarrior010 Рік тому
This would be super useful!
@lightprogrammer
@lightprogrammer Рік тому
back to basics, I like it
@someonestolemyname
@someonestolemyname Рік тому
The GNU coreutils do have a neat set of tools for timing stuff, I tried writing a script that will do something at a specific time, receiving an argument with arbitrary time format. It is quite trivial to do it with 'date -d' with GNU coreutils but would be much more difficult POSIXly without installing external tools. Mainly for the time parsing part. Not to say it is perfect, because I often need to use ISO week dates and it doesn't support that. On your attempt with figlet, you can probably make it normal by reading the output to a variable, counting the newlines, and moving the cursor up that amount with an escape sequence. Not sure if it will be so slow as to throwing off the time, but it should work.
@Blazestar2000
@Blazestar2000 Рік тому
I was literally just thinking about researching how to make some terminal timers similar to these! So, thanks DT! I suffer from serious "time blindness" sometimes when I'm on my PC late at night. The hours fly by even when I'm not distracted. So as silly as it may seem, I'm definitely going to be using that speaker-test command! Cuz it's probably gonna take something like an amber alert to get me to stop aimlessly browsing lol! Much appreciated! Love these kinds of videos!
@mellowgeekstudio
@mellowgeekstudio Рік тому
With aplay instead of speaker-test we can specify the duration of the sound, among other fun stuff
@DDBAA24
@DDBAA24 Рік тому
I like tty-clock. I use it daily.
@Miguel_GM
@Miguel_GM Рік тому
Interesting, thanks!
@HelmutFischer-thehefi
@HelmutFischer-thehefi Рік тому
Nice one 👍
Рік тому
great as usual!
@send2gl
@send2gl Рік тому
fascinating
@waynestewart1919
@waynestewart1919 Рік тому
I tried using the echo command to copy this command into a bash script (before finishing the video). What I didn't realize is that shell expansion would occur, and my $N variable expanded to the last value decremented in the while loop. When I ran the script, it kept repeating 75 in colored ASCII art plus the broken shell code for clear screen as a string.
@killistan
@killistan Рік тому
hey DT, have you messed around with tput at all? `tput cuu 8' before that figlet command should make the timer display stay in the same place, even if you have other stuff on the screen above it. (I might have miscounted the 8, though; that's just the number of lines to move the cursor up by).
@Kwales66
@Kwales66 Рік тому
Hi DT - I use Timer built in to mate
@eliinthewolverinestate6729
@eliinthewolverinestate6729 Рік тому
Hey DT I would like to change to this on debian sudo echo "7" > /sys/class/drm/card0/device/pp_sclk_o ,but gpu is in use. How do I make such a change. Do I need a script on start up? Or is there a way to shutdown gpu and implement the changes to gpu and ram while at it. Trying to get a little more out of a320 with 3200g. Looking at cheap ddr4 3600mhz and watching processor prices come down. Looking at an am5 motherboard next year sometime. Mostly kids play steam and retro game on it. And video editing.
@NebulaM57
@NebulaM57 4 місяці тому
Hello. As usual, another great video! Can I ask what the items are in the upper left of your screen? They're labeled dev www sys doc vbox... etc I am new to the window managers like dwm. I learned last night what all the items are on the right side of the bar. But I'm having trouble finding info about the stuff on the left. I have downloaded a few iso's of ArcoLinux and so far I'm enjoying working with it. I've tried playing with chadwm and xmonad arco iso's but can't see what the stuff on the left of the bar does. What's it called and where could I find a video or something of it being used. All I find are people talking about configurations. I can't seem to find anyone USING the bar. Any info would be great! Thank you and thank you for sharing!
@Adiusza
@Adiusza Рік тому
Very educational :D
@capta1nt0ad
@capta1nt0ad Рік тому
Hey DT! Do you have a smartphone, and if so, what model and OS? Keep up the great work.
@edbeckerich3737
@edbeckerich3737 Рік тому
We used to have melt and push back in the day on Sun and HP Unix boxes. Melt would make the screen melt. We used to rlogin to other people's computers and melt and push their displays.. Anything like that in Linux?
@ericxu5055
@ericxu5055 Рік тому
when you go with |for i in $(seq 15 -1 1); do echo -ne " $i"; sleep 1; done|, countdown number below 10 will turn to 90.80.70....etc, how to fix it?
@ignacioxxi
@ignacioxxi Рік тому
Very cool. It is possible to be done on windows?
@Chris-ip8uv
@Chris-ip8uv Рік тому
When I saw "Timers", I though, man - a video on using systemd timers to replace cron jobs. Alas, I was wrong... Perhaps something you might look into?
@Brock-Landers
@Brock-Landers Рік тому
echo -ne '\ec' to clear the termimal AND it's scrollback buffer. so... do echo -ne '\ec'; echo $N
@cani.j
@cani.j Рік тому
Damn, I have to switch to Linux asap.
@StopTheNewWorldOrder322
@StopTheNewWorldOrder322 Рік тому
How would you create persistence across restarts?
@N0zer0
@N0zer0 Рік тому
persistence of what exactly?
@StopTheNewWorldOrder322
@StopTheNewWorldOrder322 Рік тому
@@N0zer0 If you have a timer running and restart, the timer does not persist. This would be especially useful for long timers. I have seen some discussion about setting up a cron job to make it persist across restarts but have never seen it implemented in any code examples. Basically, how do you get Windows-like timer functionality in Linux?
@pDaleC
@pDaleC Рік тому
Still using Vim!
@alexs5102
@alexs5102 Рік тому
2nd 😄
@SB-qm5wg
@SB-qm5wg Рік тому
I use "at"
@user-xq4ft8kz9f
@user-xq4ft8kz9f Рік тому
12:35 This work for me ;) cdown () { tput sc # Save the cursor position for ((i=$1; i>0; i--)); do echo $i | figlet -c | lolcat && sleep 1 tput rc # Restore the cursor position tput ed # Clear to end of screen done }
@itis5931
@itis5931 Рік тому
Women, Life, Freedom #برای_آزادی
@anon_y_mousse
@anon_y_mousse Рік тому
You might also mention doing loops with {} in bash. for i in {10..0}; do echo $i; done
@silviuxgaming
@silviuxgaming Рік тому
on this comand ------ N=100; while [[ $((--N)) > 0 ]]; do echo -e "\033[2J\033[0m"; "$N" | figlet -c && sleep 1 ; done -------- bash: 87: command not found ------ the counting is working with bash: command no found ... great video
@DistroTube
@DistroTube Рік тому
"command not found" means that the program isn't installed. Which program did it tell you couldn't be found? Probably figlet. It's in pretty much every Linux distro's repos. P.S. Go ahead and install 'lolcat' too if it's not already installed. ;)
@DistroTube
@DistroTube Рік тому
Re-reading your comment....I see you're missing the second 'echo'. After the semicolon, 'echo "$N"'.
@silviuxgaming
@silviuxgaming Рік тому
@@DistroTube now working lol. Thanks
Find Your Most Used Terminal Commands (Bash, Fish, Zsh)
9:57
DistroTube
Переглядів 11 тис.
Shell Aliases Every Linux User Needs
29:03
DistroTube
Переглядів 37 тис.
Can You Draw The PERFECT Circle?
00:57
Stokes Twins
Переглядів 45 млн
Піхотинці - про потребу у людях
00:57
Суспільне Новини
Переглядів 1 млн
Essential Linux Commands - Cat, Tac and Tee
21:07
DistroTube
Переглядів 23 тис.
How to execute another program in C (using exec)
14:23
CodeVault
Переглядів 100 тис.
Sending and Handling Signals in C (kill, signal, sigaction)
5:52
Jacob Sorber
Переглядів 177 тис.
Multi database schema changes
1:22
Turso
Переглядів 1,1 тис.
Best ONENOTE ALTERNATIVES for Linux, Windows and MacOS
16:17
The Linux Experiment
Переглядів 96 тис.
7 Essential Command Line Tools (2022)
9:12
Tech Craft
Переглядів 183 тис.
Learn These 3 Commands To Go From Terminal Noob To Power User
19:31
DistroTube
Переглядів 26 тис.
Three Amazingly Useful Linux Commands (cmp, diff, tput)
17:52
DistroTube
Переглядів 14 тис.
18 Commands That Will Change The Way You Use Linux Forever
29:50
Akamai Developer
Переглядів 1,2 млн
How To Use The Shell Commands 'pushd', 'popd' and 'dirs'
13:45
DistroTube
Переглядів 15 тис.
How Neuralink Works 🧠
0:28
Zack D. Films
Переглядів 26 млн
Клавиатура vs геймпад vs руль
0:47
Balance
Переглядів 979 тис.
iPhone 17 Slim - НЕ ОНОВЛЮЙ iPhone в 2024 | Новини Тижня
31:12
Канал Лучкова
Переглядів 35 тис.
Samsung UE40D5520RU перезагружается, замена nand памяти
0:46
Слава 100пудово!
Переглядів 3,9 млн