DWM [SOLVED] How do I patch, install, and start DWM?

Hi, about two months ago I created a thread asking for some help installing DWM to freeBSD 13 in a virtual machine. My main issue at that point was that I didn't have X running properly.
I've come back and finally installed FreeBSD to hardware and I've gotten a bit farther this time. I've downloaded DWM from the suckless website and edited config.mk (thanks to Minbari and a guide by NapoleanWils0n for the info on how to do that), and then ran make clean install. However, There still seems to be something I haven't done correctly because I got a little ahead of myself.
I ran StartX to make sure my x server is actually running, and it launched just fine.
When I try to launch dwm, though, this happens:

$ dwm
dwm: cannot open display

I've tried to sudo and run dwm but I get the same output.
Once X is open and I try to start dwm I get the obvious output:

dwm: another window manager is already running
I believe my issue is somewhere in these final steps Minbari left on my my last post

$ vim config.def.h
$ patch -p1 < dwm-autostart-20210120-cb3f58a.diff
sudo make clean install

I'm a pretty novice user so I don't really understand how to execute these steps.
Once I vim into config.def.h am I supposed to run the patch command somehow? I assume not because I tried to do that and got an error from vim telling me it's not a viable vim command.
What is the purpose of going into config.def.h; what am I supposed to edit once I'm in there? How does the patch command actually work and how am I supposed to use it in this context?

Like I said, I'm really new when it comes to this stuff, but I'm very intrigued by FOSS and I'm I want to learn how to do all these little things.
Thanks in advance for any help here.
 
Why didn't you just install it as a package: x11-wm/dwm/?
I tried to install from a package before and had the same issue (dwm: cannot open display) and was also told by multiple people installing it all manually was the way to go. It's always possible I did that wrong somehow too, though.

Also, trying to install it manually HAS helped me get a bit more familiar with vim.
 
mark_j dwm is supposed to be a DIY package, if one wants to patch dwm, the port will not work here.

joemama Did you tried to add exec dwn (mind the path of your dwm binary) to your .xinitrc and startx?
 
I tried to install from a package before and had the same issue (dwm: cannot open display) and was also told by multiple people installing it all manually was the way to go. It's always possible I did that wrong somehow too, though.

Also, trying to install it manually HAS helped me get a bit more familiar with vim.

Oh ok, then.
So, back to your original question then. I don't know what the editing of config.def.h does. Where are the instructions for doing so?
A quick check on here (https://dwm.suckless.org/patches/autostart/) states what you hope to achieve.
Quote:
This patch will make dwm run "~/.dwm/autostart_blocking.sh" and "~/.dwm/autostart.sh &" before entering the handler loop. One or both of these files can be ommited.
So, change to the source directory where dwm.c is and run the patch as stated in your post above. It patches both dwm.c and dwm.1 (the raw manual page)

Once patched the program looks for these:
static const char autostartblocksh[] = "autostart_blocking.sh";
static const char autostartsh[] = "autostart.sh";

So, I presume you have created one or both (it seems you only really need autostart.sh)?

(I note with irony it comes from suckless.org. They should heed their own advice and fix this, eg suck less, without some obscure patch. Just saying).
 
(I note with irony it comes from suckless.org. They should heed their own advice and fix this, eg suck less, without some obscure patch. Just saying).
I think it's because dwm should get started in the way I said via startx (since it's supposed to be tiny without any extra frills).
 
I've tried to sudo and run dwm but I get the same output.
Once X is open and I try to start dwm I get the obvious output:
Both those outputs suggest you are not fully understanding how X11 works.

The first one is because X11 is not running. The second one is because you have started X11 (and the default TWM) so you can't launch another window manager.

Open up your .xinitrc file and put the following in there:

Code:
xterm

Now when you run startx, you should be greeted with a single white terminal emulator. From here you should be able to run dwm so simply type it into that terminal and press enter. Once this is working. Change that same file to the following:

Code:
xterm &
dwm

Now it should launch xterm and DWM.

Edit: I don't blame you for finding this difficult. The handbook is seriously lacking here: https://docs.freebsd.org/en/books/handbook/x11/#x11-wm
It details desktop environments rather than WMs which is daft because they are niche in comparison (and mostly broken). Possibly this whole section shouldn't be fixed but entirely reverted to about 10 years ago.
 
Ok, but surely the patch is neither bloating it or making it too frilly? ;)
Sort of. It's up to the developer what comes with the default, and they want to be very simple. The patches are extras available, think about something like x11/i3blocks: You don't need it to run x11/i3 or x11/i3-gaps, but it's a nice to have for someone else (myself included :D).
 
Both those outputs suggest you are not fully understanding how X11 works.

The first one is because X11 is not running. The second one is because you have started X11 (and the default TWM) so you can't launch another window manager.

Open up your .xinitrc file and put the following in there:

Code:
xterm

Now when you run startx, you should be greeted with a single white terminal emulator. From here you should be able to run dwm so simply type it into that terminal and press enter. Once this is working. Change that same file to the following:

Code:
xterm &
dwm

Now it should launch xterm and DWM.

Edit: I don't blame you for finding this difficult. The handbook is seriously lacking here: https://docs.freebsd.org/en/books/handbook/x11/#x11-wm
It details desktop environments rather than WMs which is daft because they are niche in comparison (and mostly broken). Possibly this whole section shouldn't be fixed but entirely reverted to about 10 years ago.
Ahh, I missed this comment. Thanks!
 
