diff --git a/files/.config/gamemode.ini b/files/.config/gamemode.ini new file mode 100644 index 0000000..7156b0c --- /dev/null +++ b/files/.config/gamemode.ini @@ -0,0 +1,3 @@ +[custom] +start=__on-gamemode start +end=__on-gamemode end diff --git a/files/.config/zsh/custom/101-function.zsh b/files/.config/zsh/custom/101-function.zsh index 42e82e3..b63d620 100644 --- a/files/.config/zsh/custom/101-function.zsh +++ b/files/.config/zsh/custom/101-function.zsh @@ -48,10 +48,6 @@ play-vm() { if ! [ -S /tmp/win10.sock ]; then echo "Cannot find spice socket! Is the vm started?" else - echo "Stopping services" - sudo systemctl stop cronie - systemctl --user stop redshift compton wallpaper - echo "Setup cpuset cgroup for host" sudo cset set -c 0,4 -s system sudo cset proc -m -f root -t system @@ -68,8 +64,5 @@ play-vm() { sudo bash -c "echo f > /sys/devices/virtual/workqueue/cpumask" # cpuset sudo cset set -d system &>/dev/null - # services - systemctl --user start redshift compton wallpaper - sudo systemctl start cronie fi } diff --git a/files/.local/bin/__on-gamemode b/files/.local/bin/__on-gamemode new file mode 100755 index 0000000..47c974e --- /dev/null +++ b/files/.local/bin/__on-gamemode @@ -0,0 +1,22 @@ +#!/bin/bash +exec 1<&- + +system_services="cronie" +user_services="compton redshift" + +if [[ "$1" == "start" ]]; then + for service in $system_services; do + sudo systemctl stop "$service" + done + for service in $user_services; do + systemctl --user stop "$service" + done +elif [[ "$1" == "end" ]]; then + for service in $system_services; do + systemctl is-enabled "$service" && sudo systemctl start "$service" + done + for service in $user_services; do + systemctl --user is-enabled "$service" && systemctl --user start "$service" + done +fi +