From dd090a80c94a4ed33e74fa85d178939c96f79b63 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Mon, 11 May 2026 10:48:16 +0300 Subject: [PATCH] usr-local-bin: initial limiting of Thunderbird resources through function --- .../_a-usrlocalbin-functions.bash | 8 ++++++++ bash/usr-local-bin/thunderbird | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bash/usr-local-bin/_a-usrlocalbin-functions.bash b/bash/usr-local-bin/_a-usrlocalbin-functions.bash index 35d1c8f..ba5c904 100755 --- a/bash/usr-local-bin/_a-usrlocalbin-functions.bash +++ b/bash/usr-local-bin/_a-usrlocalbin-functions.bash @@ -9,3 +9,11 @@ _inhibitshutdowncmd() { $@ fi } + +_gigaramhalfcpu() { + if hash systemd-run 2> /dev/null; then + systemd-run --scope --user --property=MemoryHigh=1G --property=CPUQuota=50% $@ + else + $@ + fi +} diff --git a/bash/usr-local-bin/thunderbird b/bash/usr-local-bin/thunderbird index e58850f..36c7b34 100755 --- a/bash/usr-local-bin/thunderbird +++ b/bash/usr-local-bin/thunderbird @@ -6,21 +6,31 @@ # I cannot use the Flatpak as it doesn't support smartcards. set -x + +if [ -f "$HOME/.local/bin/_a-usrlocalbin-functions.bash" ]; then + . $HOME/.local/bin/_a-usrlocalbin-functions.bash +elif [ -f /usr/local/bin/_a-usrlocalbin-functions.bash ]; then + . /usr/local/bin/_a-usrlocalbin-functions.bash +else + echo "Library _a-usrlocalbin-functions.bash not found." + exit 1 +fi + export MOZ_ENABLE_WAYLAND=1 FlagsForThunderbird="--allow-downgrade $@" # Thunderbird (stable, beta) and signatures: https://releases.mozilla.org/pub/thunderbird/releases/ if [ -f ~/.local/thunderbird/thunderbird ]; then - ~/.local/thunderbird/thunderbird $FlagsForThunderbird + gigaramhalfcpu ~/.local/thunderbird/thunderbird $FlagsForThunderbird # Fallback to global installation elif [ -f /usr/bin/thunderbird-wayland ]; then - /usr/bin/thunderbird-wayland $FlagsForThunderbird + gigaramhalfcpu /usr/bin/thunderbird-wayland $FlagsForThunderbird # Fallback to global installation elif [ -f /usr/bin/thunderbird ]; then - /usr/bin/thunderbird $FlagsForThunderbird + gigaramhalfcpu /usr/bin/thunderbird $FlagsForThunderbird # Fallback to flatpak, don't care if it doesn't exist else - flatpak run org.mozilla.Thunderbird $FlagsForThunderbird + gigaramhalfcpu flatpak run org.mozilla.Thunderbird $FlagsForThunderbird fi set +x