Skip to content

Commit

Permalink
Merge pull request #151 from JokaJukka/master
Browse files Browse the repository at this point in the history
Systemd file exists check & update docs
  • Loading branch information
l0drex authored Jan 3, 2023
2 parents 333a72a + 17d33ac commit ed3b814
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
Binary file modified .github/images/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/images/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,38 @@ and also themes your favourite editors like VSCode or Atom.
![](https://img.shields.io/badge/Build%20with-Python-yellow)
![](https://img.shields.io/github/license/oskarsh/yin-yang)

![](.github/images/header.png)
![Visualization](.github/images/header.png)
![App configuration](.github/images/settings.png)

## Features

![](.github/images/settings.png)

* Changes your themes at certain times or sunrise and sunset
* Supported Desktops:
* Gnome
* Budgie
* KDE Plasma
* Supported applications:
* VSCode
* Atom
* VSCode, Atom, gedit
* Firefox & Brave
* Kvantum
* Konsole
* OnlyOffice
* and more...
* Miscellaneous:
* Wallpaper change
* Notifications on theme change
* Play a sound
* Ability to run custom scripts

> To see planned features and the development status, visit the [project status page](https://github.com/oskarsh/Yin-Yang/projects?type=classic).
## Installation

### Dependencies:
### Arch-based distributions
Yin-Yang can be downloaded from AUR as [yin-yang](https://aur.archlinux.org/packages/yin-yang) package.


### Source
Yin-Yang depends on `python-systemd` and `pyside6` from pypi. `python-systemd` requires you have installed the systemd-headers from your package manager.

For CentOS, RHEL, and Fedora:
Expand All @@ -49,7 +57,7 @@ sudo apt update
sudo apt install libsystemd-dev gcc
```

### Yin-Yang
Then you can install Yin-Yang in a python virtual environemnt:
```bash
git clone https://github.com/oskarsh/Yin-Yang && cd Yin-Yang
## Create virtual environment for pypi packages
Expand Down
17 changes: 16 additions & 1 deletion src/daemon_handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import os
import shutil
import subprocess
from enum import Enum, auto
from pathlib import Path
Expand All @@ -7,14 +9,27 @@
from src.meta import ConfigEvent, Modes

logger = logging.getLogger(__name__)
TIMER_PATH = str(Path.home()) + '/.local/share/systemd/user/yin_yang.timer'
SYSTEMD_PATH = str(Path.home()) + '/.local/share/systemd/user/'
TIMER_PATH = SYSTEMD_PATH + "yin_yang.timer"


def create_files():
logger.debug('Creating systemd files')
if not os.path.exists(SYSTEMD_PATH):
os.makedirs(SYSTEMD_PATH)

shutil.copy('./resources/yin_yang.timer', TIMER_PATH)
shutil.copy('./resources/yin_yang.service', TIMER_PATH.replace('timer', 'service'))


def run_command(command, **kwargs):
return subprocess.run(['systemctl', '--user', command, 'yin_yang.timer'], **kwargs)


def update_times():
if not Path(TIMER_PATH).is_file():
create_files()

if config.mode == Modes.MANUAL:
run_command('stop')
logger.debug('Stopping systemd timer')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_daemon_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def tearDown(self) -> None:
def setUpClass(cls) -> None:
super().setUpClass()
if not isfile(daemon_handler.TIMER_PATH):
pathlib.Path(daemon_handler.TIMER_PATH.replace('yin_yang.timer', '')).mkdir(parents=True, exist_ok=True)
pathlib.Path(daemon_handler.SYSTEMD_PATH).mkdir(parents=True, exist_ok=True)
shutil.copyfile('./resources/yin_yang.timer', daemon_handler.TIMER_PATH)
shutil.copyfile('./resources/yin_yang.service', daemon_handler.TIMER_PATH.replace('timer', 'service'))
shutil.copyfile(daemon_handler.TIMER_PATH, daemon_handler.TIMER_PATH + '_backup')
Expand Down

0 comments on commit ed3b814

Please sign in to comment.