-
-
Save abraithwaite/1d78a946f90be478faedb5ca4db6d62e to your computer and use it in GitHub 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 |
The *.desktop
files are not supposed to be executed.
They should be used by your desktop to open applications.
Ex: in gnome, press Super
key, the activities view opens. Type the name of the app and a shortcut appears. The available apps are found by gnome using the *.desktop
files, the icon you see in the activities view is the icon referenced in the Icon=
line of the file etc...
The script changes the Exec=
line to change the code that is executed by your desktop when running the application.
I don't know what desktop you are using but the standard way of opening applications with it should rely on this mechanism.
is that systemd service or sum?
Thanks for this little script! For convenience I needed to append %U
to the Exec line, like this:
Exec=/usr/bin/systemd-run --user --slice=zoom.slice /opt/zoom/ZoomLauncher %U
This solved issues with KDE's KIO system and facilitates joining meetings with fully-qualified URLs that include e.g. password keys (format https://....zoom.us/j/12345678?pwd=MeetingPasswordHash
)
I stumbled across this in a search to solve why Zoom consumes 150% of my 12 CPU cores when running, and it looked like it would solve the problem by constraining the memory and CPUs.
Unfortunately, this does not work if your Zoom session requires you to log in, or uses SSO or is tied to a company domain, which many to most would be (yes, even when passing %U
at the end, as in the previous reply above this one).
Once that happens, you're stuck in an endless loop of systemd running the Zoom client unauthorized, prompting for auth using the browser, which then launches a new instance of Zoom (unauthorized), and round-and-round we go, never actually saving the login credentials or passing them to the Zoom client.
I'm back on the hunt for other solutions...
@desrod hey I think @brightonanc and I found a workaround for this. If you replace the exec line in ${HOME}/.local/share/applications/Zoom.desktop
with
Exec=systemd-run --scope -p MemoryMax=4G -p MemoryHigh=2G -p MemorySwapMax=0 -p CPUQuota=25%% --user -- /usr/bin/zoom %U
Then it should work with SSO and limit RAM and CPU cores.
I think code is not polished for the Flatpak version of Zoom which probably makes little sense because most people are gonna run Zoom under some kind of isolation aspect such as Flatpak or Docker. The code did run successfully thanks to @quilicicf's amendments and it made a separate .desktop as
~/.local/share/applications/Zoom.desktop
I gave it execute permissions bychmod +x ~/.local/share/applications/Zoom.desktop
but the result of./Zoom.desktop
inside of that directory gives the following result.This is how the .desktop file looks inside Vim, is this expected behavior?
Edit: I am using Arch Linux, installed Flatpak through Pacman.