예제 #1
0
파일: set.py 프로젝트: AlphaTechnolog/wallc
    def _check__config_keys(self):
        config_checker = ConfigChecker()

        if not config_checker.check('wallpaper_path'):
            error('Invalid config rules!',
                  'Please before config the wallpaper_path!, use:',
                  '$ wallc config -wp <WALLPAPER_PATH>')
예제 #2
0
파일: rm.py 프로젝트: AlphaTechnolog/wallc
    def _remove_wallpaper(self):
        if not isfile(self.complete_wall_path):
            error('Invalid wallpaper path', self.complete_wall_path,
                  'Please pass a valid file name or extension')

        remove(self.complete_wall_path)

        success('Deleted the wallpaper', self.complete_wall_path,
                'successfully!')
예제 #3
0
 def _checks(self):
     if (not self.config_checker.check(
         'wallpaper_path',
         'download_path'
     )):
         error(
             'This action is unavailable',
             'to unlock it, config the',
             'download_path && wallpaper_path rules',
             'use:',
             '$ wallc config -wp WALL_PATH -dp DOWNLOAD_PATH'
         )
예제 #4
0
파일: set.py 프로젝트: AlphaTechnolog/wallc
    def _set__wallpaper(self):
        wall_path = self.existent_config['wallpaper_path']
        args = self.app.args
        wall_name = args.wallpaper + '.' + args.extension
        wall_url = wall_path + wall_name

        if isfile(wall_url):
            subprocess.run([f'{self.app.args.program} {wall_url}'],
                           shell=True,
                           stdout=subprocess.PIPE)
        else:
            error('Invalid wallpaper url:', wall_url)

        success('Updated background to', wall_url)
예제 #5
0
    def _manage__restore__load__wallpaper(self):
        wallpaper = self.config['wallpaper']

        if isfile(wallpaper):
            subprocess.run([f'feh --bg-scale {wallpaper}'],
                           shell=True,
                           stdout=subprocess.PIPE)
        else:
            error('Invalid wallpaper url!', f'The wallpaper url: {wallpaper}',
                  'is invalid, please update it manually',
                  'editing the file ~/.wallc.conf.json', 'or use instead:',
                  '$ wallc config -wp <WALLPAPER_PATH>',
                  '$ wallc set -w <WALLPAPER_NAME> -e <WALLPAPER_EXTENSION>')

        success('Restored the wallpaper', wallpaper, 'successfully!')
예제 #6
0
 def _manage__restore__check__config_rules(self):
     if not self.config_checker.check('wallpaper_path', 'wallpaper'):
         error('Invalid config rules!',
               'Please before set a wallpaper with order:',
               '$ wallc set -w <WALLPAPER_NAME> -e <WALLPAPER_EXTENSION>')
예제 #7
0
파일: rm.py 프로젝트: AlphaTechnolog/wallc
 def _check__config_rules(self):
     if not self.config_checker.check('wallpaper_path'):
         error('Invalid config rules', 'Please before delete an image',
               'set the wallpapers path, exec:',
               '$ wallc config -wp <WALLPAPERS_PATH>')
예제 #8
0
 def _check__meta(self):
     if not 'meta' in self.config:
         error('Invalid order', 'no to merge operations')
예제 #9
0
    def merge_wallpapers(self):
        with open(self.config_path, 'r') as raw_config:
            config = json.load(raw_config)

        if not 'meta' in config:
            error(
                'Nothing to merge'
            )

        if not self.app.args.id in config['meta']:
            error(
                'Invalid id to merge'
            )

        wall_ext = config['meta'][self.app.args.id]
        wall_ext = wall_ext.split('.')[-1]
        wall_name = self.app.args.id + '.' + wall_ext

        wall_uri = (
            config['download_path'] +
            wall_name
        )

        new_wall_uri = (
            config['wallpaper_path'] +
            config['meta'][self.app.args.id]
        )

        info(
            'Moving the wallpaper ' + config['meta'][self.app.args.id],
            'from ' + wall_uri,
            'to ' + new_wall_uri
        )

        mv(
            wall_uri,
            new_wall_uri
        )

        success(
            'Moved the wallpaper',
            config['meta'][self.app.args.id]
        )

        info(
            'Refreshing merge meta information',
            'into your config file:',
            self.config_path
        )

        del config['meta'][self.app.args.id]

        if len(config['meta']) == 0:
            del config['meta']

        with open(self.config_path, 'w') as raw_config:
            json.dump(config, raw_config)

        success(
            'Refreshed your merge config',
            'Merged the wallpaper with id',
            self.app.args.id
        )