pop-os / cosmic-session

Session manager for the COSMIC desktop environment
GNU General Public License v3.0
74 stars 23 forks source link

Log out of the COSMIC using dbus #70

Closed vikdevelop closed 2 months ago

vikdevelop commented 2 months ago

Hello, I'm programming the SaveDesktop app, and I have a problem with logging out of the system using dbus. For example, in KDE6 is available this command: dbus-send --print-reply --dest=org.kde.LogoutPrompt /LogoutPrompt org.kde.LogoutPrompt.promptLogout, but what command is available for COSMIC?

wiiznokes commented 2 months ago

Here is a script I use, it should be useful to you

#!/bin/bash

set -e

if [[ -z "$DESKTOP_SESSION" ]]; then
    echo 'Error: DESKTOP_SESSION is not defined'
    exit 1
elif [[ "$DESKTOP_SESSION" == "plasma" ]]; then
    dbus-send --session --dest=org.kde.Shutdown --type=method_call /Shutdown org.kde.Shutdown.logout
elif [[ "$DESKTOP_SESSION" == "gnome" ]]; then
    gnome-session-quit --no-prompt
elif [[ "$DESKTOP_SESSION" == "gnome-xorg" ]]; then
    gnome-session-quit --no-prompt
elif [[ "$DESKTOP_SESSION" == "cosmic" ]]; then
    dbus-send --session --dest=com.system76.CosmicSession --type=method_call /com/system76/CosmicSession com.system76.CosmicSession.Exit
else
    loginctl terminate-user "{USER}"
fi

echo "Closing $DESKTOP_SESSION session..."
exit 0
vikdevelop commented 2 months ago

The provided command for the logging out of the COSMIC desktop works correctly. Thanks :)