How to pause & restore application with keyboard shortcut in Linux

Small thing, but very useful IMO – using these two easy script, it’s possible to pause and then unpause currently selected application with keystroke.

To me it’s often the case that I want have some program to be available the second I want it, but unfortunatelly it’s eating a lot of CPU and blocking another programs, which I actually use in the moment. So, I’ve created scripts to make this program available and ready for me, but cost only some RAM.

Use carefully – it can also pause you DE. :)

pause_current_app.sh

#!/bin/sh
#by dRaiser
#http://draiser.net

active_window_id=$(xdotool getactivewindow)
active_window_pid=$(xdotool getwindowpid "$active_window_id")
kill -n 19 $active_window_pid

unpause_current_app.sh

#!/bin/sh
#by dRaiser
#http://draiser.net

active_window_id=$(xdotool getactivewindow)
active_window_pid=$(xdotool getwindowpid "$active_window_id")
kill -n 18 $active_window_pid

Save those scripts in some location (eg. ~/Scripts), make them executable by chmod +x filename and create a keyboard shortcut in keyboard settings of you DE (if you don’t use DE, I suppose you don’t need this tutorial).

In Cinnamon it looks like this:

pause_1 pause2

To not pause by mistake, I used ctrl+pause/break key for pausing and pause/break for restoring application (it does nothing when app’s not paused).

Leave a Reply

Your email address will not be published. Required fields are marked *