View on GitHub

needabreak

NEED A BREAK! is an application intended to help you take care of your health while you work on a computer.

NEED A BREAK!

Presentation

FOSSA Status

NEED A BREAK! is an open source application intended to help you take care of your health while you work on a computer. It will encourage you to regularly have a break in order to avoid health issues like musculoskeletal disorders, headaches or eye strain.

I have made it for my personal usage and personaly use it every day at work and it helps me to not sit for too long. So I decided to share it because maybe it could be useful to someone else.

You will be notified a minute before lockdown:

imminent lockdown

When it is time to have a break a countdown will appear. The screen will be locked when it reaches 0:

countdown

You can verify that the application is running thanks to the task bar icon:

task bar icon

You can display the application menu by clicking on the coffee cup:

menu

The settings window let you choose how long the application will wait before lockdown:

settings

You can find this documentation on my github page: https://bnobo.github.io/needabreak/

Installation

If you just want to install and enjoy the latest version of the application, you can download the setup from here.

Note that you will have a big red warning from the UAC during installation because the installer is not digitally signed.

Get started

The project is a WPF application targeting .Net Framework 4.8. All you need is a copy of Visual Studio Community in order to build it. Once started, the application creates a coffee cup icon in the task bar to manifest its presence and permits user to interact with it. Just click on the coffee cup to open the application menu.

Contribute

I’m sure this application could be improved in many ways and I would be happy to receive some help in doing so. If you want to contribute to this project, please go to https://github.com/bNobo/needabreak and read contributing.md file.

Every kind of contribution is welcome, it includes, but is not limited to:

Points of interest in code

P/Invoke

Use of P/Invoke to lock workstation:

[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool LockWorkStation();

Use of P/Invoke to check current user notification state in order to automatically suspend the application if a notification would not be appropriate:

[DllImport("shell32.dll")]
static extern int SHQueryUserNotificationStte(outUserNotificationStateuserNotificationState);

Use of P/Invoke to ensure user is idle before poping-up the countdown window:

[DllImport("user32.dll")]
static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);

[DllImport("user32.dll")]		
static extern ushort GetAsyncKeyState(ushort virtualKeyCode);

System events

Use of system events to detect session switch:

Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;

Mutex

Use of Mutex class to prevent application from beeing launched twice:

mutex = new System.Threading.Mutex(false, "Local\\NeedABreakInstance");
if (!mutex.WaitOne(0, false))
{
    Logger.Info("Application already running");
    Current.Shutdown();
    return;
}

Translations

Use of Multilingual App Toolkit extension to handle translations. RESX files are automatically generated from translations made in XLF files.

Use of custom markup extension to handle translations in XAML files like this:

<TextBlock Margin="0 210 0 0"
           Text="{utils:TextResource warranty}" />

Adorner

Use of Adorner class to surround selected tile on the settings window.

License

FOSSA Status