Last active
October 8, 2024 20:22
-
-
Save henri/86908fb1e91f07738a1c99c5941ed357 to your computer and use it in GitHub Desktop.
repalce cinnamon (when it springs a memory leak)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# This script may be used when cinnamon springs | |
# a memory leak. Running this script will start | |
# a screen session and run 'cinnamon --replace' | |
# within this new session. | |
# | |
# Presently, this is a script to be run manually. | |
# perhaps in the future a deamon to keep an eye | |
# on memory usage would be a good idea. | |
# | |
# There is already a feature within cinnamon which | |
# is designed do this kind of auto reloading should | |
# the specified momemry limit be exceeded. However, | |
# I have not had this work reliably and hence | |
# the creation of this script to manually spin | |
# a new instance up as required. | |
# | |
# Hopefully, in a future version of cinnamon, this | |
# script will become obsolete. | |
# | |
# You may need to tweek your display settings to | |
# ensure this works for your configuration. | |
# | |
# | |
# (C) 2024 - Henri Shustak | |
# Released under the GNU GPLv3 or later licence : | |
# https://www.gnu.org/licenses/gpl-3.0.en.html | |
# | |
# | |
# | |
# version 1.0 - initial release | |
# | |
# | |
# if DISPLAY is not configured then take a guess - modify as required | |
if [[ -z "${DISPLAY+x}" ]] ; then | |
export DISPLAY=:0 | |
fi | |
# determine the next number we should use for the screen session name which will be running the cinnamon session (maybe this should be a launchd unit)? | |
screen_session_name_prefix="cinnamon-replace-" | |
current_screen_session_number=$(screen -ls | grep cinnamon-replace | awk '{print $1}' | sort -nr | head -n 1 | awk -F "$screen_session_name_prefix" '{print $2}') | |
if [[ "$current_screen_session_number" == "" ]] ; then | |
# no screen session detected - maybe the first time run on this system | |
new_screen_session_number=1 | |
else | |
# there was a session detected - so incriment that by one | |
new_screen_session_number=$(($current_screen_session_number+1)) | |
fi | |
# start a new screen session and replace cinnamon. The old one should just exit | |
new_screen_session_name="${screen_session_name_prefix}${new_screen_session_number}" | |
screen -S "${new_screen_session_name}" -md bash -lc "cinnamon --replace ; sleep 1 ; exit 0" | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment