Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
DWM custom configuration file
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
ejingles
n00b
n00b


Joined: 10 Dec 2021
Posts: 4

PostPosted: Fri Dec 10, 2021 10:58 am    Post subject: DWM custom configuration file Reply with quote

Good morning,

First of all, I'd like to thank you for your time to read my question.

So, I've my very own DWM configuration file and I'm trying to compile it, I've sort the savedconfig parameter, the problem is that my DWM configuration needs to import other .c files and not just one file.

I've tried to put all files in the /etc/portage/savedconfig/x11-wm directory but did not have success, it keeps giving me a error that cannot import "layout.c" when I try to emerge it.

This is my files:


.
├── autostart.sh
├── config.def.h
├── config.def.h.orig
├── config.def.h.rej
├── config.h
├── config.mk
├── drw.c
├── drw.h
├── drw.o
├── dwm
├── dwm.1
├── dwm.1.orig
├── dwm-autostart-20210120-cb3f58a.diff
├── dwm-bar-height-6.2.diff
├── dwm.c
├── dwm-center-6.2.diff
├── dwm.c.orig
├── dwm.c.rej
├── dwm-cyclelayouts-20180524-6.2.diff
├── dwm-fullgaps-20200508-7b77734.diff
├── dwm-fullgaps-6.2.diff
├── dwm-gridmode-20170909-ceac8c9.diff
├── dwm.o
├── dwm.png
├── dwm-rotatestack-20161021-ab9571b.diff
├── dwm-systray-20210418-67d76bd.diff
├── dwm-viewontag-20210312-61bb8b2.diff
├── layouts.c
├── LICENSE
├── Makefile
├── README
├── re.txt
├── transient.c
├── util.c
├── util.h
└── util.o

0 directories, 36 files


Anyone has a hint on how to solve this? I've thought of compiling it as a custom repo,

Thanks for your time.
Back to top
View user's profile Send private message
dscharalampidis
n00b
n00b


Joined: 07 Dec 2021
Posts: 18

PostPosted: Fri Dec 10, 2021 11:59 am    Post subject: Reply with quote

Hi,

If you compiled dwm with the savedconfig USE flag emerge will look for your config.h at /etc/portage/savedconfig/x11-wm/dwm-6.2 as per the wiki: https://wiki.gentoo.org/wiki/Dwm

Any file that is imported via this file must be at the directory from where you are trying to import it.
I am guessing that it is not there. However to better assist you please post your config.h here as well as the output of emerge.

Additionally, I can see that you have several patches in there. In Gentoo, there's a different way for applying patches that you can read about in the wiki above.
Back to top
View user's profile Send private message
ejingles
n00b
n00b


Joined: 10 Dec 2021
Posts: 4

PostPosted: Fri Dec 10, 2021 3:53 pm    Post subject: Reply with quote

Hello!

Sorry for the delay.

Quote:
If you compiled dwm with the savedconfig USE flag emerge will look for your config.h at /etc/portage/savedconfig/x11-wm/dwm-6.2 as per the wiki: https://wiki.gentoo.org/wiki/Dwm


Yes, the problem is that file has to import from another file.

Quote:
Any file that is imported via this file must be at the directory from where you are trying to import it.


I copied all the files to the path /etc/portage/savedconfig/x11-wm/

Quote:
Additionally, I can see that you have several patches in there. In Gentoo, there's a different way for applying patches that you can read about in the wiki above.


I'm aware of that, but it can be difficult and tedious to reconfigure all the dwm configuration to replicate my configuration.


Quote:
However to better assist you please post your config.h here as well as the output of emerge.


This is part of config. let me know if u want everything.

Code:
#include "layouts.c"
static const Layout layouts[] = {
        /* symbol     arrange function */
        { "[]=",      tile },    /* first entry is default */
        { "><>",      NULL },    /* no layout function means floating behavior */
        { "[M]",      monocle },
        { "HHH",      grid },
        { NULL,       NULL },
};



Output of emerge:

Code:


Would you like to merge these packages? [Yes/No] yes

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) x11-wm/dwm-6.2::gentoo
 * dwm-6.2.tar.gz BLAKE2B SHA512 size ;-) ...                                                                                                  [ ok ]
