Customizing a Status Bar in dwm (Weather, Audio, Mail, Battery and more)
Vložit
- čas přidán 11. 09. 2024
- How to get a good dwm status bar. I have one with a daily weather forecast, volume control, mail, battery, music and the current time and date.
dwmbar script: github.com/Luk...
ref(resh)bar script: github.com/Luk...
WEBSITE: lukesmith.xyz 🌐❓🔎
DONATE NOW: lukesmith.xyz/... 💰😎👌💯
Using all your cores to run status bar, sounds a good idea!
while :; do
xsetroot -name "whatever"
sleep 0.0001s
done
My weather app is the f@kin' window. I open it, and I look.
bUt wHaT aBoUt nExT fRiDaY's wEaThEr?
@@coompiler9029 you don’t
Next video: DWM IS BLOAT .. after i've added 42 patches, 23 scripts including a 15s-refreshing-wallpaper-changing-tool
Mine is written in C and checks various and various intervals. I am using the status2d patch which lets you do simple drawing in the bar to draw the batteries at different levels and to make the volume look better.
Can I fork your code?
@@mahmoudagha4060 I am running BSD on a thinkpad which is dramatically different then linux to get the system stats. There is a simple status bar on the suckless page which mine is based on. The status2d patch allows basic drawing with t a simple markup language. I plan on and am slowly making mine fully modularised so it could be used as a base for someone else but right now it's very dependant on BSD syscalls.
@@rednight2476 How does the FreeBSD kernel compare to the Linux kernel? I have heard the source is a good bit cleaner than Linux, but in terms of functionality (especially meaning graphics card drivers for gaming in my case) how do they compare?
@@Jupiter__001_ I use NetBSD - The BSDs are more than just the kernel they are complete system. The documentation and code throughout the system is cleaner than Linux+GNU. Video drivers are weaker than Linux as there is no Proprietary drivers for it and the opensource ones are little bit behind. With the BSDs you can easily browse the source tree, find the tool you are looking for and get readable code. e.g. I modeled my battery level in my statusbar directly off the system supplied command line tool.
@@rednight2476 I see. I suppose that rules out my use case. I am surprised that there is no proprietary video driver support, given that the PS4 for example runs a modified version of FreeBSD.
Thank you for the information about the BSDs being full OSes. I had already heard they were much more cleanly written than GNU-Linux, and that the documentation was more readable (there are many man pages in GNU-Linux that leave a lot to be desired...); I just wanted to hear it first-hand.
I also used system tools to create a battery monitor in my status bar, but I had to use tools bundled with the status bar instead of any inbuilt tool (although the bundled tool scanned a particular system directory to discover what it needed to know).
3:47 Maybe instead of the `pstree grep` you could run sleep in the background,
get its PID via $! and pipe that to a $file,
also add a `wait $!` after the sleep command so that the loop does not continue,
now your script could get the PID out of your $file and you could kill it easily!
Or you can put the while loop and the update in a seperate script and call the update script whenever you wanna update. No need for killing sleep processes
DWM is bloated Luke, you must learn xlib and create your own window manager
To be fair X is kinda bloated, but there is no real alternative.
@@Klblaz I am using the sway wayland compositor as a daily driver and thus far it has been a really smooth experience for me. You might want to try it out.
@@Klblaz X is a mess
It can happen, He moved to place with bad internet...
@MJS Are you guys cavemen? Do you really never do other stuff? It isn't 80s anymore.
I've been using Suckless' slstatus myself ever since I switched over to dwm, and for stuff not really covered in the base program (i.e. GPU stats), I've just made small scripts to do that stuff. It just feels a little cleaner overall to me, as well as being easier to format and modify IMO. Good scripts though!
echo -n to remove trailing newline so you don't need to replace it later.
edit: This solution is not POSIX compliant.
@MJS You're right, I wanted to reply "who the hell cares?" but then I relized that Luke does so what I'll do is edit the original comment with a warning about the non-compliance with posix.
This video helped me in an unexpected way; well, killing sleep after amixer is brillant too, but the thing i'm referring too here, is that i've now learned about and changed to, having all my shell-scripts in '~/.local/bin' instead of as previously in '~/.bin'. Some research let me to find that ' ~/.local/bin' originates from python's PEP370 in 2008 and later by systemd in an extension to xdg-basedir spec, and where '~/.local' dir first was defined under use of' ~/.local/share' in original xdg-basedir spec. Thank you for your nice videos and greetings from Denmark :)
STOP BLOATING DWM!
lol?
ah yes... stop "bloating" dwm with a basic time feature...
STOP BLOATING COMMENT
6:39 That's the cutest thing I've ever seen on the command line
Regarding the echo/NL lag issue: I think echo flushes its buffer when it sees a new line, so by translating them to spaces you make one kernel call instead of many.
I guess a better idea would be to have two different scripts: one script a.sh which calls xsetroot _once_ and exits, and the other script b.sh which runs a.sh every minute. And when updating volume etc just execute a.sh to update the bar. That will make the whole process a bit faster
Honestly, it feels like this should be a per-session daemon that gets poked with a signal whenever it needs to update, instead of a script in a while loop. In fact, have the daemon open a bunch of sockets at a known location based on what should be displayed, and then have cron jobs write to the sockets at regular intervals for some things, and have stuff like volume levels immediately write to the socket. The daemon selects all the sockets and whenever there's something to read, re-renders the status string and sends it to dwm.
Hi, I like your approach. The only exception is that you need to kill sleep. I simply have two scripts: the first one runs the whole loop and calls the second one that assembled the status bar text and does the xsetroot. Doing it this way allows me to call the second script whenever I need to update manually.
Thanks a lot for all your videos.
Hello, I use the same idea, I was curios way he is using the kill approach, it's not necessary. Also lot of people puts just sleep 60 (to wait the update), but this is different from the system time. Too fix it:
sleep $((60 - $(/bin/date +%S | sed 's/^0\([0-9]\)/\1/')))
or more bash way:
sleep $((60 - 10#$(/bin/date +%S)))
omg luke your chad ricing is getting insane
What if you used a pub/sub type thing instead of constantly updating the status bar? It would be pretty cool to have a service running that updates a text file with the stats you need. The service could see if something actually changed and then call xsetroot to update the status bar.
It would be more complex but wouldn't it be lighter than unconditionally drawing to the root window?
Idk maybe I'm talking out of my ass but it would be cool to try.
This is way over my head but I've learned what I don't know and I'll need to focus on learning.
Luke: sees a perfectly fine, functional, and minimal window manager like dwm. "Well, I guess it's time to unleash my inner autism and bloat it up with weather and mail in my status bar"
Not bloat if you have a use for it.
Even the idea of rewriting all your status bar configurations from scratch each time you change your wm gives me frustration. It would be great to make independent repository of sh scripts which would provide status modules and every status bar configuration would be just printing output of these scripts. Also it would be great to build a master script, which would concatenate these outputs into a single line. And you basically just print it in whatever status bar you ever have
I finally got dwmstatus to launch at dwm startup! I just put 'dwmstatus 2>&1 >/dev/null &' into .xprofile in my home directory and changed the permissions of .xprofile to 755 with chmod
Not sure if you are aware of/want this not but by using the following syntax: %-d instead of %d when outputing the current day number with the date command the the first syntax actually removes the zero in the day number if it's less than 10. So in this case the date format would have been "June 7" instead of "June 07".
I was just doing the exact same thing in my own system and got the youtube notification for your video....
What I do is define a bunch of functions in my dwmbar script similar to modules in i3blocks. I call "dwmbar init" on startup to evaluate all of them and output to a file in /tmp, then I can call dwmbar with the function's name as an argument to evaluate that function and sed -i that line in the tmp file. So I can refresh the RSS block by calling "dwmbar rss" without my script calling all the other time consuming functions. Then I use sed magic to transform the tmp file into one line separated by |'s and call xsetroot on it.
this one is better than the new color emoji bar
also, check these out
github.com/joestandring/dwm-bar
github.com/torrinfail/dwmblocks
I would personally just break out the display function from the script to be its own thing. The logic being that you don't have to kill anything, you can just run the display function script when you need an instant refresh. Meanwhile the sleep script will still be ticking down and when it reaches zero it calls that same display script.
I hope that makes sense.
That does sound like a better solution indeed
Hey Luke, it's been awhile since I've seen your vids, did you get the uniboomer cabin? If so, how is it?
Nice video, what camera application are you using?
Rather than killing dwm_bar, I'd make it just a while loop that calls another script ("dwm_bar_update" maybe) that actually does the work of setting the status bar contents. Then in your script that changes the volume, it can call dwm_bar_update to refresh the display. Meanwhile dwm_bar can keep running in the background and you don't need to run pstree or kill anything.
How did you get the ASCII-art-like output from "curl wttr.in"? When I ran that command, I get lots of HTML-markup with the output. Do have any special settings in your .curlrc?
Nvm, I had some User-Agent string in my curlrc for some reason.. When I comment that out, it works the same like for you ;-)
i personally use slstatus, easy to use and written in c
When I was setting up dwm, this was exactly what I did (have a while loop and a redraw function).
But since there were some segments that weren't necessary to update every 10 seconds, which was my timeout, I switched to the following system, inspired in part by i3blocks:
Have variables for separately storing each segments text, and the redraw function only formats them and sets the root window title. Then write an updater function for every segment, that can set the backing variable to whatever it should be. Then trap RTMIN+n signals, so that a signal updates a specific segment and redraws the bar with cached values for the rest.
One thing to look out for is the sleep in the while loop, I couldn't just use sleep, because then the script wouldn't catch the signals before the sleep would finish, so I need to fork the sleep into background with & and wait for its completion with wait $!, then the signals propagate properly. If anyone is interested in code, it's on my GitHub: VojtechStep/configs, .config/scripts/dwm_status.sh
Will you try out cwm or OpenBSD?
Thank you VERY VERY much !! for the larbs video now my i3 is AWESOME you are great
May I ask, what is this `se` you are running to open files?
@Arezu Thanks! I will check it out!
@Arezu Thanks man, that program is sweet. So much faster than even having bookmarks in ranger.
@Arezu fzf is bloat, use fzy instead
Yep, Arezu is right, it uses ` fzf ` , here is what I have on my LARBS ... ` se() { find ~/.local/bin/* ~/.config* -type f | fzf | xargs -r $EDITOR ;} `
P.S. Luke's version uses ` du -a ` and removes the size column through ` awk ` instead of ` find `, but using two commands is too much bloat :D
Nice surrogate activity you've got there.
What font did you have for the emojis?
Finally got the normal xfce4 panel working in dwm, so that I could get rid of a few big patches, like statuscolor and systray, which also collided.... Also I had the feeling that statuscolor had an impact on CPU, at least after manually resolving the collision.
I'm happy now, had the xfce stuff anyway on the machine and my status script got also far too messy.
Thank you, Luke.
This terminal thing is intimidating!
Wouldn't it be more elegant to trap some signal in your dwmbar script and have it update the status bar when the signal is received to achieve the event-driven update?
EDIT: Or at very least you could kill the sleep from within the aforementioned trap, that way the information on the implementation of your update loop does not leak into other scripts.
Опа попался лысый
Да, скоро приедем к нему в Fort White на новоселье
Мое почтение
do you do anything to align with the minute change or will your clock just be 59 seconds off at times?
I bet there is some way to use threading logic to get the desired behavior you'd like. Linux OSes can deal with asynchronous events (well obviously they can)
Bloating dwm part 1
I like these neat little symbols but on my system it replaces them all with a space-like character. Do you have an idea on how to fix that?
does these scripts can run on Arch? When I run these scripts, i received some errors, I think this scripts mostly run on Unix's like BSD's, I stand to be corrected.
Thanks
When I try to put emojis in the dwm status bar, they are extremly tiny :/
I believe Luke is using an installed icon fonts from FontAwesome, or something similar. Just depends on how they render.
Have you tried wmutils? It might worth a shot if you want to make a modular WM.
I seems to have like 2 different PIDs of the sleep process, so that refbar thing doesn't work on my end.
Editing dwmbar and set it to just sleep for 5s quite did the trick for me
This is probably blasphemy, but can you make bar elements execute stuff when clicked? I like that I can use the scrollwheel to change tracks, adjust volume and swhitch workspaces in i3.
4:22 I know, it's like 2 years later, but "pgrep sleep"
Killing sleep is super bad style.
Of course it links the internal implemenation of one script to another,
and also it creates a race condition which may lead to the update not working (ok super rare, but its there)
How do you set your hotkeys? I see you are not using default config.h
I don't understand the blocking weather update loop and kill signal. Can't you just add `&` after your loop to update the weather in the background?
Hey Luke! Have you considered writing a book about tips and tricks for configuring and customizing Linux? I'd buy it!
I feel really stupid for not thinking of refreshing my bar when pressing the volume change keys. I ended up writing a script (python) that listens for events from alsa or pulseaudio, and updates when necessary.
HI! Do you know how to make following container in i3wm like your camera in your dwm?
Luke, what do you use for backup?
Why not "sleep 60" ?
what is the program where he writes se and it shows all files names
the battery wont work if you have more than 10 batteries. then again who does?
your watch's attitude on your wrist is making my autism itch
Could you do a video in how to store secret keys and credentials?
GENIUS!!!
I guess that I will use just the hours beeing updated every hour to be minimalist as never.
You might want to add network internet speed monitor
For checking mail in Maildir directories, you can take a look at github.com/diego-treitos/novomail
It is very versatile, although you would need to know a bit of Jinja2 to get the output you want.
You're github page needs to be refreshed.... just got an error saying the page can't be found.
do you know how to keep keybinding working even keyboard is in totally different language layout. I mean kill client is set to super+q but since q is not available when keyoaboard is set to other language keybinding does not work. I tried to use key code for q 0x0071 but no luck.
Hey how to zoom in and zoomout in st terminal of ur LARBS build
At 1:28 you ran se. What does it do? Is it a custom shell script?
Yes. Search and edit. It's in his terminal fuzzy finder video
echo -n is your friend :p
It's not portable.
ok you got me there! Is this the actual reason you stopped using systemd?
Is dwm easier to configure than i3bar?
no
nope
Hey, i really like your work and videos, but how can i set dwm to recognize the brightness button ? This really bothering me and stopping me from using it.
Hey, have you figured it out yet?
I know it's far too late and I don't have a laptop but, I would recommend, use sxhkd and then increase the brightness.
Edit: I use sxhkd for my volume script and a few other things
Script links are no more available :(
Can i3blocks be made to run in dwm?
No. You can use polybar
Well infact it can be, you can checkout the latest master branch of i3blocks on github and compile it. The dev has added a feature where i3blocks can print to the terminal without the json format that i3 expects. There can be improvements to it though as the terminal output also contains escape sequences that causes the terminal to "redraw" the status line. If you can get rid of the terminal escapes, you can essentially then set the dwm status. I haven't tried it yet though.
check: github.com/vivien/i3blocks/issues/134
emojis in dwm is bloat! just use text
[78°-93°F|53%] | VOL: 95% | NET | UNREAD: 8 | BAT: 80% | 2019 Jun 07 (Fri) 7:47AM
^unbloated version
@MJS showing month name as a text is bloat too because you can use numbers which use 2 symbols instead of 3
curl wttr.in?format=4. You probably already know this, but the format argument will save you from parsing all that data by returning a single line.
where did the files go guys?
My battery module disappeared. Anyone know how to get it back?
Douse anyone know how to make a language selector at status bar like in gnome in dwm or where I can read about it?
What is the best web browser for minimumal WM like I3, Xmonad, DWM, etc..?
Cloud Van Frihan suckless' surf
Luke please add your dwmstatus script to voidrice repo 🥺
big bloat
use slstatus
so a
I got it!
Killing sleep 🤓 - thx
What's shortcut command for increase,decrease font in st?? I forget.
Dl st from Luke's git and look inside config.h in src. Search 'zoom'
vim colorscheme? Looks like less depressing alduin
`echo -n` echoes without newlines.
Echo flags are not posix compilant.
Tork
How is this not bloat?
Customizing bloat in dwm
Always funny when people double-u-tee-tee-arrr-dot-i-ennn Hamburg the curl when every german just reads it as "Wetter in /Hamburg" ("weather in Hamburg"), the way I supposed it was intended.... ;)
I see from his github a new repository (17 days old actually): github.com/LukeSmithxyz/dwmblocks
has he changed his statusbar?
A series of videos that will be really good to see in my opinion is a deep dive into Linux Core utilities and off course the uitl-linux also. I mean who on youtube have take the time to brake down the most basics of Linux tools? right?...
And by deep dive a mean look at the list of util-linux: pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html its a lot of stuff.. that is weeks of powerful meaningful core Linux content plus off course the are lots of things that can get really interesting like awk!.
Anyone Here Know How i can force a window without a class or instance to be set on floating in dwm would really help Thanks
You can set it using title and set isfloating true in your config.h
Does anyone know how to install flashplayer on Void?
Just use windows idiot
Using SIGUSR1 to kill sleep with trap:
#!/bin/sh
while :
do
sleep 20 &
slpid=$!
trap 'kill $slpid' USR1
wait $slpid
trap "" USR1
done