diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..bfd56f6
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,10 @@
+# top-most EditorConfig file
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index ce2fed8..cf6c706 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,62 +1,66 @@
name: Release on Version Change
on:
- push:
- paths:
- - '.version'
+ push:
+ paths:
+ - ".version"
jobs:
- release:
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v3
-
- - name: Read version
- id: get_version
- run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV
-
- - name: Determine if it's a pre-release
- id: pre_release_check
- run: |
- if [[ "${{ env.VERSION }}" == 0* ]]; then
- echo "PRE_RELEASE=true" >> $GITHUB_ENV
- echo "RELEASE_NAME=${{ env.VERSION }}-alpha" >> $GITHUB_ENV
- else
- echo "PRE_RELEASE=false" >> $GITHUB_ENV
- echo "RELEASE_NAME=${{ env.VERSION }}" >> $GITHUB_ENV
- fi
-
- - name: Get repository name
- id: get_repo_name
- run: echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV
-
- - name: Create a tar.gz archive
- run: |
- mkdir release
- rsync -av --progress . ./release --exclude=".git" --exclude=".github" --exclude="TODO.md" --exclude="README.md"
- tar -czvf ./${{ env.REPO_NAME }}.tar.gz -C release .
-
- - name: Create GitHub Release
- uses: softprops/action-gh-release@v1
- with:
- tag_name: ${{ env.VERSION }}
- body: "version: ${{ env.VERSION }}."
- prerelease: ${{ env.PRE_RELEASE }}
- name: ${{ env.RELEASE_NAME }}
- files: "${{ env.REPO_NAME }}.tar.gz"
- env:
- GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
-
- - name: Generate changelog from commits
- id: generate_changelog
- run: |
- CHANGELOG=$(git log -1 --pretty=%B | tr -d '\n' | sed 's/"/\\"/g')
- echo "CHANGELOG=${CHANGELOG}" >> $GITHUB_ENV
-
- - name: Update release with changelog
- run: |
- gh release edit ${{ env.VERSION }} --notes "${{ env.CHANGELOG }}"
- env:
- GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
+ release:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Read version
+ id: get_version
+ run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV
+
+ - name: Determine if it's a pre-release
+ id: pre_release_check
+ run: |
+ if [[ "${{ env.VERSION }}" == 0* ]]; then
+ echo "RELEASE_NAME=${{ env.VERSION }}-alpha" >> $GITHUB_ENV
+ else
+ echo "RELEASE_NAME=${{ env.VERSION }}" >> $GITHUB_ENV
+ fi
+
+ - name: Get repository name
+ id: get_repo_name
+ run: echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV
+
+ - name: Create a tar.gz archive
+ run: |
+ mkdir release
+ rsync -av --progress . ./release \
+ --exclude=".git"\
+ --exclude=".github"\
+ --exclude="TODO.md"\
+ --exclude="README.md"\
+ --exclude=".editorconfig"\
+ --exclude=".prettierignore"
+ tar -czvf ./${{ env.REPO_NAME }}.tar.gz -C release .
+
+ - name: Create GitHub Release
+ uses: softprops/action-gh-release@v1
+ with:
+ tag_name: ${{ env.VERSION }}
+ body: "version: ${{ env.VERSION }}."
+ prerelease: false
+ name: ${{ env.RELEASE_NAME }}
+ files: "${{ env.REPO_NAME }}.tar.gz"
+ env:
+ GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
+
+ - name: Generate changelog from commits
+ id: generate_changelog
+ run: |
+ CHANGELOG=$(git log -1 --pretty=%B | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/"/\\"/g')
+ echo "CHANGELOG=${CHANGELOG}" >> $GITHUB_ENV
+
+ - name: Update release with changelog
+ run: |
+ gh release edit ${{ env.VERSION }} --notes "$(echo -e "${{ env.CHANGELOG }}")"
+ env:
+ GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..4dd3757
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,2 @@
+README.md
+TODO.md
diff --git a/.version b/.version
index 17b2ccd..be14282 100644
--- a/.version
+++ b/.version
@@ -1 +1 @@
-0.4.3
+0.5.3
diff --git a/Assets/default-config.toml b/Assets/default-config.toml
new file mode 100644
index 0000000..e69de29
diff --git a/Assets/default-theme.toml b/Assets/default-theme.toml
new file mode 100644
index 0000000..0fc327a
--- /dev/null
+++ b/Assets/default-theme.toml
@@ -0,0 +1,3 @@
+# UI elements
+
+[ui]
diff --git a/Assets/icon-old.png b/Assets/icon-old.png
new file mode 100644
index 0000000..d9c2964
Binary files /dev/null and b/Assets/icon-old.png differ
diff --git a/Assets/icon-plain.png b/Assets/icon-plain.png
new file mode 100644
index 0000000..5e94272
Binary files /dev/null and b/Assets/icon-plain.png differ
diff --git a/Assets/icon.png b/Assets/icon.png
index d9c2964..c586ab3 100644
Binary files a/Assets/icon.png and b/Assets/icon.png differ
diff --git a/README.md b/README.md
index a5b6ee1..7a81df1 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,14 @@
-
+
+
KireiSakura-Kit
-KireiSakura-Kit
- KireiSakura-Kit is a library/framework based on Bash for making powerful shell scripts.
+ KireiSakura-Kit is a library written in Bash for making powerful shell scripts.
+
-> "KireiSakuraKit" is combination of two Japanese words, "Kirei" and "Sakura," along with the suffix "Kit".
-
+> "KireiSakura-Kit" is combination of two Japanese words, "Kirei" and "Sakura," along with the suffix "Kit".
> `Kirei(綺麗)` means "clean" & `Sakura(桜)` refers to cherry blossoms. Together, "KireiSakura-Kit" could be interpreted as a library that emphasizes a beautiful and clean design inspired by the elegance of cherry blossoms.
## Features
@@ -26,12 +26,12 @@
- Follow below steps to Install Kireisakura-Kit
-### For system wide:-
+### For system wide
- In terminal run:-
```bash
- curl -L https://raw.githubusercontent.com/soymadip/KireiSakura-Kit/refs/heads/install/install.sh | bash -s -- -ds
+ curl -L https://raw.githubusercontent.com/soymadip/KireiSakura-Kit/refs/heads/install/install.sh | bash -s
```
- Then in your script, include this line at the top:-
@@ -40,15 +40,17 @@
eval "$(kireisakura --init)"
```
-### Or directly in script:-
+### For directly using in script
+
+- This will check if Kit is installed or download & setup KireiSakura-Kit.
```bash
if command -v kireisakura &> /dev/null; then
eval "$(kireisakura --init)"
else
echo "> Installing KireiSakura-Kit"
- curl -sL https://raw.githubusercontent.com/soymadip/KireiSakura-Kit/refs/heads/install/install.sh -o kirestaller.sh
- bash kirestaller.sh
+ curl -sSL https://raw.githubusercontent.com/soymadip/KireiSakura-Kit/refs/heads/install/install.sh -o kirestaller.sh
+ bash kirestaller.sh -ds
fi
```
@@ -56,9 +58,10 @@
- Docs To be done.
- Run `kireisakura -h` for help.
-- See [my dotfiles](https://github.com/soymadip/Dotfiles/blob/dotfiles/install/start.sh) for example.
+- See [my dotfiles](https://github.com/soymadip/Dotfiles) for example.
## Warning
+- MAJOR CHANGES ARE BEING MADE as this project is in alpha, so be careful.
- As of now, some part of this library is Arch-linux centric, but can be extended to any distro.
- Contribute if you find this useful and wanna make this more powerful.
diff --git a/TODO.md b/TODO.md
index 08ec37c..fc03876 100644
--- a/TODO.md
+++ b/TODO.md
@@ -3,23 +3,65 @@
## For Initial Release:
- [x] Make `init.sh` in kit root for initialization.
+
- [x] Make setup command: `eval "$(kireisakura --init)"`
+
- [x] Make other commands:
- `kireisakura -h`
- `kireisakura -v`
- `kireisakura -d` etc.
- [x] Make a test script.
+
- [x] Make install script.
+
- [x] Better directory structure.
+- [ ] Make a clearer Design guide.
+
+- [ ] Revamp project.
+ - [x] Better directory structure.
+ - [x] Clearer naming conventions.
+ - [ ] Make old Modules compatible.
+
## For Another Time:
- [x] Implement Auto-Update.
- [ ] Make use of log file in more functions (for more detailed logs).
- [ ] Check if core functions & dependency functions are loaded and set that script load flag true using a variable.
+- [ ] Config file support.
+ - [ ] toml as format?
+ - [ ] use of [yq][yq_cg]?
- [ ] Add `-q` or `--quiet` flag to all possible functions.
- [ ] Write documentation (help needed).
- [ ] Enable completions (still thinking if useful):
- Make script.
- Source the file.
- In install script: `printf "echo \"fpath+=(\"${kirei_dir}/completions\")\" >> \"${zsh_rc}\""`
+
+
+
+
+# Directory structure:
+
+```shell
+./
+ |- Assets/ - holds icon, default configs etc..
+ |- bin/kireisakura - enables command, help message, version message, init system, updater.
+ |- core/
+ | |- _loader - loads configs & modules.
+ | |- logging - enables logging.
+ | |- test - test script to verify the setup.
+ | |- ui - holds ui components.
+ | |- utils - holds core functions.
+ | └─ updater - as the name suggests :)
+ |
+ |- modules/ - holds modules
+ └- .version - vesion number
+
+```
+
+
+
+
+
+[yq_cg]: [yq](https://chatgpt.com/share/671ab466-aaf0-8001-ba21-ae748636e88b)
diff --git a/bin/kireisakura b/bin/kireisakura
index 3f59d2c..b973acc 100755
--- a/bin/kireisakura
+++ b/bin/kireisakura
@@ -7,13 +7,24 @@ YELLOW='\033[1;33m'
GREEN='\033[0;32m'
RESET='\033[0m'
+KIT_LOGO="$(
+ cat <<"EOF"
+ _ ___ _ ____ _ _ ___ _
+ | |/ (_)_ __ ___(_) ___| __ _| | ___ _ _ __ __ _ | |/ (_) |_
+ | ' /| | '__/ _ \ \___ \ / _` | |/ / | | | '__/ _` |_____| ' /| | __|
+ | . \| | | | __/ |___) | (_| | <| |_| | | | (_| |_____| . \| | |_
+ |_|\_\_|_| \___|_|____/ \__,_|_|\_\\__,_,|_| \__,_| |_|\_\_|\__|
+EOF
+)"
+
+
#_____________________________________FUNCTIONS_____________________________________________
# Log function
logf() {
local message="$1"
- local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
+ local timestamp="[$(date '+%Y.%m.%d %H:%M:%S')] "
# Replace '\n' with actual newlines
local formatted_message=$(echo -e "$message")
@@ -24,6 +35,22 @@ logf() {
}
+clearx() {
+ if [[ "$(uname)" == "Darwin" ]]; then
+ clear
+ else
+ clear -x
+ fi
+}
+
+
+print_header() {
+ clearx
+ printf "echo -e '$KIT_LOGO\n\n"
+ sleep 0.3
+}
+
+
# For no arguments
show_man() {
local opt=${1:-" "}
@@ -119,6 +146,7 @@ init() {
printf "\n\n" >>"$log_file"
logf "====================== NEW SESSION =======================\n"
+ logf "Started in: $(pwd)"
logf "Initialization started."
printf "echo -e '\\n${YELLOW}[ INIT ]-> Starting Initialization..${RESET}\\n\\n'\n"
@@ -180,26 +208,26 @@ init() {
logf "Loading core....."
printf "echo \"${YELLOW}[!]-> Loading core.${RESET}\" \n"
printf "source \"\$kirei_core\" \n"
- printf "log 'Loaded core.' success \n"
+ printf "log.success 'Loaded core.' \n"
logf "Loaded core."
# This was the issue part
printf "sleep 1\n"
- printf "log \"Checking cache directory.....\" inform \n"
- printf "check_dir \"\${kirei_cache_dir}\" -q \n"
- printf "log \"Cache directory exists.\" success \n"
+ printf "log.warn \"Checking cache directory.....\"\n"
+ printf "check-dir \"\${kirei_cache_dir}\" -q \n"
+ printf "log.success \"Cache directory exists.\"\n"
printf "echo "" \n"
printf "log \"KireiSakura-Kit v${kit_version}\" \n"
printf "sleep 1\n"
printf "echo \" \\n \" \n"
- printf "log \"Initialization complete.\" success INIT\n"
+ printf "log.success \"Initialization complete.\" INIT\n"
logf "Initialization complete."
}
run_tester() {
clear -x
- bash "$kirei_dir/core/_test.sh" || exit 1
+ bash "$kirei_dir/core/test.sh" || exit 1
}
@@ -212,7 +240,7 @@ kirei_core="$kirei_core_dir/_loader.sh"
kirei_module_dir="$kirei_dir/modules"
cache_dir="${CACHE_DIR:-$HOME/.cache/KireiSakura-Kit}"
-log_file="${LOG_FILE:-KireiSakura-Kit.log}"
+log_file="${cache_dir}/${LOG_FILE_NAME:-KireiSakura-Kit.log}"
init_flag=false
is_cstm_kit_dir=false
@@ -271,5 +299,6 @@ done
# Perform setup if --init flag is set
if [ "$init_flag" = true ]; then
- init "$kirei_dir"
+ mkdir -p "$cache_dir"
+ init "$kirei_dir"
fi
diff --git a/core/_loader.sh b/core/_loader.sh
index f480b62..9788eaf 100644
--- a/core/_loader.sh
+++ b/core/_loader.sh
@@ -1,5 +1,69 @@
-# LOAD CORE
-source "$(dirname "$0")/ui.sh"
-source "$(dirname "$0")/logging.sh"
-source "$(dirname "$0")/utils.sh"
\ No newline at end of file
+#____ shell-opts _____
+shopt -s expand_aliases
+
+
+#------------------------------------
+
+remove-command-conflict() {
+
+ if type loader &> /dev/null; then
+ unset -f loader
+
+ if type -t loader | grep -q alias; then
+ unalias loader
+ fi
+ fi
+}
+
+
+export kirei_loaded_core_modules=()
+export kirei_loaded_modules=()
+
+
+remove-command-conflict loader
+
+#loader() {
+# local module_type="$1"
+# local query="$2"
+# shift
+# local called_modules=("@")
+# local failed_imports=()
+# local module_path
+#
+# echo -e "Importing modules....\n"
+#
+# for module_name in "${called_modules[@]}"; do
+# module_path="$kirei_module_dir/$module_name.sh"
+#
+# if [ -f "$module_path" ]; then
+# if source "$module_path"; then
+# log "Imported: '$module_name'"
+# else
+# log "Failed to import: '$module_name'" inform
+# failed_imports+=("$module_name")
+# fi
+# else
+# log "Failed to import '$module_name': doesn't exist." inform
+# failed_imports+=("$module_name")
+# fi
+# sleep 0.3
+# done
+#
+#
+# fr
+#
+#}
+#
+#
+#alias loader.module.load="loader extrnl load"
+#alias loader.module-core.load="loader core load"
+#
+#alias loader.module.isloaded="loader extrnl isloaded"
+#alias loader.module-core.isloaded="loader extrnl isloaded"
+
+
+
+source "$kirei_core_dir/ui.sh"
+source "$kirei_core_dir/logging.sh"
+source "$kirei_core_dir/utils.sh"
diff --git a/core/_test.sh b/core/_test.sh
deleted file mode 100755
index 6e0899e..0000000
--- a/core/_test.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-export LOG_FILE="test_script.log"
-export CACHE_DIR="$HOME/.cache/test_setup_dir"
-
-echo -e "\n Kirei Sakura Test Script"
-eval "$(kireisakura -i)"
-
-
-#//////////////// SCRIPT START \\\\\\\\\\\\\\\\
-
-echo -e "\n\n"
-log "Here are dirs:------" inform
-echo -e ""
-echo -e " Log file name: $kirei_log_file"
-echo -e " Cache dir: $kirei_cache_dir"
-echo -e " Installation dir: $kirei_dir"
-echo -e " Core dir: $kirei_core_dir"
-echo -e " Core file: $kirei_core"
-echo -e " Modules dir: $kirei_module_dir"
-
-echo -e "\n"
-
-
-kimport restore-dotfiles install-fonts install-pkgs kde-plasma-utils
-
-rm -rf $kirei_cache_dir
diff --git a/core/logging.sh b/core/logging.sh
index d9521df..e7ef85b 100644
--- a/core/logging.sh
+++ b/core/logging.sh
@@ -1,59 +1,60 @@
-log() {
- local log_message=$1
- local log_level=${2:-" - "}
- local extra_info=$3
+logger() {
+ local log_level=$1
+ local log_message=$2
+ local extra_info=$3
- # Determine color based on log level
case "$log_level" in
"error")
color="${RED}"
- ;;
- "inform")
+ ;;
+ "warn")
color="${YELLOW}"
- ;;
+ ;;
"success")
color="${GREEN}"
- ;;
+ ;;
+ "info")
+ color="${BLUE}"
+ ;;
*)
color="${BLUE}"
- ;;
+ ;;
esac
-
- if starts_with "\n" "$log_message"; then
- log_message=$(trim_char "\n" "$log_message" )
- echo ""
- echo -e "$(date +"%Y-%m-%d %H:%M:%S") " >> "$kirei_log_file"
+ if starts-with "\n" "$log_message"; then
+ log_message=$(trim-char "\n" "$log_message")
+ echo ""
+ echo -e "[$(date '+%Y.%m.%d %H:%M:%S')] " >> "$kirei_log_file"
fi
- # Format the log message
if [ -n "$extra_info" ]; then
- # Extra info case
formatted_message="${color}[ ${extra_info} ]-> ${log_message}${NC}"
else
- # No extra info case
case "$log_level" in
"error")
prefix="[X]->"
- ;;
- "inform")
+ ;;
+ "warn")
prefix="[!]->"
- ;;
+ ;;
"success")
prefix="[✔]->"
- ;;
- *)
+ ;;
+ "info" | *)
prefix="[-]->"
- ;;
+ ;;
esac
formatted_message="${color}${prefix} ${log_message}${NC}"
fi
- # Print to console
echo -e "$formatted_message"
- # Log to file
- echo -e "$(date +"%Y-%m-%d %H:%M:%S") [$log_level] $log_message" >> "$kirei_log_file"
+ echo -e "[$(date +"%Y.%m.%d %H:%M:%S")] [$log_level] $log_message" >> "$kirei_log_file"
}
+alias log='logger info'
+alias log.info='logger info'
+alias log.error='logger error'
+alias log.warn='logger warn'
+alias log.success='logger success'
diff --git a/core/test.sh b/core/test.sh
new file mode 100755
index 0000000..74f9733
--- /dev/null
+++ b/core/test.sh
@@ -0,0 +1,42 @@
+echo -e "\n\n"
+clear -x
+echo -e "\n--------------------- KireiSakura Kit Test Utility ----------------------\n\n"
+
+
+export LOG_FILE="test_script.log"
+export CACHE_DIR="$HOME/.cache/test_setup_dir"
+
+
+eval "$(kireisakura -i)"; echo -e "\n"
+
+
+
+log.warn "Set variables:------\n"
+echo -e " ${GREEN}Log file name${NC} (kirei_log_file): $kirei_log_file"
+echo -e " ${GREEN}Cache dir${NC} (kirei_cache_dir): $kirei_cache_dir"
+echo -e " ${GREEN}Installation dir${NC} (kirei_dir): $kirei_dir"
+echo -e " ${GREEN}Core dir${NC} (kirei_core_dir): $kirei_core_dir"
+echo -e " ${GREEN}Core file${NC} (kirei_core): $kirei_core"
+echo -e " ${GREEN}Module dir${NC} (kirei_module_dir): $kirei_module_dir"
+echo -e "\n\n"
+
+
+log.warn "Logs:------\n"
+
+log.success "Log level: success"
+log.error "Log level: error"
+log.warn "Log level: inform"
+echo -e "\n\n"
+
+
+log.warn "Importing modules:------\n"
+
+kimport restore-dotfiles install-fonts kde-plasma-utils disk-utils
+echo -e "\n\n"
+
+
+rm -rf $kirei_cache_dir
+rm $kirei_log_file
+
+
+echo -e "\n\n------------------------- END ----------------------------\n"
diff --git a/core/ui.sh b/core/ui.sh
index 6e451ef..2295f87 100644
--- a/core/ui.sh
+++ b/core/ui.sh
@@ -38,7 +38,7 @@ prompt() {
# footer after each module completes
-print_footer() {
+footer() {
if [ -n "$1" ]; then
if [ "$2" == "skipped" ]; then
echo -e "${RED}[x]-> $1${NC}"
@@ -49,6 +49,3 @@ print_footer() {
echo -e "${AQUA}---------------------------------------------------------------${NC}"
sleep 1
}
-
-
-
diff --git a/core/updater.sh b/core/updater.sh
new file mode 100644
index 0000000..1974224
--- /dev/null
+++ b/core/updater.sh
@@ -0,0 +1,3 @@
+
+
+# will shift here from ../bin/kireisakura
diff --git a/core/utils.sh b/core/utils.sh
old mode 100755
new mode 100644
index 1f6c06c..a103b44
--- a/core/utils.sh
+++ b/core/utils.sh
@@ -1,7 +1,5 @@
# CORE FUNCTIONS
-
-
# Import modules
# kimport
kimport() {
@@ -10,35 +8,35 @@ kimport() {
local failed_imports=()
# local is_quiet=0
- log "Importing modules....\n" inform kimport
+ log.warn "Importing modules....\n" kimport
for module_name in "${called_modules[@]}"; do
module_path="$kirei_module_dir/$module_name.sh"
if [ -f "$module_path" ]; then
if source "$module_path"; then
- log "Imported: '$module_name'"
+ log "Imported: '$module_name'"
else
- log "Failed to import: '$module_name'" inform
- failed_imports+=("$module_name")
+ log.warn "Failed to import: '$module_name'"
+ failed_imports+=("$module_name")
fi
else
- log "Failed to import '$module_name': doesn't exist." inform
- failed_imports+=("$module_name")
+ log.warn "Failed to import '$module_name': doesn't exist."
+ failed_imports+=("$module_name")
fi
sleep 0.3
done
if [ "${#failed_imports[@]}" -gt 0 ]; then
- echo ""
- log " Failed to import modules:" error kimport
+ echo ""
+ log.error " Failed to import modules:" kimport
for failed_import in "${failed_imports[@]}"; do
echo -e "\t\t${LAVENDER}$failed_import ${NC}"
done
- log "Please check your imports." inform kimport
+ log.warn "Please check your imports." kimport
exit 1
- else
- log "\nImported all modules successfully." success kimport
+ else
+ log.success "\nImported all modules successfully." kimport
fi
}
@@ -53,7 +51,7 @@ load_all_from() {
for script in "${directory}"/*.${file_ext}; do
if [ -e "$script" ]; then
if ! source "$script"; then
- log "Failed to load $script" error
+ log.error "Failed to load $script"
exit 1
fi
fi
@@ -62,49 +60,90 @@ load_all_from() {
-# Install a package using pacman or paru
-install_package() {
- local package=$1
- local failed=0
+get-package-manager() {
- if sudo pacman -S --noconfirm --needed "$package"; then
- log "$package installed successfully." success "INSTALLER"
+ if [[ "$(uname)" == "Linux" ]]; then
+ if has pacman; then
+ echo "pacman"
+ elif has apt; then
+ echo "apt"
+ elif has dnf; then
+ echo "dnf"
+ elif has zypper; then
+ echo "zypper"
else
- log "$package not found in repos. Attempting AUR..." inform
-
- if paru --needed -S "$package"; then
- log "$package installed successfully from AUR." success "INSTALLER"
- else
- log "$package not found in repos or AUR. Please install it manually." error "INSTALLER"
- failed=1
- fi
+ error "Unsupported Linux distribution."
+ error "Use one (or derivatives) of below distros: "
+ error "Debian, Ubuntu, Fedora, Arch, SUSE"
+ exit 1
fi
+ return 0
+ elif [[ "$(uname)" == "Darwin" ]]; then
+ echo "brew"
+ return 0
+ else
+ error "Unsupported OS."
+ error "Only Linux and macOS are supported."
+ exit 1
+ fi
+}
- return $failed
+
+
+install-package() {
+ local package="$1"
+ local pkg_manager="$(get_package_manager)"
+
+ case $pkg_manager in
+ pacman)
+ sudo pacman -S --noconfirm --needed "$package" > /dev/null || return 1
+ ;;
+ apt)
+ sudo apt update > /dev/null || return 1
+ sudo apt install -y "$package" > /dev/null || return 1
+ ;;
+ dnf)
+ sudo dnf install -y "$package" > /dev/null || return 1
+ ;;
+ zypper)
+ sudo zypper install -y "$package" > /dev/null || return 1
+ ;;
+ brew)
+ brew install "$package" > /dev/null || return 1
+ ;;
+ *)
+ log.error "Unknown package manager."
+ log.error "Unsupported Linux distribution."
+ log.warn "Use one (or derivatives) of below distros: "
+ log.warn "Debian, Ubuntu, Fedora, Arch, SUSE"
+ return 1
+ ;;
+ esac
+ return 0
}
# Check if a dependency is installed
-check_dependency() {
+check-deps() {
local dependency=$1
local required=$2
if pacman -Q "$dependency" &> /dev/null; then
- log "$dependency is installed." success
+ log.success "$dependency is installed."
else
- log "$dependency is not installed." inform
+ log.warn "$dependency is not installed." inform
if [ -n "$required" ] && [ "$required" == "--needed" ]; then
- log "installing $dependency...." inform
+ log.warn "installing $dependency...."
install_package "$dependency"
- log "$dependency installed." success
+ log.success "$dependency installed."
else
prompt "Do you want to install $dependency?" confirm_install --no-separator
if [ "$confirm_install" == "y" ] || [ "$confirm_install" == "Y" ] || [ -z "$confirm_install" ]; then
install_package "$dependency"
- log "$dependency installed." success
+ log.success "$dependency installed."
else
- log "$dependency installation was declined by the user." inform
+ log.warn "$dependency installation was declined by the user."
fi
fi
fi
@@ -114,7 +153,7 @@ check_dependency() {
# check if a directory exists (make it if it doesn't):
## check_dir [--needed || --el_exit] [--quiet]
-check_dir() {
+check-dir() {
local dir=$1
local is_needed=0
local el_exit=0
@@ -140,27 +179,27 @@ check_dir() {
done
if [[ "$is_needed" -eq 1 && "$el_exit" -eq 1 ]]; then
- log "Invalid flags given." error
- log "How come you gave -n & -e flags both?" inform
+ log.error "Invalid flags given."
+ log.warn "How come you gave -n & -e flags both?"
return 1
fi
if [[ -d "$dir" ]]; then
- [[ "$is_quiet" -ne 1 ]] && log "Directory '$dir' exists." inform
+ [[ "$is_quiet" -ne 1 ]] && log.warn "Directory '$dir' exists."
else
- [[ "$is_quiet" -ne 1 ]] && log "Directory '$dir' does not exist." inform
+ [[ "$is_quiet" -ne 1 ]] && log.warn "Directory '$dir' does not exist."
if [[ "$is_needed" -eq 1 ]]; then
- [[ "$is_quiet" -ne 1 ]] && log "Creating directory '$dir'..." inform
+ [[ "$is_quiet" -ne 1 ]] && log.warn "Creating directory '$dir'..."
if mkdir -p "$dir" 2>/dev/null; then
- [[ "$is_quiet" -ne 1 ]] && log "Directory '$dir' created successfully." success
+ [[ "$is_quiet" -ne 1 ]] && log.success "Directory '$dir' created successfully."
else
- log "Failed to create directory '$dir'. Attempting with sudo..." inform
+ log.warn "Failed to create directory '$dir'. Attempting with sudo..."
if sudo mkdir -p "$dir"; then
- [[ "$is_quiet" -ne 1 ]] && log "Directory '$dir' created successfully with sudo." success
+ [[ "$is_quiet" -ne 1 ]] && log.success "Directory '$dir' created successfully with sudo."
else
- log "Failed to create directory '$dir' with sudo." error
+ log.error "Failed to create directory '$dir' with sudo."
return 1
fi
fi
@@ -174,8 +213,8 @@ check_dir() {
# Check if a message strats with given char. if yes, srccessfull..
-# strats_with
-starts_with() {
+# strats_with
+starts-with() {
local character=$1
local string=$2
@@ -188,15 +227,30 @@ starts_with() {
-trim_char() {
+trim-char() {
local character=$1
local string=$2
local trimmed_message
- if starts_with "$character" "$string"; then
+ if starts-with "$character" "$string"; then
trimmed_message="${string#"$character"}"
echo "$trimmed_message"
- else
+ else
echo "$string"
fi
-}
\ No newline at end of file
+}
+
+
+cfrm-reboot() {
+ log.warn "!"
+ prompt "Reboot is recommended, Do you wanna Reboot?" cfrm_reboot
+ if [ "$cfrm_reboot" == "y" ] || [ "$cfrm_reboot" == "Y" ] || [ -z "$cfrm_reboot" ]; then
+ log.warn "rebooting..."
+ sleep 2
+ sudo reboot
+ else
+ log.success "Ok, Enjoy your system! and don't forget to reboot later.."
+ sleep 2
+ clear
+ fi
+}
diff --git a/modules/_EXAMPLE.sh b/modules/_EXAMPLE.sh
index 2b51567..036dc6c 100644
--- a/modules/_EXAMPLE.sh
+++ b/modules/_EXAMPLE.sh
@@ -8,40 +8,33 @@ example_function() {
log "Executing step 1" # log your message/instruction...
date # commands
time # another command
- log "Executing step 2" # log, pattern: log "your message for logs" < log mode (normal or null/error/inform) >
+ log "Executing step 2" # log, pattern: log "your message for logs" < log mode (normal or null/error/inform) >
ls -a # another command
swapon --show # another command
inform "inforning" # Print test in Bold yellow
print_footer "Completed executing example function" # pattern: print_footer "Your success message"
else
- log "Skipped executing eample function" inform # log error
- print_footer # To print the footer only, without message.
+ log.warn "Skipped executing eample function" # log error
+ print_footer # To print the footer only, without message.
fi
}
-
-
test() {
prompt "User Prompt with question" confirm_exfunc # pattern: prompt "your question to ask" < return variable of respond, starting with confirm_ >
if [ "$confirm_exfunc" == "y" ] || [ "$confirm_exfunc" == "Y" ] || [ -z "$confirm_exfunc" ]; then
- log "simple log"
- log "inform log " inform
- log "need attention/important" imp
- log "error log " error "TESTER"
+ log "simple log"
+ log.warn "inform log "
+ log.imp "need attention/important"
+ log.error "error log " "TESTER"
check_dependency keepassxc
change_shell
install_chaotic_aur
prompt "User Prompt with next question" test_sx
if [ "$test_sx" == "y" ] || [ -z "$test_sx" ]; then
- check_dependency keepassxc
+ check_dependency keepassxc
print_footer "Function complete"
else
print_footer "Process skipped" "skiped"
fi
- print_footer "Complete function footer & then footer"
- cfrm_reboot
- else
- print_footer "Process skipped" skipped
- exit
fi
}
diff --git a/modules/change-papirus-folder-color.sh b/modules/change-papirus-folder-color.sh
index 0cf4023..ebc520b 100644
--- a/modules/change-papirus-folder-color.sh
+++ b/modules/change-papirus-folder-color.sh
@@ -4,14 +4,15 @@ change_papirus_folder_color() {
local color_name=$1
local theme_name=${2:-Papirus-Dark}
+ #header
if ! command -v papirus-folders >/dev/null 2>&1; then
- log "Papirus-folders is not installed, installing..." inform
- install_package papirus-folders-catppuccin-git
+ log.warn "Papirus-folders is not installed, installing..."
+ install_package papirus-folders-catppuccin-git
fi
- log "Changing Papirus folder color to $color_name with theme $theme_name." inform
+ log.warn "Changing Papirus folder color to $color_name with theme $theme_name."
command papirus-folders -v -C $color_name --theme $theme_name
- log "Papirus folder color changed to $color_name." success
- print_footer
-}
\ No newline at end of file
+ log.success "Papirus folder color changed to $color_name."
+ footer
+}
diff --git a/modules/change-shell.sh b/modules/change-shell.sh
index 12c6e53..812c63b 100644
--- a/modules/change-shell.sh
+++ b/modules/change-shell.sh
@@ -1,22 +1,24 @@
# Switching to ZSH Shell:
change_shell() {
- prompt "Do you want to switch to Zsh shell?" confirm_shell
+ local shell_name="$1"
+
+ prompt "Do you want to switch to ${shell_name} shell?" confirm_shell
if [ "$confirm_shell" == "y" ] || [ "$confirm_shell" == "Y" ] || [ -z "$confirm_shell" ]; then
- if [ "$(basename "$SHELL")" == "zsh" ]; then
- log "ZSH is already Currnet shell."
+ if [ "$(basename "$SHELL")" == "${shell_name}" ]; then
+ log "${shell_name} is already Currnet shell."
else
log "Changing shell"
- log "Checking if ZSH is installed."
- check_dependency zsh needed
- log "zsh is installed."
- log "Changing SHELL to ZSH.."
- chsh -s $(which zsh)
- log "Shell changed for current user." success
- log "Log out and log back again for changes to take effect." inform
+ log "Checking if ${shell_name} is installed."
+ check-deps "${shell_name}" needed
+ log "${shell_name} is installed."
+ log "Changing SHELL to ${shell_name}.."
+ chsh -s $(which "${shell_name}")
+ log.success "Shell changed for current user."
+ log.warn "Log out and log back again for changes to take effect."
fi
- print_footer
+ footer
else
- print_footer "Shell change skipped." skipped
+ footer "Shell change skipped." skipped
fi
-}
\ No newline at end of file
+}
diff --git a/modules/confirm-reboot.sh b/modules/confirm-reboot.sh
deleted file mode 100644
index 49ee667..0000000
--- a/modules/confirm-reboot.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-# Goodbye message:
-
-
-cfrm_reboot() {
- log "!" inform
- log "Script completed." success
- prompt "Reboot is recommended, Do you wanna Reboot?" cfrm_reboot
- if [ "$cfrm_reboot" == "y" ] || [ "$cfrm_reboot" == "Y" ] || [ -z "$cfrm_reboot" ]; then
- log "rebooting..." inform
- sleep 2
- sudo reboot
- else
- log "Ok, Enjoy your system! and don't forget to reboot later.." success
- sleep 2
- clear
- fi
-}
\ No newline at end of file
diff --git a/modules/disk-utils.sh b/modules/disk-utils.sh
index 2bac884..05fab71 100644
--- a/modules/disk-utils.sh
+++ b/modules/disk-utils.sh
@@ -1,19 +1,19 @@
check_entry() {
- local disk_id="$1"
+ local disk_id="$1"
local mount_dir="$2"
local fstab_file="/etc/fstab"
# Check if the disk_id or mount_dir is already in fstab
if grep -q "$disk_id" "$fstab_file"; then
mount_point="$(grep $disk_id $fstab_file | sed -E 's/^[^ ]+ +([^ ]+).*/\1/')"
- log "The Drive has entry to already Mount in : $mount_point" inform
+ log.warn "The Drive has entry to already Mount in : $mount_point"
return 1
elif grep -q "$mount_dir" $fstab_file; then
local disk_to_mount="$(grep $mount_dir $fstab_file | sed -E 's/^([^ ]+).*/\1/')"
- log "Dir is in entry to be used for Mounting: $disk_to_mount" inform
+ log.warn "Dir is in entry to be used for Mounting: $disk_to_mount"
return 1
- else
+ else
return 0
fi
@@ -26,7 +26,6 @@ mount_external_drive() {
local disk_id
local mount_config
- # Parse options
while [[ "$#" -gt 1 ]]; do
case "$1" in
-md|--mount-dir)
@@ -46,7 +45,7 @@ mount_external_drive() {
shift 2
;;
*)
- log "Invalid flag." error
+ log.error "Invalid flag."
exit 1
;;
esac
@@ -54,36 +53,36 @@ mount_external_drive() {
# Make mount folder
- log "Checking given Mount directory." inform
- check_dir "$mount_dir" --needed || { log "Error creating dir." error; exit 1 }
+ log.warn "Checking given Mount directory."
+ check_dir "$mount_dir" --needed || { log.error "Error creating dir."; exit 1 }
# Get ownership of the dir & drive
- log "Getting ownership of the Mount directory." inform
- sudo chown -R $username:$user_group $mount_dir || { log "Error ownership." error; exit 1 }
- sudo chmod -R 744 $mount_dir || { log "Error Getting writing permission." error; exit 1 }
+ log.warn "Getting ownership of the Mount directory."
+ sudo chown -R $username:$user_group $mount_dir || { log.error "Error ownership."; exit 1 }
+ sudo chmod -R 744 $mount_dir || { log.error "Error Getting writing permission."; exit 1 }
- log "Getting ownership of the External Drive." inform
- sudo chown -R $username:$user_group $disk_id || { log "Error owning External Drive." error; exit 1 }
+ log.warn "Getting ownership of the External Drive."
+ sudo chown -R $username:$user_group $disk_id || { log.error "Error owning External Drive."; exit 1 }
# Backup fstab file
- log "Backing up current fstab file." inform
- sudo cp /etc/fstab /etc/fstab.bak || { log "Failed to back up current fstab file." error; exit 1 }
+ log.warn "Backing up current fstab file."
+ sudo cp /etc/fstab /etc/fstab.bak || { log.error "Failed to back up current fstab file."; exit 1 }
# Mounting device
mount_config="$disk_id $mount_dir auto noatime,x-systemd.automount,x-systemd.device-timeout=10,x-systemd.idle-timeout=1min 0 2"
- log "Adding Drive entry in fstab file." inform
+ log.warn "Adding Drive entry in fstab file."
echo "$mount_config" | sudo tee -a /etc/fstab
- log "Reloading systemd configuration." inform
+ log.warn "Reloading systemd configuration."
sudo systemctl daemon-reload
- log "Mounting Drive." inform
- sudo mount -a || { log "Failed to mount device." error; exit 1 }
+ log.warn "Mounting Drive."
+ sudo mount -a || { log.error "Failed to mount device."; exit 1; }
- log "External Drive '$disk_id' mounted at '$mount_dir'" success
+ log.success "External Drive '$disk_id' mounted at '$mount_dir'"
}
diff --git a/modules/enable-os-prober.sh b/modules/enable-os-prober.sh
index 955782e..7a0c8f2 100644
--- a/modules/enable-os-prober.sh
+++ b/modules/enable-os-prober.sh
@@ -6,18 +6,18 @@
enable_os_prober() {
prompt "Do you want enable os prober?" confirm_prober
if [ "$confirm_prober" == "y" ] || [ "$confirm_prober" == "Y" ] || [ -z "$confirm_prober" ]; then
- log "Editing /etc/default/grub file"
+ log.warn "Editing /etc/default/grub file"
sleep 2
- log "Enabling os-prober"
+ log.warn "Enabling os-prober"
sed -i '/^#GRUB_DISABLE_OS_PROBER=/s/^#//' "$GRUB_FILE"
- log "updating GRUB config"
+ log.warn "updating GRUB config"
sudo grub-mkconfig -o /boot/grub/grub.cfg
- log "done" success
- print_footer
+ log.success "done"
+ footer
else
- log "skipped enablig os-prober." imp "OS-Prober"
- log "GRUB will not detect OS in other partitions" imp "OS-Prober"
- print_footer
+ log.imp "skipped enablig os-prober." "OS-Prober"
+ log.imp "GRUB will not detect OS in other partitions" "OS-Prober"
+ footer
fi
}
diff --git a/modules/enable-sudo-feedback.sh b/modules/enable-sudo-feedback.sh
index b4865e1..282dba8 100644
--- a/modules/enable-sudo-feedback.sh
+++ b/modules/enable-sudo-feedback.sh
@@ -3,19 +3,19 @@
enable_sudo_feedback() {
if sudo grep -q "Defaults.*pwfeedback" /etc/sudoers; then
- log "Sudo feedback is already enabled." success
+ log.success "Sudo feedback is already enabled."
else
- log "Sudo feedback is not enabled." inform
- log "Enabling pwfeedback..."
+ log.warn "Sudo feedback is not enabled."
+ log.warn "Enabling pwfeedback..."
sleep 1
sudo cp /etc/sudoers /etc/sudoers.bak
sudo bash -c 'echo "Defaults pwfeedback" >> /etc/sudoers'
if [ $? -eq 0 ]; then
- log "Sudo feedback has been enabled." success
+ log.success "Sudo feedback has been enabled."
else
- echo "Failed to enable pwfeedback. Restoring backup..." error
+ log.error "Failed to enable pwfeedback. Restoring backup..."
sudo mv /etc/sudoers.bak /etc/sudoers
fi
fi
diff --git a/modules/fix-librewolf-ntm.sh b/modules/fix-librewolf-ntm.sh
index 8d9b480..2626516 100644
--- a/modules/fix-librewolf-ntm.sh
+++ b/modules/fix-librewolf-ntm.sh
@@ -8,14 +8,14 @@ function enable_librewolf_ntv_msging {
local firefox_dir2='/usr/lib/mozilla/native-messaging-hosts'
if [ -e "$librewolf_dir1" ]; then
- log "The destination directory '$librewolf_dir1' already exists."
+ log.warn "The destination directory '$librewolf_dir1' already exists."
read -p "Do you want to overwrite it? (y/n): " overwrite
if [ "$overwrite" = "y" ]; then
- rm -i "$librewolf_dir1"
- ln -s -r -i "$firefox_dir1" "$librewolf_dir1"
+ rm -i "$librewolf_dir1"
+ ln -s -r -i "$firefox_dir1" "$librewolf_dir1"
else
echo "Aborting..."
- return 0
+ return 0
fi
fi
@@ -23,8 +23,8 @@ function enable_librewolf_ntv_msging {
echo "The destination directory '$librewolf_dir2' already exists."
read -p "Do you want to overwrite it? (y/n): " overwrite2
if [ "$overwrite2" = "y" ]; then
- sudo rm -i "$librewolf_dir2"
- sudo ln -s "$firefox_dir2" "$librewolf_dir2"
+ sudo rm -i "$librewolf_dir2"
+ sudo ln -s "$firefox_dir2" "$librewolf_dir2"
else
echo "Aborting..."
return 0
diff --git a/modules/install-additional-repo.sh b/modules/install-additional-repo.sh
index a954215..0397926 100644
--- a/modules/install-additional-repo.sh
+++ b/modules/install-additional-repo.sh
@@ -3,78 +3,78 @@
install_adtionl_repos() {
prompt "Do you want to install 3rd party repos?" confirm_aur
if [ "$confirm_aur" == "y" ] || [ "$confirm_aur" == "Y" ] || [ -z "$confirm_aur" ]; then
-
+
# Chaotic AUR
chaotic_aur_key="3056513887B78AEB"
chaotic_aur_keyserver="keyserver.ubuntu.com"
chaotic_aur_keyring_url="https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst"
chaotic_aur_mirrorlist_url="https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst"
-
- log "Installing Chaotic AUR..." inform
- log "Appending keys..." inform
+
+ log.warn "Installing Chaotic AUR..."
+ log.warn "Appending keys..."
sudo pacman-key --recv-key $chaotic_aur_key --keyserver $chaotic_aur_keyserver || {
- log "Failed to receive Chaotic AUR key" error
+ log.error "Failed to receive Chaotic AUR key"
return 1
}
sudo pacman-key --lsign-key $chaotic_aur_key || {
- log "Failed to locally sign Chaotic AUR key" error
+ log.error "Failed to locally sign Chaotic AUR key"
return 1
}
sudo pacman -U --noconfirm $chaotic_aur_keyring_url || {
- log "Failed to install Chaotic AUR keyring" error
+ log.error "Failed to install Chaotic AUR keyring"
return 1
}
sudo pacman -U --noconfirm $chaotic_aur_mirrorlist_url || {
- log "Failed to install Chaotic AUR mirrorlist" error
+ log.error "Failed to install Chaotic AUR mirrorlist"
return 1
}
- log "Adding Chaotic AUR to /etc/pacman.conf..." inform
+ log.warn "Adding Chaotic AUR to /etc/pacman.conf..."
echo -e "\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist" | sudo tee -a /etc/pacman.conf
- log "Chaotic AUR is installed." success
+ log.success "Chaotic AUR is installed."
# ArcoLinux
arcolinux_repo_url="https://github.com/arcolinux/archlinux-tweak-tool"
arcolinux_cache_dir="~/.cache/setup/arcolinux-app"
-
- log "Installing ArcoLinux repos..." inform
- log "Cloning ArcoLinux tweak tool..." inform
+
+ log.warn "Installing ArcoLinux repos..."
+ log.warn "Cloning ArcoLinux tweak tool..."
git clone $arcolinux_repo_url $arcolinux_cache_dir || {
- log "Failed to clone ArcoLinux Tweak Tool" error
+ log.error "Failed to clone ArcoLinux Tweak Tool"
return 1
}
- log "Installing ArcoLinux keyring and mirrorlist..." inform
+ log.warn "Installing ArcoLinux keyring and mirrorlist..."
sudo pacman -U $arcolinux_cache_dir/usr/share/archlinux-tweak-tool/data/arco/packages/keyring/arcolinux-keyring-*-any.pkg.tar.zst || {
- log "Failed to install ArcoLinux keyring" error
+ log.error "Failed to install ArcoLinux keyring"
return 1
}
sudo pacman -U $arcolinux_cache_dir/usr/share/archlinux-tweak-tool/data/arco/packages/mirrorlist/arcolinux-mirrorlist-*-any.pkg.tar.zst || {
- log "Failed to install ArcoLinux mirrorlist" error
+ log.error "Failed to install ArcoLinux mirrorlist"
return 1
}
- log "Adding ArcoLinux repositories to /etc/pacman.conf..." inform
+ log.warn "Adding ArcoLinux repositories to /etc/pacman.conf..."
echo -e "\n[arcolinux_repo]\nSigLevel = PackageRequired DatabaseNever\nInclude = /etc/pacman.d/arcolinux-mirrorlist" | sudo tee -a /etc/pacman.conf
echo -e "\n[arcolinux_repo_3party]\nSigLevel = PackageRequired DatabaseNever\nInclude = /etc/pacman.d/arcolinux-mirrorlist" | sudo tee -a /etc/pacman.conf
echo -e "\n[arcolinux_repo_xlarge]\nSigLevel = PackageRequired DatabaseNever\nInclude = /etc/pacman.d/arcolinux-mirrorlist" | sudo tee -a /etc/pacman.conf
rm -rf $arcolinux_cache_dir
- log "ArcoLinux repos are successfully installed." success
+ log.success "ArcoLinux repos are successfully installed."
# Garuda
garuda_repo="[garuda]\nSigLevel = Required DatabaseOptional\nInclude = /etc/pacman.d/chaotic-mirrorlist"
-
- log "Installing Garuda repos..." inform
+
+ log.warn "Installing Garuda repos..."
echo -e "\n$garuda_repo" | sudo tee -a /etc/pacman.conf
- log "Garuda repos are successfully installed." success
+ log.success "Garuda repos are successfully installed."
# Update Repositories
- log "Updating repositories..." inform
+ log.warn "Updating repositories..."
sudo pacman -Syu || {
- log "Failed to update repositories" error
+ log.error "Failed to update repositories"
return 1
}
- log "Update complete." success
+ log.success "Update complete."
print_footer "Chaotic AUR, ArcoLinux, and Garuda repos are successfully installed."
else
- log "3rd party repo installation skipped." error
- print_footer
+ log.error "3rd party repo installation skipped."
+ print_footer
fi
}
diff --git a/modules/install-all-packages.sh b/modules/install-all-packages.sh
index 031af74..d68154d 100644
--- a/modules/install-all-packages.sh
+++ b/modules/install-all-packages.sh
@@ -9,37 +9,37 @@ function install_all_packages {
local -n group="$group_name"
local failed_pckgs=()
- log "Starting installation of packages from group: $group_name" inform
+ log.warn "Starting installation of packages from group: $group_name"
prompt "Install packages from from the group: $group_name?" confirm_instpkgs
if [[ "$confirm_instpkgs" == "y" || "$confirm_instpkgs" == "Y" || -z "$confirm_instpkgs" ]]; then
- log "Installing packages from $group_name..." inform
+ log.warn "Installing packages from $group_name..."
for pkg in "${group[@]}"; do
echo -e "\n"
- log "Installing $pkg" inform
- install_package "$pkg" || failed_pckgs+=("$pkg")
+ log.warn "Installing $pkg"
+ install-package "$pkg" || failed_pckgs+=("$pkg")
sleep 1
done
echo -e "\n"
- log "Packages from $group_name are installed" success
+ log.success "Packages from $group_name are installed"
else
echo -e "\n"
- log "User denied installation of packages from $group_name" error
+ log.error "User denied installation of packages from $group_name"
fi
# Log the completion of the group installation and print footer
- log "Finished processing group: $group_name \n" success
+ log.success "Finished processing group: $group_name \n"
done
if [[ ${#failed_pckgs[@]} -gt 0 ]]; then
- log "Failed to install the following packages: ${failed_pckgs[*]}" error
- log "Please check if they are available or if there was an error during installation." error
- else
- log "All packages are installed successfully" success
+ log.error "Failed to install the following packages: ${failed_pckgs[*]}"
+ log.error "Please check if they are available or if there was an error during installation."
+ else
+ log.success "All packages are installed successfully"
fi
print_footer
-}
\ No newline at end of file
+}
diff --git a/modules/install-fonts.sh b/modules/install-fonts.sh
index c55924b..b7d98d4 100644
--- a/modules/install-fonts.sh
+++ b/modules/install-fonts.sh
@@ -1,19 +1,19 @@
-# Install fonts to current user
+# Install fonts to current user
install_fonts() {
prompt "Do you want to install fonts in /fonts folder" confirm_fontinstal
if [ "$confirm_fontinstal" == "y" ] || [ "$confirm_fontinstal" == "Y" ] || [ -z "$confirm_fontinstal" ]; then
- log "Installing custom Fonts......"
+ log.warn "Installing custom Fonts......"
CURRENT_DIRECTORY=$(pwd)
pushd ~
- log "copying fonts to ~/$SYSTEM_FONTS_DIRECTORY."
+ log.warn "copying fonts to ~/$SYSTEM_FONTS_DIRECTORY."
cp -r "$CURRENT_DIRECTORY/$FONTS_DIRECTORY"/* "$SYSTEM_FONTS_DIRECTORY"/
popd
- log "Rebuilding font cache."
+ log.warn "Rebuilding font cache."
sudo fc-cache -f -v
- print_footer "Fonts are installed."
+ footer "Fonts are installed."
else
- print_footer "skipped Installing fonts" skipped
+ footer "skipped Installing fonts" skipped
fi
}
diff --git a/modules/install-pkgs.sh b/modules/install-pkgs.sh
deleted file mode 100644
index 44b952c..0000000
--- a/modules/install-pkgs.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-# Installing Apps:
-
-
-
-
-install_pkgs() {
- pormpt "Do you want to install apps?" confirm_pkgs
- if [ "$confirm_pkgs" == "y" ] || [ "$confirm_pkgs" == "Y" ] || [ -z "$confirm_pkgs" ]; then
- # Repo:
- log "Installing Repo packages"
- sudo pacman -S --noconfirm "${pacman_packages[@]}"
- log "Repo packages installed." success
- # AURs:
- log "Installing AUR packages," inform
- log "Please carefully select options when asked:"
- yay -S "${aur_packages[@]}"
- print_footer "AUR packages installed."
- else
- echo -e "${RED}Packages' Installation skipped.${NC}"
- fi
-}
diff --git a/modules/kde-plasma-utils.sh b/modules/kde-plasma-utils.sh
index 2da2ea8..3be94e0 100644
--- a/modules/kde-plasma-utils.sh
+++ b/modules/kde-plasma-utils.sh
@@ -6,18 +6,18 @@
change_meta_to_krunner() {
prompt "Do you want to change meta key to open krunner?" confirm_meta
if [ "$confirm_meta" == "y" ] || [ "$confirm_meta" == "Y" ] || [ -z "$confirm_meta" ]; then
- log "Changing meta key to open krunner."
+ log.warn "Changing meta key to open krunner."
kwriteconfig6 --file kwinrc --group ModifierOnlyShortcuts --key Meta "org.kde.krunner,/App,,toggleDisplay"
sleep 3
- log "Applying changes."
- log "Done"
+ log.warn "Applying changes."
+ log.success "Done"
qdbus org.kde.KWin /KWin reconfigure
- log "To get all possible commands using kwriteconfig5" inform "TIP"
- log "run 'qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.shortcutNames'." inform
+ log.warn "To get all possible commands using kwriteconfig5" "TIP"
+ log.warn "run 'qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.shortcutNames'."
# kwriteconfig5 --file ~/.config/kwinrc --group ModifierOnlyShortcuts --key Meta "org.kde.kglobalaccel,/component/kwin,org.kde.kglobalaccel.Component,invokeShortcut,NAME_OF_THE_THING_YOU_WANT_TO_OPEN" for custom shortcut..
- print_footer "Meta key will now open Krunner."
+ footer "Meta key will now open Krunner."
else
- print_footer "meta key change skipped." skipped
+ footer "meta key change skipped." skipped
fi
}
@@ -29,13 +29,13 @@ change_wallpaper() {
local wallpaper_path="$1"
prompt "Do you want to change wallpaper?" confirm_wallpaper
if [ "$confirm_wallpaper" == "y" ] || [ "$confirm_wallpaper" == "Y" ] || [ -z "$confirm_wallpaper" ]; then
- log "Changing wallpaper." inform
+ log.warn "Changing wallpaper."
sleep 2
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "var Desktops = desktops();for (i=0;i [config_file]"
+ log.error "Error: No theme name provided."
+ log.warn "Usage: change_sddm_theme [config_file]"
return 1
fi
@@ -98,7 +98,7 @@ change_sddm_theme() {
return 1
fi
- log "Changing SDDM theme to $theme_name." inform
+ log.warn "Changing SDDM theme to $theme_name."
if sudo sed -i "s/^Current=.*/Current=$theme_name/" "$config_file" ; then
echo "SDDM theme changed to $theme_name."
else
diff --git a/modules/optimise-fedora.sh b/modules/optimise-fedora.sh
index 2ed048a..56b330b 100644
--- a/modules/optimise-fedora.sh
+++ b/modules/optimise-fedora.sh
@@ -1,31 +1,35 @@
#Fedora by default needs various fixes to be able to work properly.
-
-source core-functions.sh
+#This module will fix those issues.
optimise_fedora() {
prompt "Start optimizing Your Fedora?" confirm_otf
if [ "$confirm_otf" == "y" ] || [ "$confirm_otf" == "Y" ] || [ -z "$confirm_otf" ]; then
- log "checking if you are using fedora"
+ log.warn "checking if you are using fedora"
local distro=$(get_distro_base)
if [ "$distro" == "fedora" ]; then
- log "starting." success
- log "updating system"
+ log.success "starting."
+
+ log.warn "updating system"
sudo dnf update
- log "Enabling RPM Fusion Repository"
+
+ log.warn "Enabling RPM Fusion Repository"
sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
- log "enabling fedora-cisco-openh264 Repo"
+
+ log.warn "enabling fedora-cisco-openh264 Repo"
sudo dnf config-manager --enable fedora-cisco-openh264
- log "installing appstream-data"
+
+ log.warn "installing appstream-data"
sudo dnf groupupdate core
- log "Enabling FlatHub"
+
+ log.warn "Enabling FlatHub"
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
- log "Installing Multimedia Plugins"
+
+ log.warn "Installing Multimedia Plugins"
sudo dnf install gstreamer1-plugins-{bad-\*,good-\*,base} gstreamer1-plugin-openh264 gstreamer1-libav --exclude=gstreamer1-plugins-bad-free-devel
sudo dnf install lame\* --exclude=lame-devel
sudo dnf group upgrade --with-optional Multimedia
-
+
fi
fi
}
-optimise_fedora
diff --git a/modules/pwa-fedora.sh b/modules/pwa-fedora.sh
deleted file mode 100644
index a36072a..0000000
--- a/modules/pwa-fedora.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-# Import GPG key and enable the repository
-sudo rpm --import https://packagecloud.io/filips/FirefoxPWA/gpgkey
-echo -e "[firefoxpwa]\nname=FirefoxPWA\nmetadata_expire=300\nbaseurl=https://packagecloud.io/filips/FirefoxPWA/rpm_any/rpm_any/\$basearch\ngpgkey=https://packagecloud.io/filips/FirefoxPWA/gpgkey\nrepo_gpgcheck=1\ngpgcheck=0\nenabled=1" | sudo tee /etc/yum.repos.d/firefoxpwa.repo
-
-# Update DNF cache
-sudo dnf -q makecache -y --disablerepo="*" --enablerepo="firefoxpwa"
-
-# Install the package
-sudo dnf install firefoxpwa
diff --git a/modules/resize-swap.sh b/modules/resize-swap.sh
index 4c2b6cf..e6f9b71 100644
--- a/modules/resize-swap.sh
+++ b/modules/resize-swap.sh
@@ -8,25 +8,25 @@ resize_swap() {
read -p "=>" rsz_swapf
if [ "$rsz_swapf" == "y" ] || [ "$rsz_swapf" == "Y" ] || [ -z "$rsz_swapf" ]; then
if [ -f "$swap_file" ]; then
- print_header "Swapfile already exists. Resizing to $swap_file_size..."
- log "turning off swaps" #log
+ log.info "Swapfile already exists. Resizing to $swap_file_size..."
+ log.warn "turning off swaps"
sudo swapoff -a
- log "removing already present swapfile." #log
+ log.warn "removing already present swapfile."
sudo rm "$swap_file"
else
- print_header "Creating swapfile of size $swap_file_size..."
+ log.info "Creating swapfile of size $swap_file_size..."
fi
- log "creating new file of ${swap_file_size}B for swap." #log
+ log.warn "creating new file of ${swap_file_size}B for swap."
sudo fallocate -l "$swap_file_size" "$swap_file"
- log "changing permissions." #log
+ log.warn "changing permissions."
sudo chmod 600 "$swap_file"
- log "making the ${swap_file} a swapfile." #log
+ log.warn "making the ${swap_file} a swapfile."
sudo mkswap "$swap_file"
- log "turning new swapfile on" #log
+ log.warn "turning new swapfile on"
sudo swapon "$swap_file"
- log "please check if everything is good:" #log
+ log.warn "please check if everything is good:"
swapon --show
- print_footer "Swapfile created and activated." #log
+ footer "Swapfile created and activated."
else
echo -e "${RED}swapfile size change skipped.${NC}"
fi
diff --git a/modules/restore-dotfiles.sh b/modules/restore-dotfiles.sh
index 63bab89..abb0597 100644
--- a/modules/restore-dotfiles.sh
+++ b/modules/restore-dotfiles.sh
@@ -1,33 +1,31 @@
# Function to restore dotfiles using stow
-
-
-# This function estimates that dotfiles folder is in $HOME dir.
+# This function estimates that dotfiles folder is in $HOME dir.
function stow_restore {
local cwd=$(pwd)
local dot_dir="$HOME/${1:-Dotfiles}"
- log "Restoring dotfiles using stow" inform
+ log.warn "Restoring dotfiles using stow"
if ! command -v stow >/dev/null 2>&1; then
- log "Stow is not installed, installing.... " inform
- install_package stow
+ log.warn "Stow is not installed, installing.... "
+ install-package stow
fi
- log "Current dir is $cwd"
- log "Changing directory to $dot_dir"
+ log.warn "Current dir is $cwd"
+ log.warn "Changing directory to $dot_dir"
if cd "$dot_dir"; then
- log "Running stow -v -R ."
+ log.warn "Running stow -v -R ."
if stow -v -R .; then
- log "Stow completed" success
+ log.success "Stow completed"
else
- log "Stow failed" error
+ log.error "Stow failed"
fi
else
- log "Failed to change directory to $dot_dir" error
+ log.error "Failed to change directory to $dot_dir"
fi
- log "Changing directory back to $cwd"
- cd "$cwd" || log "Failed to change back to $cwd" error
-}
\ No newline at end of file
+ log.warn "Changing directory back to $cwd"
+ cd "$cwd" || log.error "Failed to change back to $cwd"
+}