>>> Unpacking source...
>>> Unpacking dwm-6.2.tar.gz to /var/tmp/portage/x11-wm/dwm-6.2/work
>>> Source unpacked in /var/tmp/portage/x11-wm/dwm-6.2/work
>>> Preparing source in /var/tmp/portage/x11-wm/dwm-6.2/work/dwm-6.2 ...
 * Checking existence of "/etc/portage/savedconfig/x11-wm/dwm-6.2" ...
 * Found "/etc/portage/savedconfig/x11-wm/dwm-6.2"
 * Building using saved configfile "/etc/portage/savedconfig/x11-wm/dwm-6.2"
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/x11-wm/dwm-6.2/work/dwm-6.2 ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/x11-wm/dwm-6.2/work/dwm-6.2 ...
make -j8 CC=x86_64-pc-linux-gnu-gcc dwm
x86_64-pc-linux-gnu-gcc -c -march=skylake -O2 -pipe -std=c99 -pedantic -Wall -Wno-deprecated-declarations -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"6.2\" -DXINERAMA drw.c
x86_64-pc-linux-gnu-gcc -c -march=skylake -O2 -pipe -std=c99 -pedantic -Wall -Wno-deprecated-declarations -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"6.2\" -DXINERAMA dwm.c
x86_64-pc-linux-gnu-gcc -c -march=skylake -O2 -pipe -std=c99 -pedantic -Wall -Wno-deprecated-declarations -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"6.2\" -DXINERAMA util.c
In file included from dwm.c:272:
config.h:38:87: warning: excess elements in struct initializer
   38 |         { "Gimp",     NULL,       NULL,       0,            0,           1,           -1 },
      |                                                                                       ^
config.h:38:87: note: (near initialization for 'rules[0]')
config.h:39:87: warning: excess elements in struct initializer
   39 |         { "Firefox",  NULL,       NULL,       1 << 8,       0,           0,           -1 },
      |                                                                                       ^
config.h:39:87: note: (near initialization for 'rules[1]')
config.h:47:10: fatal error: layouts.c: No such file or directory
   47 | #include "layouts.c"
      |          ^~~~~~~~~~~
compilation terminated.
make: *** [Makefile:18: dwm.o] Error 1
make: *** Waiting for unfinished jobs....
drw.c: In function 'drw_text':
drw.c:328:35: warning: 'ew' may be used uninitialized in this function [-Wmaybe-uninitialized]
  328 |                                 w -= ew;
      |                                 ~~^~~~~
 * ERROR: x11-wm/dwm-6.2::gentoo failed (compile phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=x11-wm/dwm-6.2::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=x11-wm/dwm-6.2::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/x11-wm/dwm-6.2/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/x11-wm/dwm-6.2/temp/environment'.
 * Working directory: '/var/tmp/portage/x11-wm/dwm-6.2/work/dwm-6.2'
 * S: '/var/tmp/portage/x11-wm/dwm-6.2/work/dwm-6.2'

>>> Failed to emerge x11-wm/dwm-6.2, Log file:

>>>  '/var/tmp/portage/x11-wm/dwm-6.2/temp/build.log'

 * Messages for package x11-wm/dwm-6.2:

 * Building using saved configfile "/etc/portage/savedconfig/x11-wm/dwm-6.2"
 * ERROR: x11-wm/dwm-6.2::gentoo failed (compile phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=x11-wm/dwm-6.2::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=x11-wm/dwm-6.2::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/x11-wm/dwm-6.2/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/x11-wm/dwm-6.2/temp/environment'.
 * Working directory: '/var/tmp/portage/x11-wm/dwm-6.2/work/dwm-6.2'
 * S: '/var/tmp/portage/x11-wm/dwm-6.2/work/dwm-6.2'



Thank you very much for the time spent.
Back to top
View user's profile Send private message
dscharalampidis
n00b
n00b


Joined: 07 Dec 2021
Posts: 18

PostPosted: Fri Dec 10, 2021 4:42 pm    Post subject: Reply with quote

The compiler will look for the included files in certain directories to include them in the compilation.
Those directories are:
- The directory of the source code,
- The /usr/include/ directory,
- The /usr/local/include/ directory,
etc...

As far as I know portage does not keep the extracted sources. The source code is kept in archives at /var/cache/distfiles and it is extracted at a temporary folder upon emerging; then it is being deleted. That said, there is no place for you to put your layout.c file in so that it is in the same folder as the source code.

I do not know the exact mechanics of the savedconfig USE flag but I am guessing it will only look for a specific file and symlink it to replace the config.def.h.

So, in my opinion, you have two options:
1. Copy your layout.c file at /usr/include/,
2. Add another folder to your C_INCLUDE_PATH environmental variable and then copy the file there.

Again, for the patches to be applied you need to rename them and add them to your /etc/portage/patches/x11-wm/dwm-6.2/

The /etc/portage/savedconfig/ directory is not your source code directory and whatever you put in there is not going to be read, except for the dwm-6.2 file.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21764

PostPosted: Fri Dec 10, 2021 5:14 pm    Post subject: Reply with quote

Why do you need to include a C file in your header? That is technically legal, but very odd. What is in layouts.c that you need to include it anywhere?
Back to top
View user's profile Send private message
dscharalampidis
n00b
n00b


Joined: 07 Dec 2021
Posts: 18

PostPosted: Fri Dec 10, 2021 5:22 pm    Post subject: Reply with quote

Hu wrote:
Why do you need to include a C file in your header? That is technically legal, but very odd. What is in layouts.c that you need to include it anywhere?


I agree that it's odd and although I have no clue what's inside the file, it's added by this patch: https://dwm.suckless.org/patches/gridmode/
Back to top
View user's profile Send private message
ejingles
n00b
n00b


Joined: 10 Dec 2021
Posts: 4

PostPosted: Sat Dec 11, 2021 12:01 am    Post subject: Reply with quote

Hello,

this is the content of layouts.c

Code:

void
grid(Monitor *m) {
        unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows;
        Client *c;

        for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next))
                n++;

        /* grid dimensions */
        for(rows = 0; rows <= n/2; rows++)
                if(rows*rows >= n)
                        break;
        cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;

        /* window geoms (cell height/width) */
        ch = m->wh / (rows ? rows : 1);
        cw = m->ww / (cols ? cols : 1);
        for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
                cx = m->wx + (i / rows) * cw;
                cy = m->wy + (i % rows) * ch;
                /* adjust height/width of last row/column's windows */
                ah = ((i + 1) % rows == 0) ? m->wh - ch * rows : 0;
                aw = (i >= rows * (cols - 1)) ? m->ww - cw * cols : 0;
                resize(c, cx, cy, cw - 2 * c->bw + aw, ch - 2 * c->bw + ah, False);
                i++;
        }
}


