Search code examples
configurationstartupi3

i3wm | Open application on startup if not in weekend


I'm trying to configure i3 so that an application is opened only on working days. I understand that exec can be used to launch apps on startup as in
exec --no-startup-id telegram-desktop
However after reading and trying differents things I'm not getting how to use exec correctly.

For the moment I have this (which does not work):
exec --no-startup-id 'test $(date +%u) -lt 6 && slack'

The command itself works, since the following binding works:
bindsym $mod+i exec "test $(date +%u) -lt 6 && slack"


Solution

  • Try

    exec --no-startup-id test $(date +%u) -lt 6 && slack
    

    or

    exec --no-startup-id "test $(date +%u) -lt 6 && slack"
    

    Explanation

    i3 only uses double quotes (") for quoting and does not handle single quotes (') in any way. This means that the whole string 'test $(date +%u) -lt 6 && slack' - including the quotes - gets passed to /bin/sh for execution. That means /bin/sh will look for a command with the name test $(date +%u) -lt 6 && slack instead of parsing it into a command line that start with the command test.