Skip to content

Instantly share code, notes, and snippets.

@imabuddha
Last active December 17, 2020 04:19
Show Gist options
  • Save imabuddha/85d90acd71c155f08949764cd2cbef68 to your computer and use it in GitHub Desktop.
Save imabuddha/85d90acd71c155f08949764cd2cbef68 to your computer and use it in GitHub Desktop.
Make sure certain processes are terminated on logout — [Raspberry Pi] Requires two script files: one for the user & one for lightdm. This is because it should only kill when the user's session actually ends (not lock screen, etc.).
#! /bin/bash
# This script is for Raspberry pi os (current as of 16 Dec 2020)
# Location for this script: ~/.lightdm-cleanup.sh
#
# Make sure the following user processes are terminated on logout.
# If not terminated cleanly then their services won't operate
# properly when user logs in again (without rebooting).
#
# shairport-sync: with pulseaudio backend can't run shairport-sync as service
# touchegg: gestures won't work after logout/login unless client is killed on logout
#
if [ "$DISPLAY" == ":0" ]
then
pgrep -x shairport-sync | xargs -t kill -1
pgrep -x touchegg | xargs -t kill -1
fi
#! /bin/sh
#
# Location for this script: /usr/local/bin/lightdm_cleanup.sh
#
# Place the following line in /etc/lightdm/lightdm.conf [Seat:*] section:
# session-cleanup-script=/usr/local/bin/lightdm_cleanup.sh
if [ -e $HOME/.lightdm_cleanup.sh ]; then su -c "$HOME/.lightdm_cleanup.sh" $USER; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment