mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2025-04-28 05:02:26 +00:00
package_kwarg is now aur instead of yay, .vimrc check
This commit is contained in:
parent
b5a357f57b
commit
357903d5b6
3 changed files with 74 additions and 16 deletions
|
@ -13,7 +13,7 @@ def make_backup(files_dir):
|
||||||
Path.get_home(), file.replace(f'{files_dir}/', ''))
|
Path.get_home(), file.replace(f'{files_dir}/', ''))
|
||||||
to_pos = os.path.join(
|
to_pos = os.path.join(
|
||||||
current_backup_dir, file.replace(f'{files_dir}/', ''))
|
current_backup_dir, file.replace(f'{files_dir}/', ''))
|
||||||
if os.path.isfile(from_pos):
|
if Path.check_file_exists(from_pos):
|
||||||
Path.copy(from_pos, to_pos)
|
Path.copy(from_pos, to_pos)
|
||||||
|
|
||||||
Print.action('Backup complete')
|
Print.action('Backup complete')
|
||||||
|
@ -29,7 +29,12 @@ def check_installation():
|
||||||
Print.err('Dotfiles installation cancelled - zsh not installed')
|
Print.err('Dotfiles installation cancelled - zsh not installed')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
global oh_my_zsh_path
|
global oh_my_zsh_path, zsh_highlight_path
|
||||||
|
|
||||||
|
zsh_highlight_path = None
|
||||||
|
if Path.check_file_exists('/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh'):
|
||||||
|
zsh_highlight_path = '/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh'
|
||||||
|
|
||||||
oh_my_zsh_path = None
|
oh_my_zsh_path = None
|
||||||
if Path.check_dir_exists('~/.oh-my-zsh'):
|
if Path.check_dir_exists('~/.oh-my-zsh'):
|
||||||
oh_my_zsh_path = '$HOME/.oh-my-zsh'
|
oh_my_zsh_path = '$HOME/.oh-my-zsh'
|
||||||
|
@ -50,18 +55,43 @@ def check_installation():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def personalized_changes(file):
|
def personalized_changes(file):
|
||||||
if '.zshrc' in file:
|
if '.zshrc' in file:
|
||||||
|
global oh_my_zsh_path, zsh_highlight_path
|
||||||
filedata = None
|
filedata = None
|
||||||
with open(file, 'r') as f:
|
with open(file, 'r') as f:
|
||||||
filedata = f.read()
|
filedata = f.read()
|
||||||
filedata_old = filedata
|
filedata_old = filedata
|
||||||
|
|
||||||
|
# Change path to oh-my-zsh
|
||||||
filedata = filedata.replace('"$HOME/.config/oh-my-zsh"', f'"{oh_my_zsh_path}"')
|
filedata = filedata.replace('"$HOME/.config/oh-my-zsh"', f'"{oh_my_zsh_path}"')
|
||||||
|
|
||||||
|
# Change path to zsh-color-highlight
|
||||||
|
if zsh_highlight_path is not None:
|
||||||
|
original_path='/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh'
|
||||||
|
filedata = filedata.replace(f'source {original_path}', f'source {zsh_highlight_path}')
|
||||||
|
else:
|
||||||
|
if Install.package('zsh-syntax-highlighting', 'default'):
|
||||||
|
zsh_highlight_path = Input.question('Please specify path to your zsh-syntax-highlighting plugin (blank=do not include)')
|
||||||
|
if zsh_highlight_path != '':
|
||||||
|
filedata = filedata.replace(f'source {original_path}', f'source {zsh_highlight_path}')
|
||||||
|
else:
|
||||||
|
filedata = filedata.replace(f'source {original_path}', f'')
|
||||||
|
else:
|
||||||
|
filedata = filedata.replace(f'source {original_path}', f'')
|
||||||
|
|
||||||
if filedata_old != filedata:
|
if filedata_old != filedata:
|
||||||
Print.commend('Changing oh-my-zsh location in .zshrc')
|
Print.commend('Changing oh-my-zsh location in .zshrc')
|
||||||
with open(file, 'w') as f:
|
with open(file, 'w') as f:
|
||||||
f.write(filedata)
|
f.write(filedata)
|
||||||
|
|
||||||
|
if 'vimrc' in file:
|
||||||
|
if not Input.yes_no('Do you wish to use .vimrc (If you choose yes, please install Vundle or you will get errors)'):
|
||||||
|
# TODO: Install vundle
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def init(symlink):
|
def init(symlink):
|
||||||
# Get path to files/ floder (contains all dotfiles)
|
# Get path to files/ floder (contains all dotfiles)
|
||||||
|
|
43
lib.py
43
lib.py
|
@ -202,6 +202,9 @@ class Input:
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def question(text):
|
||||||
|
Print.question(text)
|
||||||
|
return input(' >>')
|
||||||
|
|
||||||
class Install:
|
class Install:
|
||||||
|
|
||||||
|
@ -296,11 +299,13 @@ class Install:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
Print.cancel('Skipping...')
|
Print.cancel('Skipping...')
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
Print.cancel(
|
Print.cancel(
|
||||||
f'assuming {repository} already installed ({repository} is installed)')
|
f'assuming {repository} already installed ({repository} is installed)')
|
||||||
|
return True
|
||||||
|
|
||||||
def package(package_name, install_text='default', use_yay=False, reinstall=False):
|
def package(package_name, install_text='default', aur=False, reinstall=False):
|
||||||
'''Installation of package
|
'''Installation of package
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
@ -314,16 +319,16 @@ class Install:
|
||||||
Returns:
|
Returns:
|
||||||
bool -- installed
|
bool -- installed
|
||||||
'''
|
'''
|
||||||
if use_yay:
|
if aur:
|
||||||
if Install.check_not_installed('yay'):
|
if Install.check_not_installed('yay'):
|
||||||
Print.warning(
|
Print.cancel(
|
||||||
f'Unable to install AUR package: {package_name}, yay is not installed')
|
f'Unable to install with yay (not installed), installing AUR package: {package_name} with git instead')
|
||||||
return False
|
Install.git_aur(package_name, install_text)
|
||||||
if Install.check_not_installed(package_name) or reinstall:
|
if Install.check_not_installed(package_name) or reinstall:
|
||||||
install_text = Install._generate_install_text(
|
install_text = Install._generate_install_text(
|
||||||
install_text, package_name, yay=use_yay)
|
install_text, package_name, yay=aur)
|
||||||
if Input.yes_no(install_text):
|
if Input.yes_no(install_text):
|
||||||
if use_yay:
|
if aur:
|
||||||
Command.execute(f'yay -S {package_name}')
|
Command.execute(f'yay -S {package_name}')
|
||||||
else:
|
else:
|
||||||
Command.execute(f'sudo pacman -S {package_name}')
|
Command.execute(f'sudo pacman -S {package_name}')
|
||||||
|
@ -333,7 +338,7 @@ class Install:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
Print.cancel(f'{package_name} already installed')
|
Print.cancel(f'{package_name} already installed')
|
||||||
return False
|
return True
|
||||||
|
|
||||||
def multiple_packages(packages, install_text, options=False, reinstall=False):
|
def multiple_packages(packages, install_text, options=False, reinstall=False):
|
||||||
'''Installation of multiple packages
|
'''Installation of multiple packages
|
||||||
|
@ -392,6 +397,26 @@ class Path:
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def check_file_exists(paths):
|
||||||
|
'''Check for file/s existence
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
paths {str} -- single path or multiple paths separated by spaces (absolute paths)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool -- One of files exists/Single file exists
|
||||||
|
'''
|
||||||
|
if type(paths) != str:
|
||||||
|
paths = str(paths)
|
||||||
|
paths = paths.split(' ')
|
||||||
|
for file_path in paths:
|
||||||
|
file_path = os.path.expanduser(file_path)
|
||||||
|
if os.path.isfile(file_path):
|
||||||
|
return True
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def get_parent(file_path):
|
def get_parent(file_path):
|
||||||
'''Get Parent directory of specified file
|
'''Get Parent directory of specified file
|
||||||
|
|
||||||
|
@ -448,7 +473,7 @@ class Path:
|
||||||
'''
|
'''
|
||||||
if not absolute_path:
|
if not absolute_path:
|
||||||
path = pathlib.Path(path).absolute()
|
path = pathlib.Path(path).absolute()
|
||||||
if os.path.isfile(path):
|
if Path.check_file_exists(path):
|
||||||
path = Path.get_parent(path)
|
path = Path.get_parent(path)
|
||||||
|
|
||||||
if not Path.check_dir_exists(path):
|
if not Path.check_dir_exists(path):
|
||||||
|
|
|
@ -10,7 +10,6 @@ def main():
|
||||||
Install.package('networkmanager')
|
Install.package('networkmanager')
|
||||||
Install.package(
|
Install.package(
|
||||||
'git', 'default + (Required for some installations, otherwise they\'ll be skipped)')
|
'git', 'default + (Required for some installations, otherwise they\'ll be skipped)')
|
||||||
Install.package('zsh', 'default + shell')
|
|
||||||
Install.package('sudo')
|
Install.package('sudo')
|
||||||
|
|
||||||
# Desktop Enviroment
|
# Desktop Enviroment
|
||||||
|
@ -21,23 +20,27 @@ def main():
|
||||||
'SDDM (KDE)', 'GDM (Gnome)', 'LightDM'])
|
'SDDM (KDE)', 'GDM (Gnome)', 'LightDM'])
|
||||||
|
|
||||||
Install.package('base-devel', 'default + (Required for makepkg installs)')
|
Install.package('base-devel', 'default + (Required for makepkg installs)')
|
||||||
Install.git_aur(
|
Install.package('yay', 'default', aur=True)
|
||||||
'yay', 'default + (Required for some installations, otherwise they\'ll be skipped)')
|
Install.package('vim')
|
||||||
Install.package('exa', 'default + (Better ls tool)')
|
Install.package('exa', 'default + (Better ls tool)')
|
||||||
|
Install.package('zsh', 'default + (Shell)')
|
||||||
|
Install.package('zsh-syntax-highlighting', 'default')
|
||||||
Install.package('terminator', 'default + (advanced terminal)')
|
Install.package('terminator', 'default + (advanced terminal)')
|
||||||
Install.package('konsole', 'default + (KDE terminal emulator)')
|
Install.package('konsole', 'default + (KDE terminal emulator)')
|
||||||
Install.package(
|
Install.package(
|
||||||
'ark', 'default + (Managing various archive formats such as tar, gzip, zip, rar, etc.)')
|
'ark', 'default + (Managing various archive formats such as tar, gzip, zip, rar, etc.)')
|
||||||
|
Install.package('timeshift', 'default + (Backup Tool), aur=True')
|
||||||
Install.package('cron', 'default + (Task scheduling)')
|
Install.package('cron', 'default + (Task scheduling)')
|
||||||
Install.package('dolphin', 'default + (File Manager)')
|
Install.package('dolphin', 'default + (File Manager)')
|
||||||
Install.package('nomacs', 'default + (Photo viewer & editor)')
|
Install.package('nomacs', 'default + (Photo viewer & editor)')
|
||||||
Install.package('discord', 'default + (Chat App)')
|
Install.package('discord', 'default + (Chat App)')
|
||||||
|
Install.package('caprine', 'default + (Unofficial Messenger Chat App)')
|
||||||
Install.package(
|
Install.package(
|
||||||
'spotify', 'default + (Online Music Player)', use_yay=True)
|
'spotify', 'default + (Online Music Player)', aur=True)
|
||||||
Install.package(
|
Install.package(
|
||||||
'spectacle', 'default + (Screenshot tool)')
|
'spectacle', 'default + (Screenshot tool)')
|
||||||
Install.package('qalculate-gtk-nognome',
|
Install.package('qalculate-gtk-nognome',
|
||||||
'Do you wish to install Qalculate! (Complex Calculator)?', use_yay=True)
|
'Do you wish to install Qalculate! (Complex Calculator)?', aur=True)
|
||||||
Install.package('gnome-system-monitor',
|
Install.package('gnome-system-monitor',
|
||||||
'Do you wish to install gnome system monitor?')
|
'Do you wish to install gnome system monitor?')
|
||||||
Install.package(
|
Install.package(
|
||||||
|
|
Loading…
Add table
Reference in a new issue