Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Debian 11 mate user logout script [SOLVED]

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
user21345
Posts: 9
Joined: 2021-12-18 08:30
Has thanked: 1 time

Debian 11 mate user logout script [SOLVED]

#1 Post by user21345 »

Hello,

I spent quite some time on this and found a lot of stuff on the internet but nothing worked with Debian 11 / Mate so far.

What I need is to run a script when the user logs out. Similar to the "Control Center" -> "Startup Applications" but not at login but at logoff time. How do I do that?

And I do need it for user session logout and not system shutdown. I have that part covered easily with a systemd entry.

Kind Regards,
Hugo
Last edited by user21345 on 2022-01-22 14:18, edited 1 time in total.

peer
Posts: 441
Joined: 2017-03-26 10:14
Has thanked: 7 times
Been thanked: 19 times

Re: Debian 11 mate user logout script

#2 Post by peer »

I have used a shutdown/reboot/logout script on debian 11. It checkes if a vm is running. You can shutdown if there are no vm's running.
The script uses kdialog.

Code: Select all

#!/bin/bash

# check if VM's are running 
# shutdown only if there are no VM's running
# vmCount is number of running vm's
vmCount=$(pgrep -c qemu-system-x86)

if [ $vmCount -gt 0 ] # VM's are running
then
  vmText="Unable to Shutdown/Reboot!\n\nVM's must be closed before Shutdown/Reboot/Logout."
  kdialog --title "Shutdown" --msgbox "$vmText"
  exit # no shutdown
fi

#shutdown
var=$(/usr/bin/kdialog --geometry 275x185+850+500 --radiolist "Shutdown/Reboot/Logout" 1 "\
                      Shutdown" on  2  "                      Reboot" off  3  "                      Logout" off)
varButton=$?

case $var in
  1)
  systemctl poweroff
  ;;
  2)
  systemctl reboot
  ;;
  3)
  userName=$(whoami)
  echo $userName
  pkill -KILL -u $userName
  ;;
esac
Perhaps this gives you a starting point.

user21345
Posts: 9
Joined: 2021-12-18 08:30
Has thanked: 1 time

Re: Debian 11 mate user logout script

#3 Post by user21345 »

Hi Peer,

thank you for your reply but I am not looking for a script, I am looking for a place to start my script when a user logs out (so not system shutdown).

I was using Centos and Gnome 2 before it was rendered unusable with version 3 and then Mate which was basically identical. I was using /etc/gdm/PostSession/Default for that purpose. But now after changing to Debian with Mate this script does not exist anymore (why do people keep changing things all the time? Do they have any idea how much of the users time they are wasting?) .

Would you know where to look? Even with the GUI interface for "Start applications" I could not figure out where this application start is happening (this mechanism reminds me a bit of windows; never used GUIs for that reason). Any ideas?

Kind Regards,
Hugo

user21345
Posts: 9
Joined: 2021-12-18 08:30
Has thanked: 1 time

Re: Debian 11 mate user logout script

#4 Post by user21345 »

Hello,

I found the solution here: https://ubuntuforums.org/showthread.php?t=1918649

You have to edit the /etc/lightdm/lightdm.conf file, setting 'session-cleanup-script' can be set to any script you want to run when the user logs out. Works also when you do not shut down the system.

Kind Regards,
Hugo
.

Post Reply