linuxx11x-dwm

Background and top bar configurations does not apply at startup


I am on Manjaro Linux and using dwm. I have made some changes (additions) in my ~/.xinitrc file to have my wallpaper set and display date & time on top bar when I log in. But I cannot have these changes applied or having an issue with my files such as ~/.xinitrc and /etc/X11/xinit/xinitrc.

I already have compton, feh (also nitrogen but do not prefer) and xsetroot installed on my system. I also applied this patch to my dwm in order to have an autostart.sh file.

Here is my ~/.dwm/autostart.sh file:

#! /bin/bash
compton --config ~/.config/compton/compton.conf &
feh --bg-fill /home/root113/Pictures/0239.jpg &
xcompmgr &

while true; do
     xsetroot -name "$(date)"
     sleep 1s
done &

This did not work. There exist a similar problem here asked 29 days ago but yet not answered or recieved any comments.

Then I search the net for more answers and help and realised that I should try to edit my ~/.xinitrc file. Here it is:

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager 
from here)

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

DEFAULT_SESSION=gnome-session

# 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

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
    for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

get_session(){
    local dbus_args=(--sh-syntax --exit-with-session)
    case $1 in
        awesome) dbus_args+=(awesome) ;;
        bspwm) dbus_args+=(bspwm-session) ;;
        budgie) dbus_args+=(budgie-desktop) ;;
        cinnamon) dbus_args+=(cinnamon-session) ;;
        deepin) dbus_args+=(startdde) ;;
        enlightenment) dbus_args+=(enlightenment_start) ;;
        fluxbox) dbus_args+=(startfluxbox) ;;
        gnome) dbus_args+=(gnome-session) ;;
        i3|i3wm) dbus_args+=(i3 --shmlog-size 0) ;;
        jwm) dbus_args+=(jwm) ;;
        kde) dbus_args+=(startkde) ;;
        lxde) dbus_args+=(startlxde) ;;
        lxqt) dbus_args+=(lxqt-session) ;;
        mate) dbus_args+=(mate-session) ;;
        xfce) dbus_args+=(xfce4-session) ;;
        openbox) dbus_args+=(openbox-session) ;;
        *) dbus_args+=($DEFAULT_SESSION) ;;
    esac

    echo "dbus-launch ${dbus_args[*]}"
}

exec $(get_session)

#Personal customizations below

compton --config ~/.config/compton/compton.conf &
feh -bg-fill /home/root113/Pictures/0239.jpg &
xcompmgr &

while true; do
    xsetroot -name "$(date)"
    sleep 1s
done &

exec dwm

Still, the problem haven't got solved. Then I changed the line

feh -bg-fill /home/root113/Pictures/0239.jpg &

with this:

~/.fehbg &

What is written inside ~/.fehbg is:

#!/bin/sh
feh --no-fehbg --bg-fill /home/root113/Pictures/0239.jpg

Did not solve my problem.

Then I decided to export my ~/.xinitrc file in /etc/X11/xinit/xinitrc by adding this line at the end of the file:

 export PATH="${PATH}:/home/root113/.xinitrc"

This did not work either. So I kept my solution seeking on the net and in one of the forums I was told that I should make my ~/.xinitrc file executable. So I did that with the following command:

 chmod +x ~/.xinitrc

Did not work either. Every time I log back in or reboot, it is the same annoying black screen and top bar with no date being displayed at all that my eyes stares.

I also tried replacing ~/file with /home/root113/file in every file in case of the path was not recognised. It was not a solution at all. Did not work.

I kept searching and searching for answers and read these useful answers and articles:

None of them refers to a kind of problem/issue that I have directly, but indirectly. So I decided to (probably a stupid idea but worth giving a try since I started to ran out of solutions) add the following to my ~/.profile file:

export PATH="${PATH}:/home/root113/.xinitrc"

Did not work either then I added the following to my ~/.zshrc file:

source ~/.profile

Did not work again.

I searched high and low for a solution on the net. I am literally in a desperate situation at the moment. I have no hope left but asking here. Thank you for reading through here. I know it has been a long question but I wanted to explain the problem to you in details and also wanted to tell you what solutions I have tried so far.


Solution

  • I figured out that in ~/.xinitrc file I have to declare my personel settings before all other stuff. Just placed them on top of the file as:

    #!/bin/sh
    #
    # ~/.xinitrc
    #
    # Executed by startx (run your window manager 
    from here)
    
    #Personal customizations below
    
    compton --config ~/.config/compton/compton.conf &
    feh -bg-fill /home/root113/Pictures/0239.jpg &
    xcompmgr &
    
    while true; do
        xsetroot -name "$(date)"
        sleep 1s
    done &
    
    exec dwm
    
    userresources=$HOME/.Xresources
    usermodmap=$HOME/.Xmodmap
    sysresources=/etc/X11/xinit/.Xresources
    sysmodmap=/etc/X11/xinit/.Xmodmap
    
    DEFAULT_SESSION=gnome-session
    
    # 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
    
    # start some nice programs
    
    if [ -d /etc/X11/xinit/xinitrc.d ] ; then
        for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
            [ -x "$f" ] && . "$f"
        done
        unset f
    fi
    
    get_session(){
        local dbus_args=(--sh-syntax --exit-with-session)
        case $1 in
            awesome) dbus_args+=(awesome) ;;
            bspwm) dbus_args+=(bspwm-session) ;;
            budgie) dbus_args+=(budgie-desktop) ;;
            cinnamon) dbus_args+=(cinnamon-session) ;;
            deepin) dbus_args+=(startdde) ;;
            enlightenment) dbus_args+=(enlightenment_start) ;;
            fluxbox) dbus_args+=(startfluxbox) ;;
            gnome) dbus_args+=(gnome-session) ;;
            i3|i3wm) dbus_args+=(i3 --shmlog-size 0) ;;
            jwm) dbus_args+=(jwm) ;;
            kde) dbus_args+=(startkde) ;;
            lxde) dbus_args+=(startlxde) ;;
            lxqt) dbus_args+=(lxqt-session) ;;
            mate) dbus_args+=(mate-session) ;;
            xfce) dbus_args+=(xfce4-session) ;;
            openbox) dbus_args+=(openbox-session) ;;
            *) dbus_args+=($DEFAULT_SESSION) ;;
        esac
    
        echo "dbus-launch ${dbus_args[*]}"
    }
    
    exec $(get_session)
    

    Everything is working properly now.