As I mentioned in your old thread, I have a page that includes installing on FreeBSD at https://srobb.net/dwm.html.
Put any patches in /usr/ports/x11-wm/dwm/files. Get it to use your custom config by installing the port, by changing directory to /usr/ports/x11-wm/dwm and, as will be (too) briefly echoed on the screen, running make DWM_CONF=<path to your custom config.h> install clean. If you use portmaster then it's
portmaster -m 'DWM_CONFIG=<path to your custom config.h>' x11-wm/dwm

If you do this you don't have to worry about editing anything to get rid of Linux specific entries, and your $HOME/.xinitrc can read
exec dwm
 
Both those outputs suggest you are not fully understanding how X11 works.

The first one is because X11 is not running. The second one is because you have started X11 (and the default TWM) so you can't launch another window manager.

Open up your .xinitrc file and put the following in there:

Code:
xterm

Now when you run startx, you should be greeted with a single white terminal emulator. From here you should be able to run dwm so simply type it into that terminal and press enter. Once this is working. Change that same file to the following:

Code:
xterm &
dwm

Now it should launch xterm and DWM.

Edit: I don't blame you for finding this difficult. The handbook is seriously lacking here: https://docs.freebsd.org/en/books/handbook/x11/#x11-wm
It details desktop environments rather than WMs which is daft because they are niche in comparison (and mostly broken). Possibly this whole section shouldn't be fixed but entirely reverted to about 10 years ago.
I finally got DWM to start using this method.

my xinintrc used tohave this on the end
exec xterm (following string of settings, I assume for the default TWM)

When I attempted to add DWM to the exec list before I tried to simply add it by editing it to

exec xterm & dwm (following string of settings)
or
exec xterm & /usr/*full path*/dwm (following string of settings)
or
exec xterm (following string of settings, I assume for the default TWM)
dwm
and a few different such iterations. None of which worked.

I did this because I was afraid to delete the string of settings because I did not know what they actually did. Finally got so annoyed that I deleted them and formatted it like kdedersen said to

exec xterm &
dwm

When I ran startx dwm finally launched, to which I jumped out of my chair and did a victory dance around the office.

Thanks again for the help, folks. It has it's frustrations but I'm quite enjoying the learning process.

Sometime in the future I'll have to try installing from ports just to see how that works too.
 
Cheers lads. Had an issue where dwm didn't want to spawn new terminals, but I installed urxvt and set it as my default for dwm. works just fine.
Now to customized some more to clean things up a bit and make them nicer.

Thanks again, folks.
 

Attachments

  • signal-2021-10-19-215749.jpeg
    signal-2021-10-19-215749.jpeg
    414.6 KB · Views: 208
When I ran startx dwm finally launched, to which I jumped out of my chair and did a victory dance around the office.
Heh, glad it is finally working for you. The satisfaction generally overrules the frustrations ;)

One thing to note is that exec. What this does is replace the process with the one it is called with. So when that exits, the current process is no more. This has its uses but obviously causes issues with scripts that intend to run later commands after. i.e

Code:
xterm &     # "run in background"
exec xterm  # "run, replacing the process"
"will never reach here"

exec xterm & is quite strange because I would think you do not want to replace the process yet (especially not on a background process &) and you want to run dwm after. So I would instead recommend:

Code:
xterm &
exec dwm
 
Not sure if I should make another thread for this, but I have a couple more question about DWM setting.

First of all, how do I set it so that my system automatically starts x on boot?
I want to be into DWM before I even log in. How can I do this?

Also, how can I disable the boot screen I get from FreeBSD that has a timer asking me what mode I want to start (multi user, single user, etc)?

I’m trying to get things configured so that I can press the power button and let my system automatically do everything until it leaves me with a terminal open in DWM.
 
Not sure if I should make another thread for this, but I have a couple more question about DWM setting.

First of all, how do I set it so that my system automatically starts x on boot?
I want to be into DWM before I even log in. How can I do this?

Also, how can I disable the boot screen I get from FreeBSD that has a timer asking me what mode I want to start (multi user, single user, etc)?

I’m trying to get things configured so that I can press the power button and let my system automatically do everything until it leaves me with a terminal open in DWM.
You mean something like a display manager?
 
I second Menelkir , x11/slim. If you're going to need a login prompting GUI and auto start then this is just simple and slim.

Can I add, though that you won't be in DWM until you pass through slim which will prompt you for your login credentials and put you under the control of DWM.

If you don't want to use a display manager, you can add an "exec dwm" into you shell configuration/startup file, which will do it for you.
But of course, you have to log in to achieve this so a display manager is your solution.
 
I second Menelkir , x11/slim. If you're going to need a login prompting GUI and auto start then this is just simple and slim.

Can I add, though that you won't be in DWM until you pass through slim which will prompt you for your login credentials and put you under the control of DWM.

If you don't want to use a display manager, you can add an "exec dwm" into you shell configuration/startup file, which will do it for you.
But of course, you have to log in to achieve this so a display manager is your solution.
Hi, I installed slim from ports last night on Menelkir's recommendation, but how do I set it to launch on start?

Like I've said before I'm really new to this kind of stuff so I don't know to how/where to set startup programs.
 
Back
Top