You are not logged in.

#1 2020-06-17 20:53:08

hussam
Member
Registered: 2006-03-26
Posts: 572
Website

script to close gdm's gnome-shell session when unneeded.

At the moment, gdm exits the "extra" gnome-shell session used by gdm when running on Wayland. For people running Xorg, for nvidia GPUs for example, there is an extra gnome-shell taking up memory.
In addition, gdm has another issue where gdm workers do not exit correctly after cancelling unlock or login.
I wrote two scripts that can run as cron jobs to help with those issues. Feedback and fixes are appreciated as I am sure I missed some cases.

This script kills gdm session if it is not the active session. it also does not kill gdm if you are logged onto root on tty. I safely run this using cron every minute.

#!/bin/bash

KillGdmSession() {
    if [[ $( loginctl show-session `loginctl show-user gdm| grep Sessions | sed -e 's/Sessions=//g' ` --property Active | grep "Active=no" ) ]] ; then loginctl terminate-user gdm; fi
}

if [[ $(/usr/bin/users | sed -e 's/root//g' ) ]]; then
    if [[ $( loginctl list-sessions --no-legend | grep " 120 gdm "  ) ]]; then
        KillGdmSession;
    fi;
fi

This script attempts to identify the stale processes. I run this using cron every hour.

#!/bin/bash
for workerprocess in `pgrep -u root gdm-session-wor`
    do if [[ ! $(pgrep -P $workerprocess) ]]; then
          _RUNNINGTIME=$(  ps -p $workerprocess -o etimes | grep -v ELAPSED )
          if [ $_RUNNINGTIME -gt 300 ]
	  then 
	       kill $workerprocess
	  fi
       fi
done

Offline

Board footer

Powered by FluxBB