Where is the command to launch i3 (when we first login into the system) located?

I assume there is a shell script somewhere with the command:

i3 -c ~/.config/i3/config

I tried to look for it in /etc/profile and /etc/X11/xinit/xinitrc but couldn’t find that line.

xsession :wink:

[13:40:41] joekamprad :: i3-private  ➜  ~ » cat /usr/share/xsessions/i3.desktop                                   
[Desktop Entry]
Name=i3
Comment=improved dynamic tiling window manager
Exec=i3
TryExec=i3
Type=Application
DesktopNames=i3
Keywords=tiling;wm;windowmanager;window;manager;

What is used by DMs (lightdm in case)

You could also start it with a .xinitrd (starts) if you do not want a DM …

[13:47:56] joekamprad :: i3-private  ➜  ~ » cat ~/.xinitrc                     
#!/bin/sh

exec dbus-launch --sh-syntax --exit-with-session i3

the config file is simply the default i3 uses so not need to specify it takes it …

1 Like

@joekamprad

Hmm. That’s quite a bummer.

I was looking for a way to load different i3 config files under different conditions because I have different configs/keybindings for i3 depending on my monitor set-up.

Here is my current solution (using i3’s include directive), but I’m not very happy with it. It seems a bit clumsy, but here it is:

# i3 config file (v4)

exec_always --no-startup-id ~/.screenlayout/monitor.sh

include ~/.config/i3/additional_monitor_config

The file ~/.config/i3/additional_monitor_config is actually a symbolic link to different config files to be included. The idea is to set the correct symbolic link to the right file inside ~/.screenlayout/monitor.sh like so:

#!/bin/sh

reset_symlink(){
    if [[ -L $1 ]]
    then
        rm $1
    fi
}

vga=$(xrandr | grep "VGA-1" | cut -d " " -f 2)
hdmi=$(xrandr | grep "HDMI-1" | cut -d " " -f 2)
symlink="/home/anthony93/.config/i3/additional_monitor_config"
reset_symlink $symlink

if [[ "$vga" == "connected" && "$hdmi" == "connected" ]]
then
    #three monitor setup (vga + hdmi + laptop)
    ln -s "/home/anthony93/.config/i3/config_three_monitor.conf" $symlink
    sleep 1 #Don't run xrandr too early 
    xrandr --output VGA-1 --auto --above eDP-1 --output HDMI-1 --auto --right-of VGA-1
elif [[ "$vga" == "disconnected" && "$hdmi" == "connected" ]]
then
    #dual monitor setup (hdmi + laptop)
    ln -s "/home/anthony93/.config/i3/config_dual_monitor_hdmi.conf" $symlink
    sleep 1
    xrandr --output HDMI --auto --above eDP-1
elif [[ "$vga" == "connected" && "$hdmi" == "disconnected" ]]
then
    #dual monitor setup (vga + laptop)
    ln -s "/home/anthony93/.config/i3/config_dual_monitor_vga.conf" $symlink
    sleep 1
    xrandr --output VGA-1 --auto --above eDP-1
else
    #single monitor setup
    ln -s "/home/anthony93/.config/i3/config_single_monitor.conf" $symlink
fi

i3-msg reload

But this method itself poses a problem. Notice how I added a sleep before each call to xrandr? Yeah. I did that because xrandr wouldn’t work correctly if I didn’t. According to Archwiki, this is an issue with xrandr where running it too soon after login will cause it to malfunction.

Adding sleep commands before xrandr solves the issue, but it gives rise to yet another problem: the include directive inside the config file is already processed by the time monitor.sh sets the additional_monitor_config symlink. That means the symlink doesn’t yet exist at the time the include is loaded, which means none of my extra configs will be loaded.

The only way I could think of to solve this is by adding i3-msg reload to the bottom of monitor.sh to force i3 to reload the config after the script runs, which, believe it or not, has its own set of problems (because i3 assigns default workspaces to each screen when it first loads, I won’t be able to see the icons i assigned to my workspaces for each screen until I launch my applications)

If only I can set the symbolic links first before i3 even starts. Should I be using udev to do that? Or maybe do it with lightdm?

I got it to work.

Added the script to the /etc/lightdm/lightdm.conf under session-setup-script

2 Likes

i mean i3 has the option to get started with an alternative config indeed… i was only giving the info how it is getting started on EndeavourOS per default :wink:

-c <file> use the provided configfile instead

so you can do create different session desktop files per example:

/usr/share/xsessions/i3-multi.desktop

[Desktop Entry]
Name=i3-multi
Comment=improved dynamic tiling window manager
Exec=i3 -c ~/.config/i3/multi
TryExec=i3 -c ~/.config/i3/multi
Type=Application
DesktopNames=i3-multi
Keywords=tiling;wm;windowmanager;window;manager;

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.