Bug fixes and performance improvements

This commit is contained in:
Ferit Yiğit BALABAN 2022-03-21 00:00:51 +03:00
parent ad97d9f0bc
commit e4c96bab71
No known key found for this signature in database
GPG Key ID: BB8494BA65A90842
2 changed files with 26 additions and 26 deletions

View File

@ -33,15 +33,16 @@ updates repositories kept in $HOME/sources by calling 'git pull' using subproces
dependencies: dependencies:
- [termcolor](https://pypi.org/project/termcolor) - [termcolor](https://pypi.org/project/termcolor)
### launch_polybar.sh ### launch_polybar
used by i3wm to launch polybar on occasions. ripped it off from arch wiki ;) used by i3wm (or me) to launch polybar on occasions. this script first checks for polybar instances, and exits if there is any; however if no instances exist, a new polybar will pop up, *quietly*!
used by: used by:
- i3wm configuration - i3wm configuration
- [source_polybar.py](https://github.com/fybalaban/scripts#source_polybarpy) - [source_polybar.py](https://github.com/fybalaban/scripts#source_polybarpy)
dependencies: dependencies:
- [fish](https://github.com/fish-shell/fish-shell) installation
- [polybar](https://github.com/polybar/polybar) - [polybar](https://github.com/polybar/polybar)
### source_polybar.py ### source_polybar.py
@ -77,7 +78,7 @@ dependencies:
## dotman.py ## dotman.py
dotman is (yet) another DOTfiles MANager that **I've** made for **my** machine. dotman is (yet) another DOTfiles MANager that ***I've*** made for ***my*** machine.
- Will it work on yours? Probably. - Will it work on yours? Probably.
- Do you really need it? Probably not. - Do you really need it? Probably not.
@ -88,8 +89,9 @@ dotman is (yet) another DOTfiles MANager that **I've** made for **my** machine.
- [x] Deploy to $HOME/.config - [x] Deploy to $HOME/.config
- [x] Interactive mode - [x] Interactive mode
- [x] Automatable mode - [x] Automatable mode
- [ ] Verbose output - [x] Verbose output
- [ ] Logging capability - [ ] Logging capability
dependencies: dependencies:
- python installation lol - python installation lol
- aw hell nah. [termcolor](https://pypi.org/project/termcolor) again

View File

@ -6,14 +6,13 @@ import os.path
from subprocess import run from subprocess import run
import sys import sys
from datetime import datetime as dt from datetime import datetime as dt
from termcolor import colored from termcolor import colored, cprint
from termcolor import cprint
DOTFILES_REPOSITORY = '$HOME/repos/dotfiles' DOTFILES_REPOSITORY = '$HOME/repos/dotfiles'
REMOTE_REPOSITORY = 'https://github.com/fybalaban/dotfiles' REMOTE_REPOSITORY = 'https://github.com/fybalaban/dotfiles'
LOCAL_CONFIG = '$HOME/.config' LOCAL_CONFIG = '$HOME/.config'
VER = 'v1.1' VER = 'v1.4'
help_message = f''' help_message = f'''
dotman {VER} dotfiles manager by fyb dotman {VER} dotfiles manager by fyb
@ -39,11 +38,14 @@ def remove_from_left_until_slash(text):
def proc(command, cwd=''): def proc(command, cwd=''):
if cwd == '': if 'cp -av' in command:
r = run(command, shell=True, capture_output=True, text=True) r = run(command, shell=True)
else: else:
r = run(command, shell=True, capture_output=True, text=True, cwd=cwd) if cwd == '':
return r.returncode, r.stdout r = run(command, shell=True, capture_output=True, text=True)
else:
r = run(command, shell=True, capture_output=True, text=True, cwd=cwd)
return r.returncode, str(r.stdout)
def prclr(text, color): def prclr(text, color):
@ -56,9 +58,8 @@ def grab_dotfiles():
return code == 0, code return code == 0, code
def copy(source, dest, method='subprocess'): def copy(source, dest):
if method == 'subprocess': proc(f'cp -av {source} {dest}')
proc(f'cp -av {source} {dest}')
def special_copy(source, dest): def special_copy(source, dest):
@ -76,16 +77,12 @@ def special_copy(source, dest):
'rofi' 'rofi'
] ]
dirs = os.listdir(source) dirs = os.listdir(source)
full_dirs = [] selected_dirs = []
for each_name in dirs: for each_name in dirs:
if each_name not in whitelist: if each_name in whitelist:
dirs.remove(each_name) selected_dirs.append(f'{source}{each_name}' if source.endswith('/') else f'{source}/{each_name}')
elif source.endswith('/'): for directory in selected_dirs:
full_dirs.append(source + each_name) copy(directory, dest)
else:
full_dirs.append(source + '/' + each_name)
for directory in full_dirs:
copy(directory, dest, 'subprocess')
def git_commit(): def git_commit():
@ -96,6 +93,7 @@ def git_commit():
if flag_commit: if flag_commit:
date = dt.now().strftime('%d.%m.%Y %H.%M') date = dt.now().strftime('%d.%m.%Y %H.%M')
proc(f'/usr/bin/git commit -m "dotman {date}"', DOTFILES_REPOSITORY) proc(f'/usr/bin/git commit -m "dotman {date}"', DOTFILES_REPOSITORY)
return flag_commit
def push_remote(): def push_remote():
@ -153,8 +151,8 @@ def main():
print('You can either backup to remote, or copy local repo to local config (deploy)') print('You can either backup to remote, or copy local repo to local config (deploy)')
ans = input('(B)ackup or (D)eploy: ') ans = input('(B)ackup or (D)eploy: ')
if ans.lower() == 'b' or ans.lower() == 'backup': if ans.lower() == 'b' or ans.lower() == 'backup':
print(colored('Step 1: ', 'magenta'), 'Copy from local config', colored("{LOCAL_CONFIG}", 'yellow'), print(colored('Step 1: ', 'magenta'), 'Copy from local config', colored(f'"{LOCAL_CONFIG}"', 'yellow'),
'to local repo', colored('"DOTFILES_REPOSITORY"', 'yellow')) 'to local repo', colored(f'"{DOTFILES_REPOSITORY}"', 'yellow'))
special_copy(LOCAL_CONFIG, DOTFILES_REPOSITORY) special_copy(LOCAL_CONFIG, DOTFILES_REPOSITORY)
print(colored('Step 2: ', 'magenta'), f'Create a commit and push to remote repo', print(colored('Step 2: ', 'magenta'), f'Create a commit and push to remote repo',
colored(f'"{REMOTE_REPOSITORY}"', 'yellow')) colored(f'"{REMOTE_REPOSITORY}"', 'yellow'))