Refactored the code
This commit is contained in:
parent
e67ea81968
commit
db9861cdcd
16
README.md
16
README.md
|
@ -18,9 +18,6 @@ For more details: [SafeEyes Protects You From Eye Strain When Working On The Com
|
|||
Install SafeEyes via [AUR](https://aur.archlinux.org/packages/safeeyes/). Credits to [Yamakaky](https://github.com/Yamakaky)
|
||||
|
||||
### Other Linux:
|
||||
|
||||
Manual installation is not tested in any systems. I will update this page as soon as I have tested in any other Linux distributions.
|
||||
|
||||
1: Install the dependencies:
|
||||
|
||||
* Arch: `hicolor-icon-theme`, `libappindicator-gtk3`, `xorg-xprop`, `python2-xlib`, `python2-gobject`, `python2-dbus`, `python2-babel`, `xprintidle` and `mpg123`
|
||||
|
@ -31,8 +28,6 @@ Manual installation is not tested in any systems. I will update this page as soo
|
|||
|
||||
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 /`
|
||||
|
||||
If you have any issues in installing Safe Eyes, please report them [here](https://github.com/slgobinath/SafeEyes/issues)
|
||||
|
||||
4: Start Safe Eyes using this command: `/opt/safeeyes/safeeyes`
|
||||
|
||||
Once started, Safe Eyes will copy the desktop file to `~/.config/autostart` and the configurations to `~/.config/safeeyes`. Therefore, from next time onwards, it should start with the system.
|
||||
|
@ -80,10 +75,21 @@ Please test Safe Eyes on your system and report any issues [here](https://github
|
|||
|
||||
Please test Safe Eyes and create installers for your operating system
|
||||
|
||||
**Found a bug?**
|
||||
|
||||
Please report them [here](https://github.com/slgobinath/SafeEyes/issues)
|
||||
|
||||
|
||||
**Can you translate English to your mother tongue (or whatever the language)?**
|
||||
|
||||
Show your support by translating Safe Eyes to a new language or by improving the existing translations.
|
||||
|
||||
**How else can you show your support?**
|
||||
|
||||
- Vote for Safe Eyes in [alternativeto.net](http://alternativeto.net/software/eyeleo/?platform=linux).
|
||||
- Suggest any improvements.
|
||||
- Share with your friends.
|
||||
|
||||
## Translating Safe Eyes
|
||||
From version 1.1.0, Safe Eyes supports translation. Translation files for each langauges must be placed in `/opt/safeeyes/config/lang` directory. The language file name must follow [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code standard. For example, the language file of English must be `en.json`. Follow these steps to translate Safe Eyes to your language.
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import gi, logging, threading, datetime, Utility
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('AppIndicator3', '0.1')
|
||||
from gi.repository import Gtk, Gdk, GLib, GdkX11
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import AppIndicator3 as appindicator
|
||||
|
||||
# Global variables
|
||||
|
@ -119,7 +119,6 @@ class TrayIcon:
|
|||
self.menu.append(self.item_info)
|
||||
self.menu.append(self.item_separator)
|
||||
self.menu.append(self.item_enable)
|
||||
# self.menu.append(self.item_disable)
|
||||
self.menu.append(self.item_settings)
|
||||
self.menu.append(self.item_about)
|
||||
self.menu.append(self.item_quit)
|
||||
|
|
|
@ -87,3 +87,17 @@ def format_time(time):
|
|||
if not system_locale:
|
||||
system_locale = 'en_US.UTF-8'
|
||||
return babel.dates.format_time(time, format='short', locale=system_locale)
|
||||
|
||||
|
||||
"""
|
||||
Create directory if not exists.
|
||||
"""
|
||||
def mkdir(path):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.EEXIST and os.path.isdir(path):
|
||||
pass
|
||||
else:
|
||||
logging.error('Error while creating ' + str(path))
|
||||
raise
|
|
@ -186,24 +186,13 @@ def initialize_config():
|
|||
global config
|
||||
config_dir_path = os.path.join(os.path.expanduser('~'), '.config/safeeyes/style')
|
||||
startup_dir_path = os.path.join(os.path.expanduser('~'), '.config/autostart')
|
||||
try:
|
||||
os.makedirs(config_dir_path)
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.EEXIST and os.path.isdir(config_dir_path):
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
|
||||
Utility.mkdir(config_dir_path)
|
||||
|
||||
if not os.path.isfile(config_file_path):
|
||||
shutil.copy2(system_config_file_path, config_file_path)
|
||||
|
||||
try:
|
||||
os.makedirs(startup_dir_path)
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.EEXIST and os.path.isdir(startup_dir_path):
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
Utility.mkdir(startup_dir_path)
|
||||
|
||||
# Add to startup for the first time only
|
||||
try:
|
||||
|
@ -244,7 +233,7 @@ def validate_config():
|
|||
|
||||
# Remove startup script
|
||||
try:
|
||||
os.remove("/usr/share/applications/safeeyes.desktop")
|
||||
os.remove(os.path.join(os.path.expanduser('~'), '.config/autostart/safeeyes.desktop'))
|
||||
except:
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue