You are not logged in.

#1 2019-08-01 13:10:55

Baitinq
Member
Registered: 2019-05-18
Posts: 11

Startx (.xinitrc) application autostart problem

Over the last day I have noticed a problem with my x-server starting. When I start X normally ($startx) all my scripts and programs in my xinitrc start correctly but when I make it so that the x-server is started automatically trough .bash_profile, redshift is not started.

Does anyone know why this happens? Seemingly the two executed commands are the same ($startx && exit) but when It is started automatically redshift simply doesnt start.

Thanks in advance for the input.

My xinitrc

#!/bin/sh

windowmanagername=dwm
windowmanager=/home/baitinq/dwm/$windowmanagername

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

# start some nice programs
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
    for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
        # shellcheck source=/dev/null
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

# start Gnome keyring (now done through PAM (https://wiki.voidlinux.org/GNOME/Keyring#xinitrc_method))
# if [ -f /usr/bin/gnome-keyring-daemon ]; then
#   dbus-update-activation-environment --systemd DISPLAY
#   eval $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh)
#   export SSH_AUTH_SOCK
# fi

#Autostarts
setxkbmap -option "" &
setxkbmap -variant chromebook &
setxkbmap -layout gb &
numlockx on &

sxhkd &
dunst &
clipmenud &
unclutter &
redshift -l $LOCATION &
i3-battery-popup -L 30 -n &

/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &

# start wm/de and keep it running (if dmw if not normal)
exec /home/baitinq/dwm/scripts/dwm-status &
exec smart-wallpaper -d /home/baitinq/Images/Wallpapers/Day -n /home/baitinq/Images/Wallpapers/Night -l $LOCATION & 2> /tmp/smart.log
while :; do
	ssh-agent $windowmanager 2> /tmp/dwm.log
done
.



My bash_profile

# StartX
if [ "$(tty)" = "/dev/tty1" ]; then
    startx && exit
fi

[[ -f ~/.bashrc ]] && . ~/.bashrc

Last edited by Baitinq (2019-08-01 13:25:30)

Offline

#2 2019-08-01 13:14:42

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Startx (.xinitrc) application autostart problem

If you want any help, you'll need to show us what you're actually doing.  Post your bash_profile, bashrc, and xinitrc.

One important difference in the two cases is that when you start x from your bash_profile, nothing else in that profile or bashrc is executed before X starts.  When you log in and type startx, all of your bash_profile and bashrc have already been processed.  So any path settings, other environment variables, etc, can be different.

EDIT: There's the problem:

redshift -l $LOCATION &

Where is LOCATION set/defined?  Presumably this is in the bashrc that wasn't posted.

Last edited by Trilby (2019-08-01 13:28:53)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2019-08-01 13:34:02

Baitinq
Member
Registered: 2019-05-18
Posts: 11

Re: Startx (.xinitrc) application autostart problem

Yest the $LOCATION env variable is in the bashrc. That might actually be the problem now that you point it out. Ill try to add a "source .bashrc" in the bash_profile so the location variable is present before the xinitrc is executed.

EDIT: That was indeed the problem. Thanks for pointing it out.

Last edited by Baitinq (2019-08-01 13:55:48)

Offline

#4 2019-08-01 13:38:23

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Startx (.xinitrc) application autostart problem

Your bashrc is already sourced from bash_profile, it is just done so after X is started, so it's too late.  You could *move* it earlier in bash_profile, but that's generally not needed and a bit of a waste - no need to keep rereading that same file.  Just define LOCATION at the top of bash_profile.

Sidenote: you'll also probably want to check the DISPLAY variable before starting X as is recommended in the wiki: https://wiki.archlinux.org/index.php/Xi … X_at_login

This ensures that if any other terminal within your X session starts as a login shell or for any other reason sources bash_profile that it will not try to startx again.

Last edited by Trilby (2019-08-01 13:40:38)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2019-08-01 21:01:19

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,186

Re: Startx (.xinitrc) application autostart problem

Also sidenote: don't just fork everything, in particular not the setxkbmap & numlockx calls to avoid interference on the server and arbitrary conditions towards following clients (eg. sxhkd)
You can also aggregate the setxkbmap calls in one.

Offline

Board footer

Powered by FluxBB