Bar not appearing after changing display manager

I changed the display manager from ly to SDDM and the bar is not loading.

Error message on the console:

thread 'main' panicked at 'Failed to create x11 connection: FailedToConnect', /home/zexu/.cargo/registry/src/
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

There is a critical difference between the two.
LY executes/uses $HOME/.xinitrc, if it exists, or /etc/X11/xinit/xinitrc.
SDDM does not use .xinitrc, but .xprofile.

Something that exists in your .xinitrc file, needs to be copied/pasted in .xprofile (create this, if it does not exist).

Also, read about how dwm uses dot files, and how xinit/xprofile work, to have a better idea for the solution you need.