LightDM failing when automounting partition on login

I am following this tutorial on archwiki to automount an encrypted partition on login.

It works fine through the tty but doesn't work with lightDM (I am using i3wm).

This is my /etc/pam_cryptsetup.sh file:

#!/bin/sh

CRYPT_USER="davifah"
MAPPER="/dev/mapper/home-"$CRYPT_USER

if [ "$PAM_USER" == "$CRYPT_USER" ] && [ ! -e $MAPPER ]
then
  tr '\0' '\n' | /usr/bin/cryptsetup open /dev/notevg/homeluks home-$CRYPT_USER
fi

This is my /etc/pam.d/system-login file:

#%PAM-1.0

auth       required   pam_tally2.so        onerr=succeed file=/var/log/tallylog
auth       required   pam_shells.so
auth       requisite  pam_nologin.so
auth       include    system-auth
auth       optional   pam_exec.so expose_authtok /etc/pam_cryptsetup.sh

.....

session    required   pam_env.so
session    optional   pam_exec.so expose_authtok /etc/pam_cryptsetup.sh

This is my lightdm.log from the failed attempt:

[+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log
[+0.00s] DEBUG: Starting Light Display Manager 1.30.0, UID=0 PID=686
[+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
[+0.00s] DEBUG: Registered seat module local
[+0.00s] DEBUG: Registered seat module xremote
[+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager
[+0.00s] DEBUG: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ‘gio-vfs’
[+0.95s] DEBUG: Monitoring logind for seats
[+0.95s] DEBUG: New seat added from logind: seat0
[+0.95s] DEBUG: Seat seat0: Loading properties from config section Seat:*
[+0.95s] DEBUG: Seat seat0: Starting
[+0.95s] DEBUG: Seat seat0: Creating greeter session
[+0.95s] DEBUG: Seat seat0: Creating display server of type x
[+0.95s] DEBUG: posix_spawn avoided (fd close requested) 
[+0.96s] DEBUG: Could not run plymouth --ping: Failed to execute child process “plymouth” (No such file or directory)
[+0.96s] DEBUG: Using VT 7
[+0.96s] DEBUG: Seat seat0: Starting local X display on VT 7
[+0.96s] DEBUG: XServer 0: Logging to /var/log/lightdm/x-0.log
[+0.96s] DEBUG: XServer 0: Writing X server authority to /run/lightdm/root/:0
[+0.96s] DEBUG: XServer 0: Launching X Server
[+0.96s] DEBUG: Launching process 704: /usr/bin/X :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
[+0.96s] DEBUG: XServer 0: Waiting for ready signal from X server :0
[+0.96s] DEBUG: Acquired bus name org.freedesktop.DisplayManager
[+0.96s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat0
[+0.96s] WARNING: Error getting user list from org.freedesktop.Accounts: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Accounts was not provided by any .service files
[+0.96s] DEBUG: Loading user config from /etc/lightdm/users.conf
[+0.96s] DEBUG: User davifah added
[+0.96s] DEBUG: posix_spawn avoided (automatic reaping requested) (fd close requested) 
[+2.45s] DEBUG: Got signal 10 from process 704
[+2.45s] DEBUG: XServer 0: Got signal from X server :0
[+2.45s] DEBUG: XServer 0: Connecting to XServer :0
[+2.50s] DEBUG: posix_spawn avoided (fd close requested) (child_setup specified) 
[+2.50s] DEBUG: Seat seat0: Display server ready, starting session authentication
[+2.50s] DEBUG: Session pid=722: Started with service 'lightdm-greeter', username 'lightdm'
[+2.53s] DEBUG: Session pid=722: Authentication complete with return value 0: Success
[+2.53s] DEBUG: Seat seat0: Session authenticated, running command
[+2.53s] DEBUG: Session pid=722: Running command /usr/bin/lightdm-gtk-greeter
[+2.53s] DEBUG: Creating shared data directory /var/lib/lightdm-data/lightdm
[+2.53s] DEBUG: Session pid=722: Logging to /var/log/lightdm/seat0-greeter.log
[+2.69s] DEBUG: Activating VT 7
[+2.69s] DEBUG: Activating login1 session c1
[+2.70s] DEBUG: Seat seat0 changes active session to c1
[+2.70s] DEBUG: Session c1 is already active
[+2.91s] DEBUG: Greeter connected version=1.30.0 api=1 resettable=false
[+3.02s] DEBUG: Greeter start authentication for davifah
[+3.02s] DEBUG: Session pid=767: Started with service 'lightdm', username 'davifah'
[+3.04s] DEBUG: Session pid=767: Got 1 message(s) from PAM
[+3.04s] DEBUG: Prompt greeter with 1 message(s)
[+6.87s] DEBUG: Seat seat0 changes active session to 
[+16.20s] DEBUG: Seat seat0 changes active session to 2
[+21.74s] DEBUG: Seat seat0 changes active session to 
[+24.24s] DEBUG: Seat seat0 changes active session to c1
[+24.24s] DEBUG: Session c1 is already active
[+27.38s] DEBUG: Continue authentication
[+27.45s] DEBUG: Session pid=767: Authentication complete with return value 0: Success
[+27.45s] DEBUG: Authenticate result for user davifah: Success
[+27.45s] DEBUG: User davifah authorized
[+27.45s] DEBUG: Greeter requests session i3
[+27.45s] DEBUG: Seat seat0: Stopping greeter; display server will be re-used for user session
[+27.45s] DEBUG: Terminating login1 session c1
[+27.46s] DEBUG: Session pid=722: Sending SIGTERM
[+27.46s] DEBUG: Greeter closed communication channel
[+27.47s] DEBUG: Session pid=722: Exited with return value 0
[+27.47s] DEBUG: Seat seat0: Session stopped
[+27.47s] DEBUG: Seat seat0: Greeter stopped, running session
[+27.47s] DEBUG: Registering session with bus path /org/freedesktop/DisplayManager/Session0
[+27.47s] DEBUG: posix_spawn avoided (fd close requested) (child_setup specified) 
[+27.47s] DEBUG: Session pid=767: Running command /etc/lightdm/Xsession i3
[+27.47s] DEBUG: Creating shared data directory /var/lib/lightdm-data/davifah
[+27.47s] DEBUG: Session pid=767: Logging to .xsession-errors
[+27.54s] DEBUG: Activating VT 7
[+27.54s] DEBUG: Activating login1 session 4
[+27.54s] DEBUG: Seat seat0 changes active session to 
[+27.54s] DEBUG: Seat seat0 changes active session to 4
[+27.54s] DEBUG: Session 4 is already active
[+27.54s] DEBUG: Session pid=767: Exited with return value 1
[+27.54s] DEBUG: Seat seat0: Session stopped
[+27.54s] DEBUG: Seat seat0: Stopping display server, no sessions require it
[+27.54s] DEBUG: Sending signal 15 to process 704
[+28.16s] DEBUG: Process 704 exited with return value 0
[+28.16s] DEBUG: XServer 0: X server stopped
[+28.16s] DEBUG: Releasing VT 7
[+28.16s] DEBUG: XServer 0: Removing X server authority /run/lightdm/root/:0
[+28.16s] DEBUG: Seat seat0: Display server stopped
[+28.16s] DEBUG: Seat seat0: Active display server stopped, starting greeter
[+28.16s] DEBUG: Seat seat0: Creating greeter session
[+28.16s] DEBUG: Seat seat0: Creating display server of type x
[+28.16s] DEBUG: Using VT 7
[+28.16s] DEBUG: Seat seat0: Starting local X display on VT 7
[+28.16s] DEBUG: XServer 0: Logging to /var/log/lightdm/x-0.log
[+28.16s] DEBUG: XServer 0: Writing X server authority to /run/lightdm/root/:0
[+28.16s] DEBUG: XServer 0: Launching X Server
[+28.16s] DEBUG: Launching process 831: /usr/bin/X :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
[+28.16s] DEBUG: XServer 0: Waiting for ready signal from X server :0
[+29.07s] DEBUG: Got signal 10 from process 831
[+29.07s] DEBUG: XServer 0: Got signal from X server :0
[+29.07s] DEBUG: XServer 0: Connecting to XServer :0
[+29.12s] DEBUG: posix_spawn avoided (fd close requested) (child_setup specified) 
[+29.13s] DEBUG: Seat seat0: Display server ready, starting session authentication
[+29.13s] DEBUG: Session pid=847: Started with service 'lightdm-greeter', username 'lightdm'
[+29.14s] DEBUG: Session pid=847: Authentication complete with return value 0: Success
[+29.14s] DEBUG: Seat seat0: Session authenticated, running command
[+29.14s] DEBUG: Session pid=847: Running command /usr/bin/lightdm-gtk-greeter
[+29.14s] DEBUG: Creating shared data directory /var/lib/lightdm-data/lightdm
[+29.14s] DEBUG: Session pid=847: Logging to /var/log/lightdm/seat0-greeter.log
[+29.15s] DEBUG: Activating VT 7
[+29.15s] DEBUG: Activating login1 session c2
[+29.16s] DEBUG: Seat seat0 changes active session to c2
[+29.16s] DEBUG: Session c2 is already active
[+29.22s] DEBUG: Greeter connected version=1.30.0 api=1 resettable=false
[+29.27s] DEBUG: Greeter start authentication for davifah
[+29.27s] DEBUG: Session pid=861: Started with service 'lightdm', username 'davifah'
[+29.27s] DEBUG: Session pid=861: Got 1 message(s) from PAM
[+29.27s] DEBUG: Prompt greeter with 1 message(s)
[+31.13s] DEBUG: Seat seat0 changes active session to 2

Forum kindly sponsored by