The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 150β€…    Votes:  4β€…    βœ… Solution
Tags: 16.04   bash   suspend  
Link: πŸ” See Original Answer on Ask Ubuntu πŸ”—

URL: https://askubuntu.com/q/1301658
Title: Creating script to report system suspend or awake is not running?
ID: /2020/12/20/Creating-script-to-report-system-suspend-or-awake-is-not-running_
Created: December 20, 2020    Edited:  December 20, 2020
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


Copy your script to:

/lib/systemd/system-sleep/sleep_mode

You will need to use sudo powers. After copying flag it as executable:

sudo chmod +x /lib/systemd/system-sleep/sleep_mode

Additionally change all occurrences of:

echo "%s

to:

echo "s

The percent sign is unnecessary.

The existing date command is OK:

date +%s >>  /tmp/suspend_time.txt

However it is formatted as number of seconds since January 1, 1970 which isn’t the most readable date format.


case statement

The case statement can be changed:

case $1/$2 in
  pre/*)
    echo "$0: Going to $2..."
    # Place your pre suspend commands here, or `exit 0` if no pre suspend action required
    ;;
  post/*)
    echo "$0: Waking up from $2..."
    # Place your post suspend (resume) commands here, or `exit 0` if no pre suspend action required
    ;;
esac
⇧ Audio jack not detected, sound playing from both speaker's and headphones Command line audio players  β‡©