Short format time using locale

This commit is contained in:
Gobinath 2017-02-08 21:39:27 -05:00
parent 812914c3a7
commit 73c7e74057
3 changed files with 18 additions and 8 deletions

View File

@ -23,11 +23,11 @@ Manual installation is not tested in any systems. I will update this page as soo
1: Install the dependencies:
* Arch: `hicolor-icon-theme`, `libappindicator-gtk3`, `xorg-xprop`, `python2-xlib`, `python2-gobject`, `python2-dbus`, `xprintidle` and `mpg123`
* Arch: `hicolor-icon-theme`, `libappindicator-gtk3`, `xorg-xprop`, `python2-xlib`, `python2-gobject`, `python2-dbus`, `python2-babel`, `xprintidle` and `mpg123`
* Debian: `gir1.2-appindicator3-0.1`, `python-xlib`, `python-gobject`, `python-gi`, `python-dbus`, `gir1.2-notify-0.7`, `python-gtk2`, `xprintidle` and `mpg123`
* Debian: `gir1.2-appindicator3-0.1`, `python-xlib`, `python-gobject`, `python-gi`, `python-dbus`, `gir1.2-notify-0.7`, `python-gtk2`, `python-babel`, `xprintidle` and `mpg123`
* Fedora 24: `libappindicator-gtk3`, `python-xlib`, `python-gobject`, `xorg-x11-utils`, `python-dbus`, `xprintidle` and `mpg123`
* Fedora 24: `libappindicator-gtk3`, `python-xlib`, `python-gobject`, `xorg-x11-utils`, `python-dbus`, `python-babel`, `xprintidle` and `mpg123`
2: Download and extract [safeeyes.tar.gz](https://github.com/slgobinath/SafeEyes/releases/download/v1.1.4/safeeyes.tar.gz) into `/`: `sudo tar -xzvf safeeyes.tar.gz -C /`

View File

@ -8,7 +8,7 @@ Homepage: https://github.com/slgobinath/SafeEyes/
Package: safeeyes
Architecture: any
Depends: gir1.2-appindicator3-0.1, python (>= 2.7.0), python-xlib, python-gi, python-dbus, gir1.2-notify-0.7, python-gtk2, xprintidle, mpg123
Depends: gir1.2-appindicator3-0.1, python (>= 2.7.0), python-xlib, python-gi, python-dbus, gir1.2-notify-0.7, python-gtk2, python-babel, xprintidle, mpg123
Description: Safe Eyes
Safe Eyes is a simple tool to remind you to take periodic breaks for your eyes. This is essential for anyone spending more time on the computer to avoid eye strain and other physical problems.
.

View File

@ -19,7 +19,7 @@
import gi
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk, GLib
import os, subprocess, threading, logging
import babel.dates, os, subprocess, threading, logging, locale
"""
Play the alert.mp3
@ -45,8 +45,8 @@ def system_idle_time():
"""
Execute the function in a separate thread.
"""
def start_thread(target_function):
thread = threading.Thread(target=target_function)
def start_thread(target_function, args=None):
thread = threading.Thread(target=target_function, kwargs=args)
thread.start()
@ -58,7 +58,7 @@ def execute_main_thread(target_function):
"""
Check for full-screen applications
Check for full-screen applications.
"""
def is_full_screen_app_found():
logging.info("Searching for full-screen application")
@ -74,3 +74,13 @@ def is_full_screen_app_found():
else:
if stdout:
return 'FULLSCREEN' in stdout
"""
Format time based on the system time.
"""
def format_time(time):
system_locale = locale.setlocale(locale.LC_ALL, '')
if not system_locale:
system_locale = 'en_US.UTF-8'
return babel.dates.format_time(time, format='short', locale=system_locale)