I have been looking for a way to start some custom apps when I login to my session in LightDM. So far, I have found two different ways:

1. Customise .xinitrc: For example, if I want to add a terminal window whenever I start the X server, I would only have to add xterm -geometry 80x50+494+51 & before exec awesome.

2. Add some apps to rc.lua: as seen here, the applications would start when AwesomeWM starts.

The methods are clear, but I have found a problem which made me think of what option would be better.

The first way would only work if I explicitly type startx in a TTY. Starting the X server without that command (for example, turning on the computer normally) will not start the applications. So how could I prevent this from happening?

The main question here, though, is: in case I can make .xinitrc work, would it be a 'better' (in terms of efficiency and specially security) way to proceed than editing my own copy of rc.lua?

3 Answers 3


I believe that AwesomeWM autorun programs are better when done well

Why = If you exit one of your autorun *always" programs and want to restart them you (a) restart X [closing everything in the process], (b) relaunch them from a shell [output messages now go to that shell], (c) create special re-launch code in rc.lua [on top of the launch code you put in .xinitrc

How = This works well for me... a) As soon after the debug lines in rc.lua add...

    local gears         = { table   = require( "gears.table" )          ,
                            p_call  = require( "gears.protected_call" ) }

    gears.p_call( dofile, path_this .. "runonce.lua" )

b) And here's the "when done well" part (IMHO) that is in runonce.lua...

    local naughty   = require( "naughty" )
    local awful     = { spawn = require( "awful.spawn" ) }
    local string    = { sub = string.sub        ,
                        find = string.find      ,
                        format = string.format  }

    -- This function makes sure the application is not restarted when awesome is reloaded
    local function run_once( command )
        local args_start = string.find( command, " " )
        local pgrep_name = args_start and command:sub( 0, args_start - 1 ) or command

        local command = "pgrep -u $USER -x " .. pgrep_name .. " > /dev/null || (" .. command .. ")"

            function( stdout, stderr, exitreason, exitcode )
                if exitcode ~= 0 then
                        preset  = naughty.config.presets.critical           ,
                        text    = string.format(    "%s\n\n%s\n%s\n%s\n%s", 
                                                    exitcode )              })
            end )

    -- Start these if not already running
    run_once( "guake &> /dev/null" )
    run_once( "remmina -i &> /dev/null" )
    run_once( "skypeforlinux" )

Why I believe it is done well...

1) Works with programs that have parameters [only searches for the name, not the args] 2) Has an alert if things go wrong [without killing Awesome] 3) Only edit the bottom section

Finally... mod+ctrl+r reloads awesome [nothing really changes, just resets memmory] and of course the apps you always want are re-launched exactly the same way they were the first time


Update 2018:

Using the XDG autostart is still the standard compliant way to do this. However Awesome v4.3 adds a new awful.spawn.once function which takes care of saving the application "single instance" property directly in the X server. This allows the spawn to be called multiple time while being executed only once. It works across restart.


The best is to implement the XDG autostart protocol. It is usually about adding files to ~/.config/autostart then having a script or a daemon take care of starting the apps. This script or daemon is then either started by the session manager or from .xinitrc.

rc.lua should not be used for Autostart as it can be restarted at random time (mod4+ctrl+r) and re-execute everything. Some users have elaborate systems to detect if something has already been launched, but in my opinion it's not worth it.

The second best way is directly from .xinitrc.


I have a very simple script named /usr/local/bin/awesome_run_once:


pgrep $@ > /dev/null || ($@ &)

At the end of my ~/.config/awesome/rc.lua, I add some calls to it with the app I want to run:

-- auto start programs
awful.util.spawn("awesome_run_once wicd-client")
awful.util.spawn("awesome_run_once redshift")
awful.util.spawn("awesome_run_once nextcloud")

Works fine enough.

I got this idea from Autostart - awesome but the page doesn't seem to be online anymore...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.