Skip to content

Instantly share code, notes, and snippets.

@Fire-Dragon-DoL
Forked from abraithwaite/chill-zoom.sh
Last active June 29, 2023 14:51
Show Gist options
  • Save Fire-Dragon-DoL/e0adaeba76e872ad70e50c9469900f1d to your computer and use it in GitHub Desktop.
Save Fire-Dragon-DoL/e0adaeba76e872ad70e50c9469900f1d to your computer and use it in GitHub Desktop.
FEDORA version - Zoom in Systemd Cgroups on Linux. Change the max allocations to fit your workstation.
#!/usr/bin/env bash
# throttle-zoom '0-1' '6G'
set -xe
main() (
allowedCpus="${1?Missing allowed CPUs, ex: 0-4}"
maxMemory="${2?Missing max memory, ex: 6G}"
# Add parameter checks to avoid invalid values here
mkdir -p "${XDG_CONFIG_HOME}/systemd/user"
{
printf '[Slice]\n'
printf 'AllowedCPUs=%s\n' "${allowedCpus}"
printf 'MemoryHigh=%s\n' "${maxMemory}"
} > "${XDG_CONFIG_HOME}/systemd/user/zoom.slice"
awk '{
if ($0 ~ /^Exec=/)
print "Exec=/usr/bin/systemd-run --user --slice=zoom.slice /usr/bin/zoom %U";
else
print;
}' < /usr/share/applications/Zoom.desktop > "${HOME}/.local/share/applications/Zoom.desktop"
update-desktop-database ~/.local/share/applications
)
main "$@"
echo "========== RESULT ========="
cat "${XDG_CONFIG_HOME}/systemd/user/zoom.slice"
echo "========== DESKTOP ========="
cat "${HOME}/.local/share/applications/Zoom.desktop"
ln -s "${HOME}/.local/share/applications/Zoom.desktop" "${XDG_CONFIG_HOME}/autostart/Zoom.desktop"
#!/usr/bin/bash -xe
cat <<EOF > "${HOME}/.config/systemd/user/zoom.slice"
[Slice]
AllowedCPUs=0-4
MemoryHigh=6G
EOF
cat /usr/share/applications/Zoom.desktop | sed -E 's#^(Exec=).*$#Exec=/usr/bin/systemd-run --user --slice=zoom.slice /opt/zoom/ZoomLauncher#' > "${HOME}/.local/share/applications/Zoom.desktop"
update-desktop-database ~/.local/share/applications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment