Giter VIP home page Giter VIP logo

hyprfreeze's Introduction

hyprfreeze

basher install Hyprfreeze is a utility to suspend a game process (and other programs) in Hyprland and Sway.

Hyprfreeze.mp4

Useful to:

  • Pause single-player games that can't normally be paused (Elden Ring, Baldur's Gate 3, ...)
  • Pause cutscenes to read the subtitles or if you suddenly need to leave your desk
  • Save system resources (excluding RAM) if you need them for another computer task, or if the game's pause menu uses too many

Note: Running games in gamescope is highly recommended. (See #1)

Installation

Arch Linux

Hyprfreeze is available in AUR.

Dependencies

  • a compatible window manager (hyprland or sway) to get the PID of the active window
  • jq to parse json
  • psmisc contains 'pstree' which is required to list child processes

    Optional

  • hyprprop or swayprop to get the pid of a window by selecting it with your mouse

    Highly Recommended

  • gamescope fixes mouse input not working in other XWayland windows after pausing a Wine game. It's also the superior way to game in Wayland anyway.

Basher

Hyprfreeze is compatible with shell script package manager Basher.

basher install Zerodya/hyprfreeze

Manual

Clone this repo and symlink the hyprfreeze script to a directory in your PATH:

git clone https://github.com/Zerodya/hyprfreeze.git Hyprfreeze
ln -s $(pwd)/Hyprfreeze/hyprfreeze $HOME/.local/bin

Usage

Add a bind in your Hyprland or Sway config to pause the current active window:

# ~/.config/hypr/hyprland.conf
...
# Toggle freeze on active window
bind = , PAUSE, exec, hyprfreeze -a

Available flags

-h, --help            show help message

-a, --active          toggle suspend by active window
-p, --pid             toggle suspend by process id
-n, --name            toggle suspend by process name/command
-r, --prop            toggle suspend by clicking on window (hyprprop/swayprop must be installed)

-s, --silent          don't send notification
-t, --notif-timeout   notification timeout in milliseconds (default 5000)
--info                show information about the process
--dry-run             doesn't actually suspend/resume a process, useful with --info
--debug               enable debug mode

Examples:

# Pause game by process name
hyprfreeze -n eldenring.exe
# Get info about a process by clicking on its window, without suspending it
hyprfreeze -r --info --dry-run

Disclaimer

There is always the risk, although slim, that an application may crash.

This is intrinsically related to modifying running processes and is not something that Hyprfreeze can prevent.

Please make sure to save your data before using hyprfreeze.

hyprfreeze's People

Contributors

alternerdtive avatar icedborn avatar rolv-apneseth avatar zerodya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hyprfreeze's Issues

No sound in other programs when pausing a Linux native game (e.g. Minecraft)

I have encountered an issue when using this script with Minecraft... when using this script to pause a running Minecraft client, any other audio being played (I use Pipewire) is muted (the clip/video/program continues running). This seems to be one-way; audio in MC does not shut down when I pause the other app.

Mouse input doesn't work inside Xorg/XWayland windows while a Wine/Proton game is paused

This issue happens when pausing a game while the mouse cursor is inside the game window. It's like the mouse cursor gets paused too, and is stuck in that state (Proton games run in XWayland), so it stops working in other XWayland windows too.


This issue is apparently only present when running the script via a keybind.

For some reason running the same script in a terminal (by manually assigning the game process to the PID variable) works as intended and mouse input works correctly in other Xorg/XWayland windows.

Script I ran in terminal which works as intended:

PID=26043 #Manually assign pid of a game
PIDS=$(pstree $PID -npl | grep -oP '(?<=\()[0-9]+(?=\))')

kill -STOP $PIDS

Pausing a game running in gamescope also works as intended.

EDIT

On further analysis it looks like this issue only happens when pausing a game while the mouse cursor is inside the game window.

If I add a sleep timer like this

if [[ "$(ps -o state= $PID)" == S ]]; then
        sleep 3 #timer
        kill -STOP $PIDS
	exit 0
fi

run the script from keybind, and quickly move the mouse cursor out of the game window, the game gets paused after 3 seconds and the mouse works correctly in other XWayland windows.
Not sure how to proceed right now as this should be fixed in a way that still allows pausing the game instantaneously.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.