1 Replies - 236 Views - Last Post: 03 July 2013 - 02:42 PM Rate Topic: -----

#1 random0munky  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-July 13

Run Script on Wake

Posted 02 July 2013 - 11:00 AM

Hey guys trying to figure out the switch case for when a linux computer wakes/resumes from sleep. This is the bash script equivalent:


#!/bin/bash
case $1 in
    hibernate)
        echo "Hey guy, we are going to suspend to disk!"
        ;;
    suspend)
        echo "Oh, this time we are doing a suspend to RAM. Cool!"
        ;;
    thaw)
        echo "Oh, suspend to disk is over, we are resuming..."
        ;;
    resume)
        echo "Hey, the suspend to RAM seems to be over..."
        ;;
    *)  echo "Somebody is calling me totally wrong."
        ;;
esac




I was seeing if this would work in my case (feeling it won't since python probably doesn't understand, hibernate, suspend, resume, thaw commands)


#!/usr/bin env python
switch($1) {
  case hibernate:
        print "Hibernate"
        break;
    case suspend:
        print "Suspend"
        break;
    case resume:
        print "Resume"
        break;
    case thaw:
        print "Thaw"
        break;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Run Script on Wake

#2 Nallo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 163
  • View blog
  • Posts: 255
  • Joined: 19-July 09

Re: Run Script on Wake

Posted 03 July 2013 - 02:42 PM

More importantly python doesn't have a switch statement. Don't throw bash code at python. It wont work.

Sorry for the rant.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1