I’m trying to make a script which stops the display manager service, starts it again, and then launches an application. The problem is that no matter what I try I can’t launch any applications after starting the display manager service. I believe that the environment variables related to the xsession are not being given to the running script, and so the applications fail to run.
My current script is this:
#!/usr/bin/env bash
stage=0
if [[ $# -gt 0 ]]; then
stage=$1
fi
if [[ $stage -eq 0 ]]; then
# switches to root since user scripts seem to be killed when the display manager service is stopped
sudo -b windows 1
fi
if [[ $stage -eq 1 ]]; then
systemctl stop display-manager.service
systemctl start display-manager.service
# sleep to give me time to log into sddm
sleep 25
# switch back to user
sudo -u cowsociety -b windows 2
fi
if [[ $stage -eq 2 ]]; then
firefox &> /home/cowsociety/Documents/log.txt
fi
the log file:
Authorization required, but no authorization protocol specified
Error: cannot open display: :0