Fix icons and desktop file installation (#408)
This commit is contained in:
parent
41464e4ebc
commit
a51ff8bff0
|
@ -104,4 +104,13 @@ safeeyes/config/locale/*/LC_MESSAGES/safeeyes.po~
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
# PyCharm
|
# PyCharm
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
# Debian Build
|
||||||
|
.pybuild/
|
||||||
|
debian/safeeyes
|
||||||
|
debian/.debhelper
|
||||||
|
debian/files
|
||||||
|
debian/safeeyes.substvars
|
||||||
|
debian/safeeyes.prerm.debhelper
|
||||||
|
debian/safeeyes.postinst.debhelper
|
|
@ -0,0 +1,17 @@
|
||||||
|
safeeyes/platform/safeeyes.desktop usr/share/applications
|
||||||
|
safeeyes/platform/icons/hicolor/128x128/apps/safeeyes.png usr/share/icons/hicolor/128x128/apps
|
||||||
|
safeeyes/platform/icons/hicolor/16x16/apps/safeeyes.png usr/share/icons/hicolor/16x16/apps
|
||||||
|
safeeyes/platform/icons/hicolor/16x16/status/safeeyes_disabled.png usr/share/icons/hicolor/16x16/status
|
||||||
|
safeeyes/platform/icons/hicolor/16x16/status/safeeyes_enabled.png usr/share/icons/hicolor/16x16/status
|
||||||
|
safeeyes/platform/icons/hicolor/16x16/status/safeeyes_timer.png usr/share/icons/hicolor/16x16/status
|
||||||
|
safeeyes/platform/icons/hicolor/24x24/apps/safeeyes.png usr/share/icons/hicolor/24x24/apps
|
||||||
|
safeeyes/platform/icons/hicolor/24x24/status/safeeyes_disabled.png usr/share/icons/hicolor/24x24/status
|
||||||
|
safeeyes/platform/icons/hicolor/24x24/status/safeeyes_enabled.png usr/share/icons/hicolor/24x24/status
|
||||||
|
safeeyes/platform/icons/hicolor/24x24/status/safeeyes_timer.png usr/share/icons/hicolor/24x24/status
|
||||||
|
safeeyes/platform/icons/hicolor/32x32/apps/safeeyes.png usr/share/icons/hicolor/32x32/apps
|
||||||
|
safeeyes/platform/icons/hicolor/32x32/status/safeeyes_disabled.png usr/share/icons/hicolor/32x32/status
|
||||||
|
safeeyes/platform/icons/hicolor/32x32/status/safeeyes_enabled.png usr/share/icons/hicolor/32x32/status
|
||||||
|
safeeyes/platform/icons/hicolor/48x48/apps/safeeyes.png usr/share/icons/hicolor/48x48/apps
|
||||||
|
safeeyes/platform/icons/hicolor/48x48/status/safeeyes_disabled.png usr/share/icons/hicolor/48x48/status
|
||||||
|
safeeyes/platform/icons/hicolor/48x48/status/safeeyes_enabled.png usr/share/icons/hicolor/48x48/status
|
||||||
|
safeeyes/platform/icons/hicolor/64x64/apps/safeeyes.png usr/share/icons/hicolor/64x64/apps
|
|
@ -29,6 +29,7 @@ import locale
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
|
@ -381,8 +382,6 @@ def initialize_safeeyes():
|
||||||
shutil.copy2(SYSTEM_STYLE_SHEET_PATH, STYLE_SHEET_PATH)
|
shutil.copy2(SYSTEM_STYLE_SHEET_PATH, STYLE_SHEET_PATH)
|
||||||
os.chmod(STYLE_SHEET_PATH, 0o777)
|
os.chmod(STYLE_SHEET_PATH, 0o777)
|
||||||
|
|
||||||
initialize_platform()
|
|
||||||
|
|
||||||
|
|
||||||
def initialize_platform():
|
def initialize_platform():
|
||||||
"""
|
"""
|
||||||
|
@ -397,19 +396,25 @@ def initialize_platform():
|
||||||
startup_entry = os.path.join(startup_dir_path, 'safeeyes.desktop')
|
startup_entry = os.path.join(startup_dir_path, 'safeeyes.desktop')
|
||||||
|
|
||||||
# Create the folders if not exist
|
# Create the folders if not exist
|
||||||
mkdir(applications_dir_path)
|
|
||||||
mkdir(icons_dir_path)
|
mkdir(icons_dir_path)
|
||||||
mkdir(startup_dir_path)
|
mkdir(startup_dir_path)
|
||||||
|
|
||||||
# Remove existing files
|
# Remove existing files
|
||||||
delete(desktop_entry)
|
|
||||||
delete(startup_entry)
|
delete(startup_entry)
|
||||||
|
|
||||||
# Create a destop entry
|
# Create a destop entry
|
||||||
try:
|
if not os.path.exists(os.path.join(sys.prefix, "share/applications/safeeyes.desktop")):
|
||||||
os.symlink(SYSTEM_DESKTOP_FILE, desktop_entry)
|
# Create the folder if not exist
|
||||||
except OSError:
|
mkdir(applications_dir_path)
|
||||||
logging.error("Failed to create desktop entry at %s" % desktop_entry)
|
|
||||||
|
# Remove existing file
|
||||||
|
delete(desktop_entry)
|
||||||
|
|
||||||
|
# Create a link
|
||||||
|
try:
|
||||||
|
os.symlink(SYSTEM_DESKTOP_FILE, desktop_entry)
|
||||||
|
except OSError:
|
||||||
|
logging.error("Failed to create desktop entry at %s" % desktop_entry)
|
||||||
|
|
||||||
# Create the new startup entry
|
# Create the new startup entry
|
||||||
try:
|
try:
|
||||||
|
@ -422,8 +427,13 @@ def initialize_platform():
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
system_icon = os.path.join(path, filename)
|
system_icon = os.path.join(path, filename)
|
||||||
local_icon = os.path.join(icons_dir_path, os.path.relpath(system_icon, SYSTEM_ICONS))
|
local_icon = os.path.join(icons_dir_path, os.path.relpath(system_icon, SYSTEM_ICONS))
|
||||||
|
global_icon = os.path.join(sys.prefix, "share/icons", os.path.relpath(system_icon, SYSTEM_ICONS))
|
||||||
parent_dir = str(Path(local_icon).parent)
|
parent_dir = str(Path(local_icon).parent)
|
||||||
|
|
||||||
|
if os.path.exists(global_icon):
|
||||||
|
# This icon is already added to the /usr/share/icons/hicolor folder
|
||||||
|
continue
|
||||||
|
|
||||||
# Create the directory if not exists
|
# Create the directory if not exists
|
||||||
mkdir(parent_dir)
|
mkdir(parent_dir)
|
||||||
|
|
||||||
|
|
24
setup.py
24
setup.py
|
@ -36,14 +36,22 @@ def __compile_po_files():
|
||||||
subprocess.call(msgfmt_cmd, shell=True)
|
subprocess.call(msgfmt_cmd, shell=True)
|
||||||
|
|
||||||
|
|
||||||
def _data_files(path):
|
def __data_files():
|
||||||
"""
|
"""
|
||||||
Collect the data files.
|
Collect the data files.
|
||||||
"""
|
"""
|
||||||
for root, _, files in os.walk(path):
|
root_dir = sys.prefix
|
||||||
if not files:
|
return [(os.path.join(root_dir, "share/applications"), ["safeeyes/platform/safeeyes.desktop"]),
|
||||||
continue
|
(os.path.join(root_dir, "share/icons/hicolor/24x24/status"), ["safeeyes/platform/icons/hicolor/24x24/status/safeeyes_disabled.png", "safeeyes/platform/icons/hicolor/24x24/status/safeeyes_enabled.png", "safeeyes/platform/icons/hicolor/24x24/status/safeeyes_timer.png"]),
|
||||||
yield (os.path.join(site.USER_BASE or sys.prefix, root), [os.path.join(root, f) for f in files])
|
(os.path.join(root_dir, "share/icons/hicolor/24x24/apps"), ["safeeyes/platform/icons/hicolor/24x24/apps/safeeyes.png"]),
|
||||||
|
(os.path.join(root_dir, "share/icons/hicolor/16x16/status"), ["safeeyes/platform/icons/hicolor/16x16/status/safeeyes_disabled.png", "safeeyes/platform/icons/hicolor/16x16/status/safeeyes_enabled.png", "safeeyes/platform/icons/hicolor/16x16/status/safeeyes_timer.png"]),
|
||||||
|
(os.path.join(root_dir, "share/icons/hicolor/16x16/apps"), ["safeeyes/platform/icons/hicolor/16x16/apps/safeeyes.png"]),
|
||||||
|
(os.path.join(root_dir, "share/icons/hicolor/32x32/status"), ["safeeyes/platform/icons/hicolor/32x32/status/safeeyes_disabled.png", "safeeyes/platform/icons/hicolor/32x32/status/safeeyes_enabled.png"]),
|
||||||
|
(os.path.join(root_dir, "share/icons/hicolor/32x32/apps"), ["safeeyes/platform/icons/hicolor/32x32/apps/safeeyes.png"]),
|
||||||
|
(os.path.join(root_dir, "share/icons/hicolor/64x64/apps"), ["safeeyes/platform/icons/hicolor/64x64/apps/safeeyes.png"]),
|
||||||
|
(os.path.join(root_dir, "share/icons/hicolor/128x128/apps"), ["safeeyes/platform/icons/hicolor/128x128/apps/safeeyes.png"]),
|
||||||
|
(os.path.join(root_dir, "share/icons/hicolor/48x48/status"), ["safeeyes/platform/icons/hicolor/48x48/status/safeeyes_disabled.png", "safeeyes/platform/icons/hicolor/48x48/status/safeeyes_enabled.png"]),
|
||||||
|
(os.path.join(root_dir, "share/icons/hicolor/48x48/apps"), ["safeeyes/platform/icons/hicolor/48x48/apps/safeeyes.png"]),]
|
||||||
|
|
||||||
|
|
||||||
def __package_files(directory):
|
def __package_files(directory):
|
||||||
|
@ -68,10 +76,6 @@ def __package_data():
|
||||||
data.extend(__package_files('safeeyes/platform'))
|
data.extend(__package_files('safeeyes/platform'))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
# __data_files = list(_data_files('share'))
|
|
||||||
__data_files = list()
|
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="safeeyes",
|
name="safeeyes",
|
||||||
version="2.1.1",
|
version="2.1.1",
|
||||||
|
@ -84,7 +88,7 @@ setuptools.setup(
|
||||||
download_url="https://github.com/slgobinath/SafeEyes/archive/v2.1.1.tar.gz",
|
download_url="https://github.com/slgobinath/SafeEyes/archive/v2.1.1.tar.gz",
|
||||||
packages=setuptools.find_packages(),
|
packages=setuptools.find_packages(),
|
||||||
package_data={'safeeyes': __package_data()},
|
package_data={'safeeyes': __package_data()},
|
||||||
data_files=__data_files,
|
data_files=__data_files(),
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
entry_points={'console_scripts': ['safeeyes = safeeyes.__main__:main']},
|
entry_points={'console_scripts': ['safeeyes = safeeyes.__main__:main']},
|
||||||
keywords='linux utility health eye-strain safe-eyes',
|
keywords='linux utility health eye-strain safe-eyes',
|
||||||
|
|
Loading…
Reference in New Issue