Shall I put the code in the configuration file directly? I could do that, but what's confusing me is not being able to compile the code that I have. Sorry if i'm misunderstanding how it works.

Also, it's not making too much sense that I need to repatch a fresh configuration when I have done it already. Manual patching can get really annoying.

Thanks once again guys.
Back to top
View user's profile Send private message
dscharalampidis
n00b
n00b


Joined: 07 Dec 2021
Posts: 18

PostPosted: Sat Dec 11, 2021 12:20 am    Post subject: Reply with quote

ejingles wrote:
what's confusing me is not being able to compile the code that I have.

I tried to explain in my previous reply, but maybe I did not express myself clearly.

This statement #include "layouts.c" tells the compiler to go find that layouts.c file and include it in the code it compiles.
The compiler will try to find that file in the directories I mentioned before.

In your case, the file is not there and it fails.

ejingles wrote:
Shall I put the code in the configuration file directly?

Copying the code of layouts.c into your config.h should also work.

ejingles wrote:
Also, it's not making too much sense that I need to repatch a fresh configuration when I have done it already.

What do you mean? When did you patch it?
Back to top
View user's profile Send private message
ejingles
n00b
n00b


Joined: 10 Dec 2021
Posts: 4

PostPosted: Sat Dec 11, 2021 1:35 am    Post subject: Reply with quote

I mean that my configuration files are already patched, I just kept the "patch files" to keep track of what I've patched already on my configuration files. This is my "dotfiles" dwm configuration.

For example, when I do a new arch installation, I'll just "recompile" that directory and I've everything set to go.


Tomorrow I'll try adding those files to the path that you mentioned. I'll give a feedback afterwards.
Back to top
View user's profile Send private message
dscharalampidis
n00b
n00b


Joined: 07 Dec 2021
Posts: 18

PostPosted: Sat Dec 11, 2021 1:59 am    Post subject: Reply with quote

A patch is applied upon compilation to the binary. Nothing changes in the source code.
If you remove the .diff files from the directory and recompile; the resulting binary will not include the patches.
The C compiler sees those files in the directory of the source code and applies them to the binary.

That's not specific to Gentoo. It's the same on Arch and any other distro or operating system.

You can forget about emerge and compile the source code that you have, the same way you are used to on Arch. The config.mk will still work and install dwm where it's supposed to be installed.
However, if you want to use emerge and install dwm the Gentoo way, then you must keep in mind the following:
1. The savedconfig directory is there to help you make changes to the config.h - it is not where you put your source code.
2. To apply patches you must rename them and keep them under /etc/portage/patches/x11-wm/dwm-6.2/ so that every time you run emerge, portage will find them and apply them to the binary.

If you want to call other files via #include in your config.h, you need to place those files at a directory where the compiler can find them.
Since the source code directory is created by portage at /tmp during compilation and after that it is deleted, you need to place those files in one of the other directories that the compiler scans, like the /usr/include/ or set another folder to your C_INCLUDE_PATH environmental variable and then copy the files there.

I hope that helps.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum