From 5bedccede38b5b0e2e5b381b43370507803b81bf Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Sun, 30 Aug 2026 22:18:35 +0200 Subject: [PATCH] scripts: add plasma start/kill scripts... ...and some other useful things, too --- dot-local/bin/hyprconfig | 28 +---- dot-local/bin/hyprconfig.bash | 19 +++ dot-local/bin/hyprconfig.fish | 9 ++ dot-local/bin/kde-xxxx-plasmashell | 6 + dot-local/bin/kdedown | 3 + dot-local/bin/kdeup | 3 + dot-local/bin/prefcore-v3 | 45 +++++++ dot-local/bin/run_after_noctalia.sh | 4 +- dot-local/bin/upgrayyedd | 179 ++++++++++++++++++---------- dot-local/bin/wl-freeze | 1 + 10 files changed, 204 insertions(+), 93 deletions(-) mode change 100755 => 120000 dot-local/bin/hyprconfig create mode 100755 dot-local/bin/hyprconfig.bash create mode 100755 dot-local/bin/hyprconfig.fish create mode 100755 dot-local/bin/kde-xxxx-plasmashell create mode 100755 dot-local/bin/kdedown create mode 100755 dot-local/bin/kdeup create mode 100755 dot-local/bin/prefcore-v3 create mode 120000 dot-local/bin/wl-freeze diff --git a/dot-local/bin/hyprconfig b/dot-local/bin/hyprconfig deleted file mode 100755 index ba977b2..0000000 --- a/dot-local/bin/hyprconfig +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -EDITOR=kak - -CONFS=(hyprland hypridle hyprlauncher hyprlock hyprpaper hyprqt6engine noctalia/noctalia-colors) - -mapfile -d '' FRAGMENTS < <( find "$HOME/.config/hypr/fragments" -maxdepth 1 -type f -print0 ) -# mapfile -d '' FRAGMENTS < <( find "$HOME/.config/hypr/scripts" -maxdepth 1 -type f -print0 ) - -ALLFILES=() -for conf in "${CONFS[@]}"; do - ALLFILES+=("$HOME/.config/hypr/${conf}.conf") -done - -for fragment in "${FRAGMENTS[@]}"; do - ALLFILES+=("${fragment}") -done - -# for script in "${SCRIPTS[@]}"; do -# ALLFILES+=("${script}") -# done - -"$EDITOR" "${ALLFILES[@]}" - -# echo "BASH_VERSION=$BASH_VERSION" -# declare -p ALLFILES - diff --git a/dot-local/bin/hyprconfig b/dot-local/bin/hyprconfig new file mode 120000 index 0000000..1c87970 --- /dev/null +++ b/dot-local/bin/hyprconfig @@ -0,0 +1 @@ +hyprconfig.fish \ No newline at end of file diff --git a/dot-local/bin/hyprconfig.bash b/dot-local/bin/hyprconfig.bash new file mode 100755 index 0000000..bd45ec8 --- /dev/null +++ b/dot-local/bin/hyprconfig.bash @@ -0,0 +1,19 @@ +#!/bin/bash + +dirs=( + "$HOME/.config/hypr/" + "$HOME/.config/hypr/fragments/" +) + +files=() + +for dir in "${dirs[@]}"; do + while IFS= read -r -d '' file; do + files+=("$file") + done < <(find "$dir" -maxdepth 1 -type f -name '*.lua' -print0) +done + +printf '%q\n' "${files[@]}" + +kak "${files[@]}" + diff --git a/dot-local/bin/hyprconfig.fish b/dot-local/bin/hyprconfig.fish new file mode 100755 index 0000000..663085d --- /dev/null +++ b/dot-local/bin/hyprconfig.fish @@ -0,0 +1,9 @@ +#!/bin/fish + +set files \ + (find ~/.config/hypr/ -maxdepth 1 -type f -name '*.lua') \ + (find ~/.config/hypr/fragments -maxdepth 1 -type f -name '*.lua')\ + (find ~/.config/hypr/noctalia/ -maxdepth 1 -type f -name '*.lua') + +kak $files + diff --git a/dot-local/bin/kde-xxxx-plasmashell b/dot-local/bin/kde-xxxx-plasmashell new file mode 100755 index 0000000..a87fe71 --- /dev/null +++ b/dot-local/bin/kde-xxxx-plasmashell @@ -0,0 +1,6 @@ +#!/bin/sh + +killall plasma_session +killall plasma-shell +killall plasma-shutdown + diff --git a/dot-local/bin/kdedown b/dot-local/bin/kdedown new file mode 100755 index 0000000..b81a092 --- /dev/null +++ b/dot-local/bin/kdedown @@ -0,0 +1,3 @@ +#!/bin/sh + +openrc -U default diff --git a/dot-local/bin/kdeup b/dot-local/bin/kdeup new file mode 100755 index 0000000..3b5a48b --- /dev/null +++ b/dot-local/bin/kdeup @@ -0,0 +1,3 @@ +#!/bin/sh + +openrc -U desktop diff --git a/dot-local/bin/prefcore-v3 b/dot-local/bin/prefcore-v3 new file mode 100755 index 0000000..15bdb0b --- /dev/null +++ b/dot-local/bin/prefcore-v3 @@ -0,0 +1,45 @@ +#!/bin/sh + +ccd0_sum=0 +ccd1_sum=0 + +echo "CCD0:" +i=0 +while [ "$i" -lt 8 ]; do + perf=$(cat "/sys/devices/system/cpu/cpu$i/acpi_cppc/highest_perf") + printf "cpu%-2d %s\n" "$i" "$perf" + ccd0_sum=$((ccd0_sum + perf)) + i=$((i + 1)) +done + +echo +echo "CCD1:" +i=8 +while [ "$i" -lt 16 ]; do + perf=$(cat "/sys/devices/system/cpu/cpu$i/acpi_cppc/highest_perf") + printf "cpu%-2d %s\n" "$i" "$perf" + ccd1_sum=$((ccd1_sum + perf)) + i=$((i + 1)) +done + +ccd0_avg=$((ccd0_sum / 8)) +ccd1_avg=$((ccd1_sum / 8)) + +echo +printf "CCD0 average highest_perf: %d\n" "$ccd0_avg" +printf "CCD1 average highest_perf: %d\n" "$ccd1_avg" + +echo + +if [ "$ccd0_sum" -lt "$ccd1_sum" ]; then + echo "Slower CCD: CCD0" + echo "BUILD_CPUS=0-7,16-23" + echo "FAST_CPUS=8-15,24-31" +elif [ "$ccd1_sum" -lt "$ccd0_sum" ]; then + echo "Slower CCD: CCD1" + echo "BUILD_CPUS=8-15,24-31" + echo "FAST_CPUS=0-7,16-23" +else + echo "Both CCDs have identical aggregate highest_perf values." +fi + diff --git a/dot-local/bin/run_after_noctalia.sh b/dot-local/bin/run_after_noctalia.sh index cf64c53..059f5fc 100755 --- a/dot-local/bin/run_after_noctalia.sh +++ b/dot-local/bin/run_after_noctalia.sh @@ -1,13 +1,13 @@ #!/bin/bash -qs -c noctalia-shell > /dev/null 2>&1 & +qs -c noctalia > /dev/null 2>&1 & while ! pgrep -x qs >/dev/null; do sleep 1 done sleep 5; -qs -c noctalia-shell ipc call wallpaper random all +# qs -c noctalia-shell ipc call wallpaper random all nextcloud > /dev/null 2>&1 & qtpass > /dev/null 2>&1 & diff --git a/dot-local/bin/upgrayyedd b/dot-local/bin/upgrayyedd index 53077a6..1db7d1f 100755 --- a/dot-local/bin/upgrayyedd +++ b/dot-local/bin/upgrayyedd @@ -1,40 +1,73 @@ #!/bin/bash -#make sure we're running gentoo -grep -i gentoo /etc/os-release || exit +PORTAGE_CPUS="8-15,24-31" +BUILD_CGROUP="/sys/fs/cgroup/openrc.portage-cgroup" -declare precmd -if [[ $(id -u) -ne 0 ]]; -then - precmd="sudo" -else - precmd="" -fi +# make sure we're root +root_check(){ + if [ "$(id -u)" -ne 0 ];then + echo "" + echo "You have to run this script with sudo" + exit 0 + fi +} + +pin_to_ccd0() { + taskset -pc "$PORTAGE_CPUS" $$ >/dev/null || { + echo "CPU affinity konnte nicht gesetzt werden" + exit 1 + } +} + +ccd_emerge() { + taskset -c "$PORTAGE_CPUS" /usr/bin/emerge "$@" +} + +ccd_make() { + taskset -c "$PORTAGE_CPUS" schedtool -D -e make "$@" +} + +run_in_portage_cgroup () { + ( + echo "$BASHPID" > "$BUILD_CGROUP/cgroup.procs" || exit 1 + exec "$@" + ) +} + +# make sure we're running gentoo +grep -i gentoo /etc/os-release || { echo "Dieses System basiert nicht auf Gentoo" && exit 1; } -numcores="$(echo ""$(nproc)"" -4 | bc)" +numcores="$(echo ""$(nproc)"" /2 | bc)" + +cd_to_src(){ + readlink -f "/usr/src/linux" || { echo "Symlink /usr/src/linux nicht gesetzt oder fehlerhaft" && exit 2; } + cd "/usr/src/linux" || { echo "Verzeichniswechsel fehlgeschlagen" && exit 2; } +} clean_builddir(){ make mrproper - cp "/usr/src/config-$arg" "./.config" || exit 2 } -do_build(){ -[[ $(id -u) -ne 0 ]] && sudo -s arg="$1" cores="$numcores" <<'END_OF_SUDO' - schedtool -D -e make oldconfig - schedtool -D -e make modules_prepare - schedtool -D -e make -j"$cores" || exit 2 - schedtool -D -e make modules_install - schedtool -D -e make install - emerge @module-rebuild -END_OF_SUDO -sudo -k +call_makejobs(){ + pin_to_ccd0 + ccd_make oldconfig + ccd_make modules_prepare + ccd_make -j"$numcores" || exit 2 + ccd_make modules_install + ccd_make install + ccd_emerge @module-rebuild } -dont_build(){ - # echo "/usr/src/config-""$1""" "./.config" - echo "/usr/src/config-"$1"" "./.config" +prepare_config(){ + cp "/usr/src/config-$1" ".config" + test -f "./.config" || { echo "Kopieren der config fehlgeschlagen" && exit 2; } } +print_version(){ + echo "Building version:" + head -n5 Makefile + echo "" +} build_timeout(){ unset key @@ -46,107 +79,121 @@ case "$1" in emerge -puDNg @world ;; sync|ref|refresh) - "$precmd" emaint sync -A + root_check + emaint sync -A ;; world|dup) - "$precmd" /usr/bin/emerge -avuDNg @world "${@:2}" + root_check + run_in_portage_cgroup schedtool -D -e emerge -avuDNg @world "${@:2}" exit 0 ;; daily|all) - "$precmd" emaint sync -A - "$precmd" /usr/bin/emerge -avuDNg @world "${@:2}" + root_check + emaint sync -A + run_in_portage_cgroup schedtool -D -e emerge -avuDNg @world "${@:2}" exit 0 ;; - install|in) - "$precmd" /usr/bin/emerge -avg "${@:2}" + pkg|in) + root_check + run_in_portage_cgroup schedtool -D -e emerge -avg "${@:2}" exit 0 ;; skipkernel) - "$precmd" /usr/bin/emerge -avuDNg @world --exclude=dist-kernel --exclude=gentoo-kernel --exclude=gentoo-sources --exclude=git-sources "${@:2}" + root_check + /usr/bin/emerge -avuDNg @world --exclude=dist-kernel --exclude=gentoo-kernel --exclude=gentoo-sources --exclude=git-sources "${@:2}" exit 0 ;; preserved) - "$precmd" /usr/bin/emerge -av @preserved-rebuild + root_check + run_in_portage_cgroup schedtool -D -e emerge -av @preserved-rebuild exit 0 ;; wholeworld) - "$precmd" /usr/bin/emerge -avuDeg --with-bdeps=y --usepkg=n --binpkg-changed-deps=n --keep-going=y @world --exclude="acct-group/* acct-user/* virtual/* app-eselect/* sys-kernel/* sys-firmware/* dev-python/* dev-java/* dev-ruby/* dev-perl/* dev-lua/* dev-php/* dev-tex/* dev-texlive/* x11-themes/* */*-bin" + PORTAGE_CPUS=32 + root_check + schedtool -B -e /usr/bin/emerge -avuDeg --with-bdeps=y --usepkg=n --binpkg-changed-deps=n --keep-going=y @world --exclude="acct-group/* acct-user/* virtual/* app-eselect/* sys-kernel/* sys-firmware/* dev-python/* dev-java/* dev-ruby/* dev-perl/* dev-lua/* dev-php/* dev-tex/* dev-texlive/* x11-themes/* */*-bin" exit 0 ;; search|se) - "$precmd" /usr/bin/emerge --search "${@:2}" + root_check + /usr/bin/emerge --search "${@:2}" exit 0 ;; clean|rm) - "$precmd" /usr/bin/emerge -a --depclean "${@:2}" + root_check + /usr/bin/emerge -a --depclean "${@:2}" + exit 0 + ;; + checkclean) + /usr/bin/emerge -apv --depclean "${@:2}" exit 0 ;; live) - "$precmd" /usr/bin/emerge -av @live-rebuild + root_check + /usr/bin/emerge -av @live-rebuild ;; flatpaks) flatpak update ;; kernel-live) - cd "/usr/src/linux" || exit 2 + root_check + cd_to_src test -f "./.config" || exit 2 - echo "Building version:" - head -n5 Makefile + print_version build_timeout - echo "" - do_build - echo "Build completed. Remember to upgrayyedd /usr/src/config-* if necessary." + call_makejobs exit 0 ;; kernel-gentoo) + root_check cd "/usr/src/linux" || exit 2 clean_builddir - echo "Building version:" - head -n5 Makefile + prepare_config "gentoo" + print_version build_timeout - echo "" - do_build gentoo + call_makejobs echo "Build completed. Remember to upgrayyedd /usr/src/config-* if necessary." exit 0 ;; kernel-llvm) + root_check cd "/usr/src/linux" || exit 2 clean_builddir - echo "Building version:" - head -n5 Makefile + prepare_config "llvm" + print_version build_timeout - echo "" - do_build llvm + call_makejobs echo "Build completed. Remember to upgrayyedd /usr/src/config-* if necessary." exit 0 ;; kernel-git) + root_check cd "/usr/src/linux" || exit 2 clean_builddir - echo "Building version:" - head -n5 Makefile + prepare_config "git" + print_version build_timeout - echo "" - do_build git + call_makejobs echo "Build completed. Remember to upgrayyedd /usr/src/config-* if necessary." exit 0 ;; kernel-server) + root_check cd "/usr/src/linux" || exit 2 clean_builddir - echo "Building version:" - head -n5 Makefile + prepare_config "server" + print_version build_timeout - echo "" - do_build server + call_makejobs echo "Build completed. Remember to upgrayyedd /usr/src/config-* if necessary." exit 0 ;; clean-kernels) + root_check echo "Relevant files in /boot:" - echo "" + echo "" command ls -1 --hide='*/' /boot/System.map* /boot/initramfs* /boot/vmlinuz* - "$precmd" eclean-kernel -aA -L std + eclean-kernel -aA -L std ;; log) grep -i --color=auto "completed" /var/log/emerge.log @@ -157,10 +204,13 @@ case "$1" in echo "note: use 'date -d @[unixtime]' to convert the timestamp" ;; testify) - echo "${@:2}" - echo "Precmd is: $precmd" - echo "$numcores" - dont_build gentoo + run_in_portage_cgroup bash -c ' + echo "PID: $$" + echo "cgroup:" + cat /proc/$$/cgroup + echo "allowed CPUs:" + grep Cpus_allowed_list /proc/$$/status + ' ;; *) printf '\nCurrently available commands:\n\n' @@ -183,6 +233,7 @@ case "$1" in 'kernel-git ' 'build kernel flavor: git' \ 'kernel-server ' 'build kernel flavor: server' \ ' ' ' ' \ + 'checkclean ' 'check for orphans' \ 'clean ' 'clean orphaned packages' \ 'preserved ' 'clean-up old libraries' \ 'clean-kernels ' 'remove old kernels' \ diff --git a/dot-local/bin/wl-freeze b/dot-local/bin/wl-freeze new file mode 120000 index 0000000..0c5f1bd --- /dev/null +++ b/dot-local/bin/wl-freeze @@ -0,0 +1 @@ +/media/source/wl-freeze/wl-freeze \ No newline at end of file -- 2.55.0