Compare commits

...

2 Commits

Author SHA1 Message Date
Icedream a0920a6f87
Only attempt to disable service if still installed. 2025-05-22 15:19:30 +02:00
Icedream 656e6c9d27
Remove tweak-cpu-usage script.
This reverts commit 1c9bbb7559.
2025-05-22 15:15:52 +02:00
4 changed files with 23 additions and 51 deletions

View File

@ -1,10 +0,0 @@
[Unit]
Description=Tweak CPU usage
[Service]
Type=simple
ExecStart=%h/.local/bin/tweak-cpu-usage
Restart=on-failure
[Install]
WantedBy=default.target

View File

@ -1,36 +0,0 @@
#!/bin/bash
set -e
set -u
cores=$(nproc)
limits=(
# process_name:limit%
firefox:$(( 50 * cores ))
vesktop:$(( 20 * cores ))
)
# check for cpulimit command
if ! command -v cpulimit 2>/dev/null >/dev/null; then
echo "ERROR: need cpulimit command" >&2
exit 1
fi
limit_process() {
local process_name="$1"
local limit_percentage="${2%%.}"
cpulimit -i -e "$process_name" -l "$limit_percentage"
}
limit_processes() {
local pids
pids=()
for limit in "${limits[@]}"; do
IFS=: read process_name limit_percentage <<<"$limit"
limit_process "$process_name" "$limit_percentage" & pids+=($!)
done
wait "${pids[@]}"
}
limit_processes

View File

@ -53,6 +53,24 @@ install_files() {
done done
} }
remove_file() {
local path="$1" sha256hash="${2:-}"
if [ -n "${sha256hash}" ]; then
if ! check_file "${path}" "${sha256hash}"; then
return
fi
fi
rm -v "$path"
}
check_file() {
local path="$1" sha256hash="${2:-}"
if [ ! -f "$path" ]; then
return
fi
sha256sum -c - <<< "${sha256hash} ${path}" >/dev/null 2>/dev/null
}
### ###
install_files "${HOME}" home install_files "${HOME}" home
@ -63,9 +81,11 @@ if command -v fc-cache >/dev/null 2>&1; then
fi fi
if command -v systemctl >/dev/null 2>&1; then if command -v systemctl >/dev/null 2>&1; then
systemctl --user daemon-reload if check_file "${HOME}/.config/systemd/user/tweak-cpu-usage.service" 6abf4488aa268b0171cb400270e2531c8fb067ebe8216c72d337f8c056952f9e; then
systemctl --user enable tweak-cpu-usage systemctl --user disable tweak-cpu-usage || true
systemctl --user restart tweak-cpu-usage remove_file "${HOME}/.config/systemd/user/tweak-cpu-usage.service"
fi
remove_file "${HOME}/.local/bin/tweak-cpu-usage" 7da1938cdf78e583140638848f8bf8a268c2710e4fa3462bca8373e438d67491
fi fi
# KDE 6 # KDE 6

View File

@ -111,7 +111,6 @@ if has_tags pm:pacman; then
# from here on we should have yay available # from here on we should have yay available
yay_install \ yay_install \
bat \ bat \
cpulimit \
customizepkg-git \ customizepkg-git \
zsh \ zsh \
zsh-syntax-highlighting \ zsh-syntax-highlighting \
@ -156,7 +155,6 @@ if has_tags pm:apt; then
zsh \ zsh \
zsh-syntax-highlighting \ zsh-syntax-highlighting \
bat \ bat \
cpulimit \
jq \ jq \
git \ git \
gnupg2 gnupg2