Skip to main content

The i3 Autostart Trap: How One Line of Code Hijacks Your Config

· 2 min read
Max Kaido
Architect

For months, I was haunted by a ghost in my machine. My i3 config, which I had carefully crafted, was behaving erratically. Scripts that were supposed to run on startup would sometimes fail. Worse, a hideous black-and-white noise screensaver would randomly appear, despite my explicit commands to disable it. I had gotten so used to the randomness that I accepted it as a fact of life.

Today, that ended. The culprit was found, and it's a lesson in how seemingly harmless "convenience" features can wreak havoc in a minimal environment.

The Problem: Unreliable exec_always

My i3 config contained these unambiguous lines:

# Disable screen blanking and power management
exec_always --no-startup-id xset s off
exec_always --no-startup-id xset -dpms
exec_always --no-startup-id xset s noblank

Yet, the screensaver kept returning. This wasn't a problem with i3 or xset. It was a race condition. Two different systems were fighting for control of my display settings at startup, and I had no idea who the other competitor was.

The Culprit: dex, the Hidden Saboteur

The investigation uncovered this seemingly innocent line hiding in plain sight near the top of my i3 config:

# Start XDG autostart .desktop files
exec --no-startup-id dex --autostart --environment i3

What does dex do? It scans the XDG autostart directory (/etc/xdg/autostart/) and launches every single application defined there. This is a feature inherited from full desktop environments like GNOME and XFCE, which use this directory to auto-launch everything from clipboard managers to power managers.

A quick look inside that directory on my system revealed the smoking guns:

  • light-locker.desktop
  • xfce4-power-manager.desktop
  • xscreensaver.desktop
  • A whole suite of gnome.SettingsDaemon services.

My i3 session was blindly launching a cocktail of conflicting power managers and screensavers. Sometimes my xset commands would execute last, and my session would be fine. Other times, one of these services would launch after xset, immediately overriding my settings and re-enabling the screensaver. This was the source of the maddening randomness.

The Solution: Kill It With Fire

The fix was brutally simple: delete the dex line.

# Start XDG autostart .desktop files
- exec --no-startup-id dex --autostart --environment i3

The entire point of using i3 is to have explicit control over your environment. The dex command is the philosophical opposite of this. It's a black box that invites chaos from other desktop environments you've intentionally left behind.

My config was already correctly and explicitly launching the services I actually need:

# This is the correct way
exec --no-startup-id nm-applet
exec --no-startup-id blueman-applet
exec --no-startup-id picom -b

By removing the one line that tried to be "helpful," I eliminated the conflict. My xset commands are now the single source of truth, and the screensaver is gone for good.

The Takeaway

If your i3 config feels unreliable, look for hidden "magic." A minimal window manager demands an explicit configuration. Don't let the ghosts of full desktop environments haunt your machine. Check your config for dex or any other blanket autostart utility and reclaim control.