ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    How to script a process upon wake up on Ubuntu

    Scheduled Pinned Locked Moved IT Discussion
    3 Posts 2 Posters 214 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • IRJI
      IRJ
      last edited by IRJ

      Create a new file in /etc/pm/sleep.d

      vi /etc/pm/sleep.d/bluetooth_restart
      

      Add the following contents to the file. You will want to replace sudo service restart bluetooth section with your own commands or point to your own script

      #!/bin/sh
      case "$1" in
          thaw|resume)
              sudo service bluetooth restart
              ;;
      esac
      

      Now when you system wakes up it will automatically perform this action.

      1 Reply Last reply Reply Quote 3
      • stacksofplatesS
        stacksofplates
        last edited by stacksofplates

        You could just modify the bluetooth.service to have this :

        [Unit]
        ...
        `After=suspend.target hibernate.target hybrid-sleep.target`
        
        ...
        
        [Install]
        WantedBy=suspend.target hibernate.target hybrid-sleep.target
        
        IRJI 1 Reply Last reply Reply Quote 1
        • IRJI
          IRJ @stacksofplates
          last edited by

          @stacksofplates said in How to script a process upon wake up on Ubuntu:

          You could just modify the bluetooth.service to have this :

          [Unit]
          ...
          `After=suspend.target hibernate.target hybrid-sleep.target`
          
          ...
          
          [Install]
          WantedBy=suspend.target hibernate.target hybrid-sleep.target
          

          What file are you using?

          This is what I found /etc/systemd/system/bluetooth.taget.wants/bluetooth.service

          b6be4a94-06d8-4b71-9052-a6508b604f6d-image.png

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post