Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problems with xinit and dwm
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
dscharalampidis
n00b
n00b


Joined: 07 Dec 2021
Posts: 18

PostPosted: Tue Dec 07, 2021 5:38 am    Post subject: Problems with xinit and dwm Reply with quote

I installed a Gentoo profile with SELinux, hardened kernel and without a desktop.
I am not planning to use a display manager and will be using dwm for a window manager.

I have the following ~/.xinitrc:
Code:
#!/bin/sh
#
# ~/.xinitrc
#
# Set variables
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/Xresources
sysmodmap=/etc/X11/xinit/Xmodmap

# merge in defaults and keymaps
if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then
    xrdb -merge "$userresources"
fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# source the xprofile
[ -f /etc/xprofile ] && . /etc/xprofile
[ -f ~/.xprofile ] && . ~/.xprofile

# start the window manager
exec dbus-launch --sh-syntax --exit-with-session dwm


I am planning to use the ~/.xprofile as an autostart script:
Code:
#!/bin/sh
#
# ~/.xprofile
#
# Fix Java misbehaving with DWM
/usr/bin/wmname LG3D &
AWT_TOOLKIT=MToolkit; export AWT_TOOLKIT &

# Start the OpenRazer daemon
/usr/bin/openrazer-daemon &


Finally, I have configured my ~/.bash_profile initialize X upon successful login:
Code:
#!/bin/sh
#
# ~/.bash_profile
#
# Starting X11 on console login
if shopt -q login_shell; then
            [[ -f ~/.bashrc ]] && source ~/.bashrc
                [[ -t 0 && $(tty) == /dev/tty1 && ! $DISPLAY ]] && exec startx
        else
                    exit 1 # Somehow this is a non-bash or non-login shell.
fi


The problem that I am facing is that my ~/.xprofile is not being sourced upon login, or at least that's what it appears to be happening.
After logging in, dwm starts normally, but whatever is in my ~/.xprofile doesn't.
If I do:
Code:
source ~/.xprofile

Everything runs smoothly.

I tried to move the contents of ~/.xprofile into ~/.xinitrc, but again, they are being ignored.

What am I doing wrong?
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Wed Dec 08, 2021 5:11 am    Post subject: Reply with quote

Quote:
The problem that I am facing is that my ~/.xprofile is not being sourced upon login, or at least that's what it appears to be happening.

I would add the line below to ~/.xprofile:
Code:
echo ".xprofile running..." >>/tmp/xprofile.log

Run 'cat /tmp/xprofile.log' to see if any how many times ~/.xprofile has been running.

Code:
AWT_TOOLKIT=MToolkit; export AWT_TOOLKIT &

This line won't do what you want if you start it in the background.

Quote:
I tried to move the contents of ~/.xprofile into ~/.xinitrc, but again, they are being ignored.

I can only guess. Try to add some delay between the invocation of /usr/bin/openrazer-daemon and the invocation of dwm.
Back to top
View user's profile Send private message
dscharalampidis
n00b
n00b


Joined: 07 Dec 2021
Posts: 18

PostPosted: Wed Dec 08, 2021 12:01 pm    Post subject: Reply with quote

@mike155 thanks for the reply!

Adding echo in .xprofile is a great idea.
I added one at the top and one the bottom of the file, so I now know that the file is indeed parsed from top to bottom.

Adding sleep however, did not help.

So, dmw starts, the xprofile is parsed because I can see both the echo messages in the log, but the other commands are as if they are not in there.
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Wed Dec 08, 2021 1:54 pm    Post subject: Reply with quote

Great.

The next step is error handling. :)

First of all, take a look at the system log. Maybe there are messages from openrazer-daemon?

Then, redirect output of your script to a file. Alter the invocation of ~/.xprofile in .xinitrc to:
Code:
source ~/.xprofile >/tmp/xprofile.out 2>&1

Are there any messages in /tmp/xprofile.out?

Inside of shell scripts, you could (and should) check error return codes of programs you call.
Code:
if ! /usr/bin/openrazer-daemon
then
    echo "openrazer-daemon failed with error code $!"
fi

It seems that you want to start openrazer-daemon in the background? Is that necessary? Or does openrazer-daemon fork itself? Maybe it has an option that makes it fork itself and run as a daemon?

If you really want to start openrazor-daemon in the background, you could try something like:
Code:
(
    if ! /usr/bin/openrazer-daemon
    then
        echo "openrazer-daemon failed with error code $?"
    fi
) &
Back to top
View user's profile Send private message
dscharalampidis
n00b
n00b


Joined: 07 Dec 2021
Posts: 18

PostPosted: Wed Dec 08, 2021 2:34 pm    Post subject: Reply with quote

@mike155, I really appreciate your help!

So...

xprofile.out came out empty.

Then, I had the following idea:

I added the error handling ifs to the ~/.xprofile script as well as two echos, one at the start and one the end. All echos were exporting to a log file.

The log file came out with only the start and end echos, which suggests that the rest of the commands are running without issues... only they are not :)

Anyway, I solved my issue by patching dwm with this:
https://dwm.suckless.org/patches/autostart/

Although I am curious about what's going on, I have to move on as I have other mysteries to solve in my journey from Arch to Gentoo :)
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