You are not logged in.
Pages: 1
Hello,
I use this code for starting my gaming VM (with GPU passthrough):
#!/bin/bash
chmod 777 /dev/input/by-id/usb-Razer_Razer_Lancehead_Tournament_Edition-event-mouse
# Start evdev (input)
exec -a EVDEV-INPUT-VM ./evdev /dev/input/by-id/usb-Razer_Razer_BlackWidow_Chroma_V2-if01-event-kbd &
# Fix permissions for scream-ivshmem (sound)
chmod 777 /dev/shm/scream-ivshmem
# Set CPU governor to performance
sh -c "echo -n performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor";
sh -c "echo -n performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor";
sh -c "echo -n performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor";
sh -c "echo -n performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor";
# Turn on presentation mode (disable sleeping)
inhibit_cookie=$(qdbus org.freedesktop.PowerManagement.Inhibit /org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.Inhibit "VM" "because")
# Move all windows to second screen if available
# Change video input on monitor
#ddccontrol -r 0x60 -w 17 dev:/dev/i2c-X
# KERNEL_SECURITY_CHECK_FAILURE fix for Fortnite
echo 1 > /sys/module/kvm/parameters/ignore_msrs
# Sleep for 1 sec
sleep 1
# Start VM
virsh start windows10Gaming-8GB
# Sleep for 1 sec
sleep 1
# Start htop
htopbut I wonder how can I run sets of commands when I close that terminal or I press Ctrl+C? --> Because I want to reset some values to default state after that.
I use several linux distros like: Archlinux, Ubuntu, Fedora, Linux Mint
Offline
trap SIGTERM, man trap
Offline
trap SIGTERM, man trap
Thank you so like this?
_term() {
echo "exit"
}
trap _term SIGTERMI use several linux distros like: Archlinux, Ubuntu, Fedora, Linux Mint
Offline
"TERM", idk whether "SIGTERM" will cause an error, also you may want to trap "EXIT" (ie. "trap _term TERM EXIT") - and be sure to call it before running a blocking loop or child.
Offline
Maybe also interrupt and hungup signal?
SIGHUP - when you close terminal window.
SIGINT - Ctl_c to interrupt execution.
trap _term SIGTERM SIGINT SIGHUP EXITsh -c "echo -n performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
Just curious, do you have to spawn another shell to call echo? will this not working?
#/!/bin/bash
echo -n performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Last edited by solskog (2020-09-14 14:56:48)
Offline
That's actually the signals I bindly slap behind every "standard" trap ![]()
(So if I don't want to handle SIGSTOP or SIGUSR*)
Edit: nb. for completeness sale you cannot trap sigstop (or kill) this way
Last edited by seth (2020-09-14 15:04:16)
Offline
Pages: 1