How to rework a script made for kdmctl to reboot directly into another OS using lightdm?

Hi,

I am using the following script to reboot directly from openSUSE into Windows:

#!/bin/bash


if kdmctl | grep -q shutdown; then
  IFS=$'	'
  set -- `kdmctl listbootoptions`
  if  "$1" = ok ]; then
    win=$(echo "$2" | tr ' ' '
' | sed -ne 's,\\s, ,g;/windows/I{p;q}')
    echo $win
    if  -n "$win" ]; then
      notify-send "Rebooting in Windows"
      kdmctl shutdown reboot "=$win" ask > /dev/null
    else
      notify-send "Windows boot unavailable."
    fi
  else
    notify-send "Boot options unavailable."
  fi
else
  notify-send "Cannot reboot system."
fi

# Logout
qdbus org.kde.ksmserver /KSMServer logout 0 0 0

But because of a suggestion given in another thread I had to switch to lightdm. Now the script doesn’t work and says “Cannot reboot system.”

How should I rework it in order to make it work with lightdm?

TBH, I highly doubt that lightdm (or any other DM for that matter) supports something similar.

Haven’t read the mentioned thread, but I think it should actually be possible to auto-unlock seahorse with kdm as well.
After all, that’s very probably not done by lightdm, but rather by PAM.
So it should be possible to modify the PAM config to do that with kdm too.

Forgot to write:
You can set an entry to be booted on next reboot via “grub2-once” or “grub2-reboot”. (that’s what kdm does actually)
But that would need root permissions.

Rebooting could be done via “systemctl reboot”, or (better, if you are using Plasma, because it would properly logout too) “qdbus org.kde.ksmserver /KSMServer logout 0 1 1” (the last number doesn’t matter much AFAIK, the second number tells ksmserver whether to logout, reboot, or shutdown)

Thanks wolfi. The solution you gave in the other thread worked better, no script rework necessary! :slight_smile: