From eb7a53157170ef1187432d4e1c1d24407b9441d5 Mon Sep 17 00:00:00 2001 From: Nicola <73220426+Zerodya@users.noreply.github.com> Date: Sat, 2 Sep 2023 18:58:22 +0200 Subject: [PATCH] First commit --- README.md | 12 +++++++++++- hyprfreeze | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 hyprfreeze diff --git a/README.md b/README.md index 43c7556..07c222c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,12 @@ # hyprfreeze -Pause and resume game/program process in Hyprland +Simple bash script to pause a game process in Hyprland, allowing you to resume it later. +Useful to: +- Pause games during unskippable cutscenes and similar scenarios +- Save system resources (CPU and GPU are free, the process is saved in RAM) + +(Also works for any other program; pauses the current active window) +### Usage +Make the script executable, then in your Hyprland config add a bind to the script e.g. : +``` +bind = $mainMod, PAUSE, exec, ~/scripts/hyprfreeze +``` diff --git a/hyprfreeze b/hyprfreeze new file mode 100644 index 0000000..b0b762b --- /dev/null +++ b/hyprfreeze @@ -0,0 +1,16 @@ +#!/bin/bash + +PID=$(hyprctl activewindow | grep -i pid | awk -F "pid: " '{ print $2 }' | awk -F "," '{ print $1 }') +PIDS=$(pstree $PID -npl | grep -oP '(?<=\()[0-9]+(?=\))') + +# Pause process if running +if [[ "$(ps -o state= $PID)" == S ]]; then + kill -STOP $PIDS + exit 0 +fi + +# Resume process if stopped +if [[ "$(ps -o state= $PID)" == T ]]; then + kill -CONT $PIDS + exit 0 +fi