Views: 
              2,566 
          
          
                Votes:  2 
          
          
          
            
            Tags: 
              
                gnome  
              
                suspend  
              
                gnome-shell  
              
          
          
            
              
                
                Link: 
                  🔍 See Original Answer on Ask Ubuntu ⧉ 🔗
              
            
          
        
        
          
            URL: 
              https://askubuntu.com/q/1053376
          
          
            
            Title: 
              How to automatically restart Gnome Shell every time the PC comes out from suspend
            
          
          
            ID: 
              /2018/07/09/How-to-automatically-restart-Gnome-Shell-every-time-the-PC-comes-out-from-suspend
            
          
          
            Created: 
               July  9, 2018
          
          
          
          
            
            Upload: 
              October 19, 2025
          
          
               Layout:  post
          
          
            
            TOC: 
              false
          
          
               Navigation:  false
          
          
               Copy to clipboard:  false
          
          
        
       
Change your script from this:
case "${1}" in
    post)
         gnome-shell --replace
;;
esac
To this:
#!/bin/sh
case $1/$2 in
  pre/*)
    echo "Going to $2..."
    # Place your pre suspend commands here, or `exit 0`
    # if no pre suspend action required
    sleep 1
    ;;
  post/*)
    echo "Waking up from $2..."
    # Place your post suspend (resume) commands here, or `exit 0` 
    # if no post suspend action required
    sleep 2
    gnome-shell --replace
    ;;
esac
For sure you are missing #!/bin/sh at the top of your script. Most of the rest of the proposed changes are not be necessary but informative.