-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add initial config file, road to 3.7 * add some documentation
- Loading branch information
1 parent
3435653
commit 59611a8
Showing
25 changed files
with
106 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"blacklist": ["telegram", "hangouts"], | ||
"icons": { | ||
"theme": "Numix", | ||
"size": 24 | ||
}, | ||
"conversion-tool": "CairoSVG" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
version=v3.6.6 | ||
version=v3.7 | ||
if [[ $EUID -ne 0 ]]; then | ||
case $1 in | ||
-u|--update) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
@@ -30,6 +30,7 @@ | |
USERNAME = getenv("SUDO_USER") | ||
USERHOME = get_userhome(USERNAME) | ||
BACKUP_FOLDER = path.join(USERHOME, ".config", "Hardcode-Tray", "") | ||
CONFIG_FILE = path.join(USERHOME, ".config", "hardcode-tray.json") | ||
BACKUP_FILE_FORMAT = "%d-%m-%Y_%H-%M-%S" | ||
LOG_FILE_FORMAT = "%d-%m-%Y_%H-%M-%S" | ||
CHMOD_IGNORE_LIST = ["", "home"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
@@ -194,8 +194,9 @@ def replace_vars_path(self, _path): | |
class ArgsParser: | ||
"""CLI arguments parser.""" | ||
|
||
def __init__(self, args): | ||
def __init__(self, args, config): | ||
self._args = args | ||
self._config = config | ||
self._parse() | ||
|
||
def _parse(self): | ||
|
@@ -209,6 +210,11 @@ def _parse(self): | |
self._parse_path() | ||
self._parse_choice() | ||
|
||
@property | ||
def config(self): | ||
"""Property: config.""" | ||
return self._config | ||
|
||
@property | ||
def args(self): | ||
"""Property : args.""" | ||
|
@@ -222,7 +228,17 @@ def _parse_theme(self): | |
"dark": Theme(self.args.dark_theme), | ||
"light": Theme(self.args.light_theme) | ||
} | ||
else: | ||
elif self.config.get("icons", None): | ||
theme = self.config["icons"].get("theme", {}) | ||
if isinstance(theme, str): | ||
self.theme = Theme(theme) | ||
else: | ||
if theme.get("light", None) and theme.get("dark", None): | ||
self.theme = { | ||
"dark": Theme(theme["dark"]), | ||
"light": Theme(theme["light"]) | ||
} | ||
if not self.theme: | ||
source = Gio.SettingsSchemaSource.get_default() | ||
if source.lookup("org.gnome.desktop.interface", True): | ||
gsettings = Gio.Settings.new("org.gnome.desktop.interface") | ||
|
@@ -242,10 +258,14 @@ def _parse_colors(self): | |
self.colours = colours | ||
|
||
def _parse_conversion_tool(self): | ||
conversion_tool = None | ||
if self.args.conversion_tool: | ||
conversion_tool = self.args.conversion_tool | ||
elif self.config.get("conversion-tool", None): | ||
conversion_tool = self.config.get("conversion-tool") | ||
if conversion_tool: | ||
try: | ||
self.svgtopng = CONVERSION_TOOLS[ | ||
self.args.conversion_tool](self.colours) | ||
self.svgtopng = CONVERSION_TOOLS[conversion_tool](self.colours) | ||
except SVGNotInstalled: | ||
exit("The selected conversion tool is not installed.") | ||
else: | ||
|
@@ -267,9 +287,17 @@ def _parse_icon_size(self): | |
self.icon_size = self.args.size | ||
else: | ||
if DESKTOP_ENV in ("pantheon", "xfce"): | ||
self.icon_size = 24 | ||
icon_size = 24 | ||
else: | ||
icon_size = 22 | ||
if self.config.get("icons", None): | ||
self.icon_size = self.config["icons"].get("size", icon_size) | ||
if self.icon_size not in [16, 22, 24]: | ||
self.icon_size = icon_size | ||
logging.debug("Icon size in the config file is wrong. " | ||
"Falling back to the detected one...") | ||
else: | ||
self.icon_size = 22 | ||
self.icon_size = icon_size | ||
|
||
def _parse_scaling_factor(self): | ||
self.scaling_factor = get_scaling_factor(DESKTOP_ENV) | ||
|
@@ -280,7 +308,10 @@ def _parse_scaling_factor(self): | |
def _parse_fix_only(self): | ||
self.only = [] | ||
if self.args.only: | ||
self.only = self.args.only.lower().strip().split(",") | ||
only = self.args.only.lower().strip().split(",") | ||
for bfile in self.config.get("blacklist"): | ||
only.remove(bfile) | ||
self.only = only | ||
|
||
def _parse_path(self): | ||
self.path = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author : Bilal Elmoussaoui ([email protected]) | ||
Contributors : Andreas Angerer, Joshua Fogg | ||
Version : 3.6.6 | ||
Version : 3.7 | ||
Website : https://github.com/bil-elmoussaoui/Hardcode-Tray | ||
Licence : The script is released under GPL, uses a modified script | ||
form Chromium project released under BSD license | ||
|
@@ -32,7 +32,7 @@ | |
from modules.const import (USERHOME, CHMOD_IGNORE_LIST, USER_ID, GROUP_ID, LOG_FILE_FORMAT, BACKUP_EXTENSION, | ||
BACKUP_FOLDER, BACKUP_FILE_FORMAT) | ||
from gi.repository import Gio | ||
|
||
from json import load | ||
|
||
def setup_logging(): | ||
"""Setup logging handlern write to a file under /tmp.""" | ||
|
@@ -68,6 +68,16 @@ def progress(count, count_max, app_name=""): | |
stdout.flush() | ||
|
||
|
||
def parse_json(file_name): | ||
"""Parse json file and return the object.""" | ||
if path.isfile(file_name): | ||
with open(file_name, 'r') as data: | ||
json = load(data) | ||
data.close() | ||
return json | ||
return {} | ||
|
||
|
||
def symlink_file(source, link_name): | ||
"""Symlink a file, remove the dest file if already exists.""" | ||
try: | ||
|
Oops, something went wrong.