tom-james-watson/breaktimer-app

Reset Break Timer On Screen Lock / Unlock

Opened this issue · 1 comments

I'm aware there is an "Idle Reset" feature, but this does not work ideally because of the following reasons:

  • The break interval keeps resetting while I participate on a conference call, because the computer thinks I'm "idle", when in fact I'm not
  • When I set the idle interval too small (2 min), the break counter keeps resetting even when I'm thinking about something, checking my phone, etc.
  • When I set the interval for too long (5 min), the counter does not always reset when I leave the computer

An ideal solution would be to add a setting to reset the break interval after the screen has been locked and then unlocked again. A locked screen is a clear indication that the user is not on the computer.

Thank you for your consideration.

As a workaround, I configured Ubuntu to disable breaks when the screen is locked, and to enable them again on unlock. Here is how to do it:

Create the following script files, and make them executable:

~/scripts/on_screen_lock.sh

#!/bin/sh

echo "$(date): Screen locked" >> /tmp/screen.log

breaktimer disable

~/scripts/on_screen_unlock.sh

#!/bin/sh

echo "$(date): Screen unlocked" >> /tmp/screen.log

breaktimer enable

~/scripts/monitor_screen_unlock.sh

#!/bin/sh

dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | while read x; do
  if echo $x | grep "boolean true" &> /dev/null; then
    ~/scripts/on_screen_unlock.sh &
  fi
done

Install xss-lock

sudo apt-get install xss-lock

Open "Startup Applications" and add the following commands:

  1. xss-lock -- /home/user/scripts/on_screen_lock.sh
  2. /home/user/scripts/monitor_screen_unlock.sh

You have to use the full path here, using ~/scripts/ will not work.