You can do that through a script which uses the commandline DCOP client dcop
If you need it to work when more than one user is logged in, you have to run it as root and use --all-users --all-sessions switched
The target application is ksmserver, the target interface also ksmserver
For example (single user, single session, executed as that user)
#> dcop ksmserver ksmserver saveCurrentSession
#> dcop ksmserver ksmserver logout 0 2 0
Where 0 2 0 are values from
http://developer.kde.org/documentation/l…pplication.html
0 (NoConfirm), 2 (ForceNow), 0 (Type None = just logout)
Cheers,
_