Skip to content

Commit

Permalink
update readme, better packaging & easier installation
Browse files Browse the repository at this point in the history
  • Loading branch information
C2N14 committed Aug 3, 2018
1 parent 0cc1a61 commit 8ccf70d
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 46 deletions.
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

![](automathemely/lib/automathemely_large.svg)
![AutomaThemely icon](automathemely/lib/automathemely_large.svg)

# AutomaThemely

Expand All @@ -9,41 +9,40 @@ Simple, set-and-forget python application for changing between GNOME themes acco

### Prerequisites

* Obviously having the GNOME desktop environment (or maybe not, see [notes](#notes) for more info)
* Obviously having the GNOME desktop environment
* Python 3.5+
* Crontab
* GTK+ 3.0+ (optional for the moment, for the settings manager GUI)
* pip3 (optional, for installation)
* GTK 3.0+
* pip3 (will be installed if package with dependencies is installed, otherwise it must be manually installed)

### Installing

**[RECOMMENDED]** You can go to [releases](https://github.com/C2N14/AutomaThemely/releases) and download whichever package suits your needs
You can go to [releases](https://github.com/C2N14/AutomaThemely/releases) and download whichever package suits your needs

Or clone the project and install it yourself (icons and shortcuts will not be installed)
Because of the several python versions different distros have, here are my recommendations for the following distros:

```
git clone https://github.com/C2N14/AutomaThemely.git
cd AutomaThemely
python3 setup.py install
```
| Distro | Recommendation |
| --- | --- |
| Ubuntu 16.04 | Manually install all the python dependencies with pip3 and install the python 3.5 no dependencies package |
| Ubuntu 18.04 | Just install the regular python 3.6 package and all the dependencies should be available |
| Other distros | Check your python version, and if it is equal or above 3.5 but not listed in the releases page you can try [packaging it yourself](https://github.com/C2N14/AutomaThemely/wiki/Packaging-it-yourself)

### Running

Once installed, run once to generate a settings file

```
```bash
automathemely
```

And then run again with `-m` or `--manage` use the settings manager (requires GTK 3.0+)

```
```bash
automathemely --manage
```

Or manually set the settings with `-s` or `--setting` if you somehow don't have GTK in your system

```
```bash
# To show all the available options
automathemely --list
# For example:
Expand All @@ -52,26 +51,26 @@ automathemely --setting themes.light=Adwaita

Or you can even manually edit the configuration file in `/home/user/.config/AutomaThemely`

Finally, update all the necessary crontabs to make sure it runs at the right hours
Finally, you can either restart your computer or run the following to make sure it runs at the right hours and also start the scheduler so it starts working

```
```bash
# Update sunrise and sunset times
automathemely --update
# Start the scheduler
automathemely --restart
```

### Adding to startup/login

If you are like most users and don't leave your computer on 24/7, you should most likely add it to startup to get the most out of it (that is, if you don't want to run it everytime you login). Depending on your distro this instructions will be different. For Ubuntu and other similar systems you can follow [these instructions](https://askubuntu.com/questions/48321/how-do-i-start-applications-automatically-on-login)
And that's it!

### Running it manually

In the case of it failing to do its job (please report to [issues](https://github.com/C2N14/AutomaThemely/issues)) you can always run it manually to try to fix it by running `automathemely` or by the icon on the application tray
In the case of it failing to do its job (please report to [issues](https://github.com/C2N14/AutomaThemely/issues)) you can always try to restart the scheduler or run it manually to try to fix it by running `automathemely` or by the icon on the application tray

## Notes

* This program assumes that a day in your location has both sunrise and sunset in the same 0 to 24 hr day span, and if you decide to set a custom time offset make sure both of these events still occur within this span
* Although it is specifically made for GNOME, it should be compatible with Unity and other GNOME based environments, and other desktop environments *could* be implemented in the future.
* Although it is specifically made for GNOME, it should be compatible with Unity and other GNOME based environments.
* This program requires an active internet connection **ONLY** if you set *Auto Location* on (it uses your ip to determine your geolocation), otherwise you can manually set your location and you won't need it.
* You should never really manually edit the version number on the configuration file because it will most likely be overwritten
* Tested with Ubuntu 18.04 & Ubuntu 16.04
* Yeah, yeah, I know that icon is an eyesore but I'm no designer so it'll have to do until a better one is made ¯\\\_(ツ)_

Expand Down
2 changes: 1 addition & 1 deletion automathemely/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

_ROOT = os.path.abspath(os.path.dirname(__file__))
__version__ = 1.1
__version__ = 1.2


def get_resource(path=''):
Expand Down
2 changes: 1 addition & 1 deletion automathemely/autoth_tools/extratools.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_extra_themes(extra, placeholder=False):
# All possible paths that I know of that can contain VSCode extensions
vscode_extensions_paths = ['/snap/vscode/current/usr/share/code/resources/app/extensions',
'/usr/share/code/resources/app/extensions',
os.path.join(Path.home(), '.vscode/extensions')]
os.path.join(str(Path.home()), '.vscode/extensions')]
vscode_themes = []
for p in vscode_extensions_paths:
vscode_themes += scan_vscode_extensions(p)
Expand Down
4 changes: 2 additions & 2 deletions automathemely/autoth_tools/settsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def get_installed_themes():
# All paths that I know of that can contain GTK themes
gtk_paths = [
'/usr/share/themes/',
os.path.join(Path.home(), '.themes/'),
os.path.join(Path.home(), '.local/share/themes/')
os.path.join(str(Path.home()), '.themes/'),
os.path.join(str(Path.home()), '.local/share/themes/')
]
for directory in gtk_paths:
t = [d.replace(directory, '').replace('/', '') for d in glob('{}*/'.format(directory))]
Expand Down
6 changes: 5 additions & 1 deletion automathemely/lib/automathemely.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Exec=automathemely
Icon=automathemely
Terminal=false
StartupNotify=false
Actions=Manage;Update;
Actions=Manage;Update;Restart;

[Desktop Action Manage]
Exec=automathemely --manage
Expand All @@ -15,3 +15,7 @@ Name=Manage settings
[Desktop Action Update]
Exec=automathemely --update
Name= Update sun times

[Desktop Action Restart]
Exec=automathemely --restart
Name= Restart the scheduler
2 changes: 1 addition & 1 deletion automathemely/lib/default_user_settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1.1,
"version": 1.2,
"themes": {
"light": "",
"dark": ""
Expand Down
58 changes: 45 additions & 13 deletions install_scripts/.package.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#!/bin/bash

if_not_dir_create () {
if [ ! -d "$1" ]; then
mkdir -p "$1"
fi
}

declare -a outputs=("deb" "rpm" "sh")
declare -a pypacks=("astral" "requests" "tz" "tzlocal" "schedule")
declare -a otherdeps=("python3-pip")
declare -a python_versions=("3.5" "3.6")

declare -a original_files=(*)

deps=""
for p in "${pypacks[@]}"
Expand All @@ -15,17 +24,40 @@ do
deps="$deps-d $d "
done

for out in "${outputs[@]}"
do
fpm -s python -t "${out}" -f -n 'automathemely' --python-bin python3 --python-pip pip3 \
--python-package-name-prefix python3 --no-python-dependencies ${deps}--after-install postinst.sh \
--before-remove preremove.sh ../setup.py
done
for pyth_v in "${python_versions[@]}"; do
# NO_DEPS PACKAGING
for out in "${outputs[@]}"
do
fpm -s python -t "${out}" -f -n 'automathemely' --python-bin python${pyth_v} --python-pip pip3 \
--python-package-name-prefix python3 --no-python-dependencies --after-install postinst.sh \
--before-remove preremove.sh ../setup.py
done

for file in *; do
if [[ ! " ${original_files[@]} " =~ " ${file} " ]]; then
mv "$file" "no_deps-${file}"
fi
done

# DEPS PACKAGING
for out in "${outputs[@]}"
do
fpm -s python -t "${out}" -f -n 'automathemely' --python-bin python${pyth_v} --python-pip pip3 \
--python-package-name-prefix python3 --no-python-dependencies ${deps}--after-install postinst.sh \
--before-remove preremove.sh ../setup.py
done

for file in *; do
if [[ ! " ${original_files[@]} " =~ " ${file} " ]]; then
mv "$file" "python${pyth_v}-${file}"
fi
done

version="$(echo python${pyth_v}-automathemely*.deb | grep -o -P '(?<=_).*(?=_)')"

version="$(echo *.deb | grep -o -P '(?<=_).*(?=_)')"
if [ "$version" != "" ]
then
shopt -s extglob
mkdir "../releases/v$version"
mv automathemely* "../releases/v$version"
fi
if [ "$version" != "" ]
then
if_not_dir_create "../releases/python${pyth_v}/v$version"
mv *automathemely* "../releases/python${pyth_v}/v$version"
fi
done
4 changes: 2 additions & 2 deletions install_scripts/postinst.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

packdir="$(pip3 show automathemely | grep -oP "^Location: \K.*")/automathemely"
USER_HOME="$(getent passwd $SUDO_USER | cut -d: -f6)"
packdir="$(sudo -u ${SUDO_USER} python3 -m pip show automathemely | grep -oP "^Location: \K.*")/automathemely"

if_not_dir_create () {
if [ ! -d "$1" ]; then
Expand Down Expand Up @@ -59,4 +59,4 @@ sudo -E -u $SUDO_USER systemctl --user --global start automathemely.timer
# REMOVE OBSOLETE STUFF
# Crontab removal
# If crontabs are not installed carries on
crontab -u $SUDO_USER -l | awk ' !/sunrise_change_theme/ && !/sunset_change_theme/ && !/update_sunhours_daily/ && !/update_sunhours_reboot/ { print }' | crontab -u $SUDO_USER -
(crontab -u $SUDO_USER -l | awk ' !/sunrise_change_theme/ && !/sunset_change_theme/ && !/update_sunhours_daily/ && !/update_sunhours_reboot/ { print }' | crontab -u $SUDO_USER -) || true
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_package_files(directory):

setup(
name='AutomaThemely',
version=1.15,
version=version,
description='Simple, set-and-forget python application for changing between GNOME themes according to light and '
'dark hours',
long_description=long_description,
Expand All @@ -27,7 +27,7 @@ def get_package_files(directory):
url='https://github.com/C2N14/AutomaThemely',
license='GPLv3',
packages=['automathemely', 'automathemely.bin', 'automathemely.autoth_tools'],
python_requires='>3.5',
python_requires='>=3.5',
install_requires=['requests', 'astral', 'pytz', 'tzlocal', 'schedule'],
include_package_data=True,
package_data={'automathemely': get_package_files('automathemely/lib')+['../automathemely/bin/systemd-trigger.sh']},
Expand Down

0 comments on commit 8ccf70d

Please sign in to comment.