more script adds

This commit is contained in:
xsghetti 2024-03-13 13:01:33 -04:00
parent a11d325a19
commit e1df303d71
15 changed files with 621 additions and 0 deletions

26
Scripts/.old/font_glyphs.sh Executable file
View file

@ -0,0 +1,26 @@
#!/bin/bash -
Usage() { echo "$0 FontFile"; exit 1; }
SayError() { local error=$1; shift; echo "$0: $@"; exit "$error"; }
[ "$#" -ne 1 ] && Usage
width=70
fontfile="$1"
[ -f "$fontfile" ] || SayError 4 'File not found'
list=$(fc-query --format='%{charset}\n' "$fontfile")
for range in $list
do IFS=- read start end <<<"$range"
if [ "$end" ] ; then
start=$((16#$start))
end=$((16#$end))
for((i=start;i<=end;i++)) ; do
printf -v char '\\U%x' "$i"
printf '%b' "$char"
done
else
printf '%b' "\\U$start"
fi
done | grep -oP '.{'"$width"'}'

65
Scripts/.old/install_v1.sh Executable file
View file

@ -0,0 +1,65 @@
#!/bin/bash
#|---/ /+--------------------------+---/ /|#
#|--/ /-| Main installation script |--/ /-|#
#|-/ /--| Prasanth Rangan |-/ /--|#
#|/ /---+--------------------------+/ /---|#
#--------------------------------#
# import variables and functions #
#--------------------------------#
source global_fn.sh
if [ $? -ne 0 ] ; then
echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..."
exit 1
fi
#----------------------#
# prepare package list #
#----------------------#
cp custom_hypr.lst install_pkg.lst
if [ -f "$1" ] && [ ! -z "$1" ] ; then
cat $1 >> install_pkg.lst
fi
#--------------------------------#
# add nvidia drivers to the list #
#--------------------------------#
if [ `lspci -k | grep -A 2 -E "(VGA|3D)" | grep -i nvidia | wc -l` -gt 0 ] ; then
cat /usr/lib/modules/*/pkgbase | while read krnl
do
echo "${krnl}-headers" >> install_pkg.lst
done
echo -e "nvidia-dkms\nnvidia-utils" >> install_pkg.lst
sed -i "s/^hyprland-git/hyprland-nvidia-git/g" install_pkg.lst
else
echo "nvidia card not detected, skipping nvidia drivers..."
fi
#--------------------------------#
# install packages from the list #
#--------------------------------#
./install_pkg.sh install_pkg.lst
#---------------------------#
# restore my custom configs #
#---------------------------#
./restore_fnt.sh
./restore_cfg.sh
./restore_sgz.sh
#------------------------#
# enable system services #
#------------------------#
service_ctl NetworkManager
service_ctl bluetooth
service_ctl sddm

32
Scripts/.old/restore_chk.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
#|---/ /+--------------------------------------+---/ /|#
#|--/ /-| Script to compare git and local dots |--/ /-|#
#|-/ /--| Prasanth Rangan |-/ /--|#
#|/ /---+--------------------------------------+/ /---|#
source global_fn.sh
if [ $? -ne 0 ] ; then
echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..."
exit 1
fi
CfgDir=`echo $CloneDir/Configs`
while read lst
do
pth=`echo $lst | awk -F '|' '{print $1}'`
cfg=`echo $lst | awk -F '|' '{print $2}'`
pth=`eval echo $pth`
echo "${cfg}" | xargs -n 1 | while read cfg_chk
do
tgt=`echo $pth | sed "s+^${HOME}++g"`
if [ `diff -qr --no-dereference ${pth}/$cfg_chk $CfgDir$tgt/$cfg_chk | wc -l` -gt 0 ]
then
echo "diff found ${pth}/$cfg_chk <--> $CfgDir$tgt/$cfg_chk"
fi
done
done < restore_conf.lst

View file

@ -0,0 +1,105 @@
#! /usr/bin/python3
# |---/ /+----------------------------------------+---/ /|#
# |--/ /-| Script to install pkgs from input list |--/ /-|#
# |-/ /--| Effibot |-/ /--|#
# |/ /---+----------------------------------------+/ /---|#
import argparse
# get reference to directories
# ZSH_FOLDER="/usr/share/oh-my-zsh"
import os
from os.path import exists, expanduser, isdir, join
# define folders
global ZSH_FOLDER
global ZSH_CUSTOM_PLUGINS
global WORKARAOUND
global RC_FILE
# those folders are hardcoded for now because the script is
# meant to be used with the configuration of main install script
ZSH_FOLDER = expanduser("/usr/share/oh-my-zsh")
ZSH_CUSTOM_PLUGINS = join(ZSH_FOLDER, "custom/plugins")
WORKARAOUND = False
RC_FILE = os.getenv('ZDOTDIR', default='') if os.getenv('ZDOTDIR', default='') != '' else expanduser(f"/home/{os.getlogin()}/.zshrc")
# this is a workaround string to be able to load the completion plugin manually
workaround = "fpath+=${ZSH_CUSTOM:-${ZSH:-/usr/share/oh-my-zsh}/custom}/plugins/zsh-completions/src"
def get_plugin_list(input_file):
# read the input file
with open(input_file, "r") as f:
plugin_list = [line.strip() for line in f.readlines()]
if "zsh-completions" in plugin_list:
WORKARAOUND = True
return plugin_list
def generate_plugin_block(plugin_list):
"""generate the line for the .zshrc file to load the plugins"""
line = "plugins=("
to_download = []
for plugin in plugin_list:
# checks if the plugin comes from a git repo
if plugin.startswith("http"):
# if it does, append it to the list of plugins to download
to_download.append(plugin)
# get the name of the plugin and append it to the line
plugin_name = plugin.split("/")[-1].split(".")[0]
line += f"{plugin_name} "
else:
# if not, it is assumed that the plugin is in the default plugin folder
line += f"{plugin} "
line += ")\n"
return line, to_download
def download_plugins(to_download):
"""downloads the plugins from the list of plugins"""
for plugin in to_download:
plugin_name = plugin.split("/")[-1].split(".")[0]
plugin_folder = join(ZSH_CUSTOM_PLUGINS, plugin_name)
if not exists(plugin_folder) and not isdir(plugin_folder):
# os.makedirs(plugin_folder)
print(f"Downloading plugins: {plugin_name} from {plugin}")
os.system(f"git clone {plugin} {plugin_folder}")
else:
print(f"Plugin {plugin_name} already exists")
def main(input_file) -> None:
print("\nInstalling ZSH plugins\n")
# get the list of plugins
plugin_list = get_plugin_list(input_file)
# generate the line to be added to the .zshrc file
plugin_line, to_download = generate_plugin_block(plugin_list)
print(f"Your desired plugins are: {plugin_line}")
if WORKARAOUND:
print("Workaround is needed to load the completion plugin")
plugin_line += workaround + "\n"
# download the plugins
download_plugins(to_download)
# add the line to the .zshrc file
updated_line = ""
print(f"rc file is {RC_FILE}")
try:
with open(RC_FILE, "r") as f:
# search for the line that loads the plugins
f_content = f.read()
updated_line = f_content.replace("plugins=(git)", plugin_line)
with open(RC_FILE, "w") as g:
g.write(updated_line)
print("Plugin list updated")
except FileNotFoundError:
print("File not found")
except IOError as e:
print(f"IO error -> {e}")
if __name__ == "__main__":
parser = argparse.ArgumentParser("Input file containing list of plugins")
parser.add_argument("-f", help="Input file containing list of plugins")
input_file = parser.parse_args().f
main(input_file)