The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
1

How can I use autostart .desktop files in i3?

asked 2013-07-08 18:58:45 +0000

ack006 gravatar image

updated 2013-07-13 11:46:42 +0000

Many applications include .desktop files in the /etc/xdg/autostart directory to enable the automatic start of the application when the desktop environment or window manager starts up. While searching for these autostart commands using:

$ grep "Exec=" /etc/xdg/autostart/* ${HOME}/.config/autostart/*

then manually adding them as exec <command> lines to ${HOME}/.i3/config works, it quickly becomes tedious to keep track of newly installed or uninstalled applications. Are there any ways to automate this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-07-08 19:40:23 +0000

ack006 gravatar image

updated 2013-07-09 15:03:09 +0000

One possibility is to use dex.

(Note: dex isn't part of i3, it needs to be installed using a package manager or built from source.)

dex is a very handy utility for working with .desktop files. Used with the path to a .desktop file, it will start the application. Used with the -a option, it will start applications with .desktop files in the 'autostart' directories, and it is smart enough to decide which of them to start depending on the desktop environment or window manager used.

Since few applications know about i3 (yet ;-) ), some tweaking of .desktop files may be needed.

First, test what applications would be started without any tweaks by running:

$ dex -vad

This will show what dex would do with each .desktop file in the autostart directories /etc/xdg/autostart and ${HOME}/.config/autostart, showing for each of them if it would be ignored, and if not, what command would be executed for starting the application. Some applications may not be appropriate or useful in i3, others would be useful in i3, but would not be started because they specify a specific desktop environment to start in. All this can be fixed by doing some tweaking, see below.

For each application whose startup you wish to modify, edit the application's .desktop file in /etc/xdg/autostart/<application>.desktop (or copy it to ${HOME}/.config/autostart/<application>.desktop first).

(1) To not start an application if i3 is running, add the following line:

NotShowIn=i3;

(2) To start an application only if i3 is running, remove any NotShowIn= line, then add:

OnlyShowIn=i3;

(3) To tweak an application's startup command only if i3 is running, first do step (1), then make a fresh copy of the original .desktop file, naming it something like <application>-i3.desktop, do step (2) on this file, then finally change the line:

Exec=<command>

to your liking. To test the change, use:

$ dex </path/to/application.desktop>

Now, to verify that all your changes are correct, tell dex to simulate autostart using the i3 window manager:

$ dex -vade -i3

and fix any problems. Finally, edit ${HOME}/.i3/config, remove any now redundant exec <command> lines, and add the line:

exec dex -ae i3

at the very end, then log out and back in.

Done :-)

edit flag offensive delete link more

Comments

Sounds cool. Tell us more about `dex`. I get `command not found`.

joepd gravatar imagejoepd ( 2013-07-08 21:42:16 +0000 )edit

dex isn't part of i3, you have to install it using your distribution's package manager or build it from source ;-)

ack006 gravatar imageack006 ( 2013-07-09 01:00:50 +0000 )edit

Nice, thanks for editing your question!

joepd gravatar imagejoepd ( 2013-07-09 08:26:17 +0000 )edit

Very nice answer.

vvo gravatar imagevvo ( 2013-09-01 22:14:13 +0000 )edit

Fantastic, this allows me to use standard xdg autostart with basically any wm. I was troubled by exec commands in i3 since those are not portable between different wm-s.

majkinetor gravatar imagemajkinetor ( 2014-06-14 22:15:16 +0000 )edit

Question Tools

Stats

Asked: 2013-07-08 18:58:45 +0000

Seen: 2,579 times

Last updated: Jul 13 '13