Skip to content

Instantly share code, notes, and snippets.

@jtsagata
Created June 10, 2015 03:19
Show Gist options
  • Select an option

  • Save jtsagata/a6087d3d8e251899f8cb to your computer and use it in GitHub Desktop.

Select an option

Save jtsagata/a6087d3d8e251899f8cb to your computer and use it in GitHub Desktop.
universal pause key
#!/bin/bash
# https://github.com/ryanries/UniversalPauseButton
# https://news.ycombinator.com/item?id=9686854
currentProcess=$(xprop -id $(xprop -root | grep -F '_NET_ACTIVE_WINDOW(WINDOW)' | awk '{print $5}') | grep -F '_NET_WM_PID(CARDINAL)' | awk '{print $3}')
state=$(grep 'State:' /proc/$currentProcess/status | awk '{print $2}')
if [[ "$state" == "T" ]]
then
kill -CONT $currentProcess
else
kill -STOP $currentProcess
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment